Using pbuilder to build Debian packages

pbuilder is a tool to use debootstrap for automatic package building in a clean environment. Confused already? debootstrap is a tool to create an encapsulated Debian environment inside a Debian installation. Imagine you run Sid (the "unstable" branch of Debian) and want to build a package for the stable branch Sarge. Then you can use debootstrap to install Sarge below a directory in your file system. When it's done you use chroot to get there and presto you are in a Sarge environment.

pbuilder automates this process by created such a debootstrapped Debian and building a package in there. This serves two purposes:

  • You can build packages for Sarge although your system already runs on Sid. (Common for developers.) It helps to keep packages clean.
  • You can check if all the dependencies are correct. The debootstrapped installation will contain no more packages than what's essential to run Debian. If a dependency is missing in your package's control information then you will notice that.

Currently the debootstrap tool is a bit broken for Sid so you need to first create a pbuilder (which is contained in a file called base.tgz) for Sarge...

pbuilder create --distribution sarge --mirror http://www.artfiles.org/debian.org

...and then upgrade it to sid...

pbuilder update --override-config --mirror http://www.artfiles.org/debian.org --distribution sid

(Before you run the second line make sure your /etc/pbuilderrc sets

DISTRIBUTION=sid

).