This site is now 100% read-only, and retired.

Testing package building with pbuilder

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:

  • Build Dependencies
    • These are all the packages which must be installed before the given package can be built from source.
  • Dependencies
    • These are the packages which must be installed before this package can be installed and used.

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:

#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:

pbuilder create

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.



Re: Testing package building with pbuilder
Posted by gna (217.173.xx.xx) on Wed 23 Mar 2005 at 09:17
[ View Weblogs ]
Maybe a dumb question, but what should a .dsc file contain? That is mentioned in the docs of pbuilder.

And anyway, if i want to create my own binary package, how do i do it?

[ Parent ]

Re: Testing package building with pbuilder
Posted by Steve (82.41.xx.xx) on Wed 23 Mar 2005 at 09:23
[ View Weblogs ]

A .dsc is produced when you build a package with debuild - if you're in the source directory of a Debian package you can just invoke pdebuild and not worry about it though.

Building a Debian binary package from scratch is too big a thing to explain in a single comment but you can find all the information in Debian's new maintainer guide.


[ Parent ]

Re: Testing package building with pbuilder
Posted by gna (217.173.xx.xx) on Wed 23 Mar 2005 at 10:01
[ View Weblogs ]
Thanks for the quick response.

Maybe if i find a really good method for making packages from scratch-tar.gz then i will post a guide-like document.

My current problem is to have the binary files copied to the package structure. Right now i only try to use diff on the chrooted build enviroment with a before file-list and an after file-list.

I managed to create simple packages manually.

[ Parent ]

Re: Testing package building with pbuilder
Posted by Steve (82.41.xx.xx) on Wed 23 Mar 2005 at 13:32
[ View Weblogs ]

If you're used to installing inside a chroot and looking at the results - you might like checkinstall.

From the package description:

 CheckInstall keeps track of all the files created or
 modified by your installation script ("make install"
 "make install_modules", "setup", etc), builds a
 standard binary package and installs it in your
 system giving you the ability to uninstall it with your
 distribution's standard package management utilities.


[ Parent ]

Re: Testing package building with pbuilder
Posted by gna (212.40.xx.xx) on Wed 23 Mar 2005 at 14:22
[ View Weblogs ]

I'll try it soon.


[ Parent ]

Re: Testing package building with pbuilder
Posted by glanz (216.209.xx.xx) on Sat 26 Mar 2005 at 14:35
[ View Weblogs ]

is a nice tutorial about Creating .deb-Packages With Checkinstall.... It clears up a lot of confusion.(^>

[ Parent ]

Re: Testing package building with pbuilder
Posted by dkg (72.43.xx.xx) on Fri 21 Oct 2005 at 16:22
[ View Weblogs ]
Thanks for this article! i'm trying to set up pbuilder now on a mixed etch/sid system, and i'm getting the following errors from pbuild create:
squeak:~# pbuilder create
W: /root/.pbuilderrc does not exist
Distribution is sid.
Building the build environment
 -> running cdebootstrap
P: Retrieving Release.gpg
P: Retrieving Release
P: Parsing Release
P: Retrieving Packages.gz
P: Validating Packages
P: Parsing Packages
P: Retrieving libc6
P: Validating libc6
P: Retrieving libgcc1
P: Validating libgcc1
----snip out lots of Retrieving, Validating, and Unpacking----
P: Unpacking package bash
P: Unpacking package findutils
P: Configuring package makedev
P: Configuring package sysv-rc
P: Configuring package gcc-4.0-base
P: Configuring package libpam-runtime
P: Configuring package libc6
E: Couldn't install root!
pbuilder: cdebootstrap failed
 -> Aborting with an error
 -> cleaning the build env 
    -> removing directory /var/cache/pbuilder/build//22966 and its subdirectories
Any thoughts on what might be going wrong? do i need to have the host system running straight sid?

[ Parent ]

Re: Testing package building with pbuilder
Posted by Steve (82.41.xx.xx) on Sat 22 Oct 2005 at 15:45
[ View Weblogs ]

Please see this page for a brief discussion of the problem:


[ Parent ]