Tweaking and recompiling .deb packages

Fixing a bug or experimenting with a program often requires going back to the source. Compiling the program yourself from a tarball usually means you lose the benefits of your package system, such as dependency tracking. Fortunately, Debian and Ubuntu include mechanisms to let you compile packages yourself without straying too far from the world of your package manager. It's actually really easy, because the repositories contain information about where to get source files and how to compile them. (I've tried these instructions on Ubuntu.)

  1. Install compilers and other dev tools:
    sudo apt-get install build-essential devscripts fakeroot
  2. Install the build-time dependencies for the package:
    sudo apt-get build-dep FOO
  3. Download the source for your package (to the current directory):
    apt-get source foo
    At this point, you can make whatever modifications you wish to the source.
  4. Compile the package:
    cd FOO-6; debuild -us -uc
    To compile with debugging information, use
    export DEB_BUILD_OPTIONS="debug nostrip noopt"
  5. You now have a shiny new .deb file. Install it with
    dpkg --install FOO_6-1_i386.deb
    Congratulations!

1 comment: