Building with Cowbuilder

Cowbuilder™ is nice tool to build Debian packages in a defined environment. It makes sure all build-dependencies are specified correctly by building the package in a clean chroot. As its cousin Pbuilder™ it can be extended via hooks to (e.g. run autopkg tests) but doesn't need a tarball unpacked but uses copy on write tree to speed up the build.

Since Cowbuilder™ uses different command line arguments than Debuild™ and Dpkg-buildpackage™, we can't simply pass the options to run it on the command line. To simplifiy the integration we use a separate helper named git-pbuilder. gbp has it's own command line option for this:

  gbp buildpackage --git-pbuilder

This will set the build command to run git-pbuilder (which invokes Cowbuilder™ by default) and the clean command to /bin/true. It also activates the parsing of several git-pbuilder related options like --git-dist, --git-arch and --git-pbuilder-options.

We can make git-pbuilder usage the default by adding it to ~/.gbp.conf:

cat <<EOF > ~/.gbp.conf
# We invoke cowbuilder via git-pbuilder. Arguments passed to gbp buildpackage
# will be passed to dpkg-buildpackage in the chroot
pbuilder = True

git-pbuilder defaults to building a package for the sid distribution. If you want to build for another distribution, pass this in the --git-dist option:

  gbp buildpackage --git-pbuilder --git-dist=jessie

If you want to use debuild again (without modifying ~/.gbp.conf), you can use:

  gbp buildpackage --git-no-pbuilder

In order for all of the above to work you have to create a base chroot first using git-pbuilder:

  git-pbuilder create

This can later be updated using:

  git-pbuilder update