Tuesday, September 25, 2007

Fun with Debian Source Packages I

Most of the time there's no need to build packages from source. But sometimes it can be useful. I did this on several occasions, for several reasons:
  • manually apply a patch from the Debian bug tracking system, so as to fix a bug
  • attempt to fix/debug a problem (this requires programming skills, and motivation - I happen to have both)
  • build binaries with different options than those used by the package maintainer
Why would anyone do the latter? Well, I'll have more to say about that next time.

For now I'll just spell out the procedure for building a typical Debian package from source (adapted from the APT HOWTO):
  • one-time step: add a deb-src line to /etc/apt/sources.list, like this:
    deb-src http://http.us.debian.org/debian/ testing main contrib non-free
  • run apt-get update
  • install build dependencies for the package you want to build (I'll use bacula-sd as an example):
    apt-get build-dep bacula-sd
  • cd to a temporary directory
  • get the source package:
    apt-get source bacula-sd
  • cd to the newly created source directory:
    cd bacula-2.2.0/
  • optional: make modifications to the source code
  • build the package:
    dpkg-buildpackage -rfakeroot -uc -b
  • optional: install the package:
    dpkg -i ../bacula-sd_2.2.0-1_i386.deb
    note that all the bacula packages are built from the same source package, so that the parent directory actually contains a bunch of binary packages.
The source directory is typically quite similar to the upstream source package, except that it contains a sub-directory named debian, where Debian specific files reside. Among these is the rules file which can be used to manually perform the various steps in the build process.

More fun to come.

No comments:

Post a Comment