Using Debootstrap, Pbuilder and Co to build Debian Packages

09.06.2006 at 09:27

Building debian packages within your normal system can be quite dangerous because care has to be taken that the resulting binary won't link against wrong libraries etc. To simplify this process there are a few useful tools available. These can not only be used to build packages, other use cases include building a chroot environment from a given distribution or install a base system.

Creating a chroot environment

Debootstrap builds a chroot environment of a given distribution. First take a look at what will be installed.

debootstrap --print-debs sid .

if it looks ok then download the packages i prefer to keep them in a tarball for further use

debootstrap --make-tarball sid-chroot.tgz sid .

later you can use that tarball to actually extract the debs an install them into a given directory.

mkdir ~/sid-chroot && cd ~/sid-chroot
debootstrap --unpack-tarball sid-chroot.tgz sid .

so if everything worked so far you should now have a complete root filesystem which is ready to chroot into.

chroot . /bin/sh

Another package which can do nearly the same is cdebootstrap, it is mostly a reimplementation for debootstrap written in the c programming language for use in the debian-installer.

cdbootstrap -f minimal sid .

Compiling packages in a clean room environment

If you wan't to compile debian packages in a clean room environment then take a look at pbuilder. First you will need to create a build environment, as a side note pbuilder uses debootstrap to accomplish this.

pbuilder create --distribution sid

This will create a base.tgz file in /var/cache/pbuilder. By default changes to the pbuilder environment will be lost after logout. To prevent this you have to login as follows

pbuilder login --save-after-login

Now we are able to build actuall packages for example do something like

apt-get source gcc-4.1-source
pbuilder build *.dsc

Further information

For further information consult the manpages of the corresponding programs. In addition the following sites could be quite interesting.

Comments (0)

There are currently no comments available