open core »

Fixing libdlna formula in Homebrew

Update: This fix has now been added to the Homebrew package.

Recently I got an XBox 360 for xmas, and started looking for ways to stream the music in my Macbook Air to it. I found some interesting commercial software to do it, but stumbled upon an open-source linux tool called uShare that was also available through the Homebrew package manager.

Doing a brew install ushare immediately stopped due to a make install error of the libdlna package, a dependency of uShare, that is required for compatibility with Playstation 3. Here’s the error I got:

profiles.c: In function 'av_profile_get_codecs':
profiles.c:208: error: 'CODEC_TYPE_AUDIO' undeclared (first use in this function)
profiles.c:208: error: (Each undeclared identifier is reported only once
profiles.c:208: error: for each function it appears in.)
profiles.c:214: error: 'CODEC_TYPE_VIDEO' undeclared (first use in this function)
make[1]: *** [profiles.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [install] Error 2

This error happens for newer versions of the libavformat that no longer have the symbols CODEC_TYPE_AUDIO and CODEC_TYPE_VIDEO.

So, in order to fix the formula you need to apply this patch to the source code of libdlna. You can find the content of this patch in a github gist. But to successfully install the Homebrew formula you have to edit the formula file and include this patch in the patches method:

$ brew edit libdnla

Then find the patches method (on line 10) and change the code inside to the following:

def patches
    # fixes ffmpeg locations
    # fixes missing symbols for newer versions of libavformat

Basically, instead of returning just the patch that was already in the formula as a string, I’m now returning an array with that patch, and my patch.

Now just save the file and:

$ brew install libdlna

And then resume the ushare formula install:

$ brew install ushare

That’s it. It should now install without a hassle.

I submitted this change to the Homebrew project with a pull request, so anytime soon you won’t be needing this workaround :)