Posted by Steve on Wed 23 Mar 2005 at 02:42
When creating new packages it's important to test that they can build properly on all machines, not just the machine that you use to test it on. This usually means testing that the package build-dependencies are specified correctly.
In Debian packages there are two forms of dependencies you can specify:
The build-dependencies are usually fairly easy to determine, but a lot of developers still make mistakes - because they forget to define a dependency which just happens to be installed upon their personal build machine.
This is especially important if you're a Debian developer and you're uploading a package to main archive - because your package will be built upon all the available build machines.
If the package isn't correct and doesn't have all the depencencies specified correctly it will fail to build and thus fail to be updated on all the architechures that Debian supports.
The simplest way to test building a package is to install a minimal Debian system inside a chroot jail and build it against that. This ensures that only a minimal set of packages will be installed by default, and that the only additional packages will be those you've explicitly defined in your package's control file.
Thankfully this process is very simple via the use of the pbuilder package.
To install it run, as root:
apt-get install pbuilder
Once this is done you'll be able to create a new unstable installation of Debian inside your filesystem, this is what you can then build against to test your package's dependencies.
To get started you'll probably want to modify the default configuration. The following settings are taken from /etc/pbuilderrc:
MIRRORSITE=http://ftp.jp.debian.org/debian #export http_proxy=http://your-proxy:8080/
These are the two things you might need to change, whilst you can download all your packages from Japan it makes sense to choose a location closer to you!
Once that's done you setup the initial, minimal, installation of Sid by running:
This will create the base image. (Later you can update this by running "pbuilder update"). It does this by downloading a set of base packages, so be warned it might take some time to complete.
Once that has been done you're all set.
When we covered rebuilding Debian packages previously we introduced the debuild command to perform a package build.
Using pbuilder instead you should simply use pdebuild - this will build your package inside the faux system we've installed, with any packages you specify as being required to build your binary installed as required.
Because the build will start from a clean, minimal, environment on each run you will discover that you need to download a lot of packages when the build starts.
If all goes well you can find your binary package located in "/var/cache/pbuilder/result" and be assured that the package will have it's dependencies satisfied.
Building your packages with pbuilder is a good habbit to get into, as it will easily spot broken build-dependencies and allow your users to rebuild your packages without undue hassles.
This article can be found online at the Debian Administration website at the following bookmarkable URL (along with associated comments):
This article is copyright 2005 Steve - please ask for permission to republish or translate.