Dec 27, 2007

Customizing Debian Packages

Debian's packaging system makes it really easy to modify packages if you want to. In this little howto I modify ffmpeg to add MP3 support but the process can easily be adapted to any package.

First create a work directory and drop down into it. This is just to make cleanup easy.

$> mkdir temp; cd temp

Then make sure the ffmpeg build dependencies are installed
$> sudo apt-get build-dep ffmpeg

Then download the source package
$> apt-get source ffmpeg

Then install the extra (codec) libraries we're adding support for
$> sudo apt-get install liblame-dev libfaad2-dev libfaac-dev libxvidcore4-dev

Then drop down into the ffmpeg source directory
$> cd ffmpeg*

Now you will have to edit the first line of the the debian/changelog and modify the package version. If you don't system updates will want to 'replace' your modified package. The first line should look something like this:
ffmpeg (3:0.cvs20070307-5ubuntu4) gutsy; urgency=low
. You will want append something at the end of the part in parentheses. In my case I use:
ffmpeg (3:0.cvs20070307-5ubuntu4-mg1) gutsy; urgency=low

It's my initials followed by a revision number.

Once you've modified the change log you can build the package but before we do we set an environment variable used by the build scripts that indicates we want the 'risky' libraries included.
$> DEB_BUILD_OPTIONS=risky && fakeroot debian/rules binary

Now we just need to install the packages. The packages were placed up one directory during the build process so we just move up and install.
$> cd .. && sudo dpkg -i *.deb

Now we just clean up after ourselves
$> cd .. && rm -rf temp

No comments: