This is the tutorial for cowbuilder. See also qemubuilder.



Create the base image:

sudo cowbuilder --create

And a new and shiny build image is created in /var/cache/pbuilder/base.cow/

Every day usage

Update the base image

sudo cowbuilder --update

Build a package:

sudo cowbuilder --build somepackage.dsc


Bash and SVN tips

Setup your .bashrc according to:

Building your package for many distributions at once

cowbuilder is really handy to build your pet project for many distributions at once. If you have got an amd64 system, you can easily build a package for i386 and amd64 architectures and for say stable, sid and lucid.

You can use an apt cache to reduce the downloads on mirrors, so my mirror is always http://apt:9999/debian or http://apt:9999/ubuntu. ( you shoud then add --mirror http://apt:9999/debian 

sudo mkdir  /var/cache/pbuilder/squeeze-i386

Creating a base path :

DIST=squeeze sudo cowbuilder --create --basepath /var/cache/pbuilder/squeeze-amd64/base.cow 

Creating an ubuntu base path which is trickier because one must :

<!> Some steps left to describe here.

$ DIST=gutsy sudo cowbuilder --create --distribution gutsy --components "main universe" --basepath /var/cache/pbuilder/gutsy-amd64.cow --mirror http://apt:9999/ubuntu --debootstrapopts --exclude=udev,pcmciautils,initramfs-tools

Building i386 base paths may be achieved by appending those options to the cowbuilder --create command line.

--debootstrapopts --arch --debootstrapopts i386

Once everything is set up, I use this script in a debian source package directory to build it for every distribution.

set -e

[ -d $RESULTDIR ] || mkdir $RESULTDIR

DISTLIST=$(ls -d /var/cache/pbuilder/*.cow)

for chrootdir in $DISTLIST
    sudo cowbuilder --update --basepath $chrootdir
    DIST=$(basename $chrootdir | cut -d'-' -f1)
    [ -d $RESULTDIR/$DIST ] || mkdir $RESULTDIR/$DIST
    DIST=$DIST pdebuild --pbuilder cowbuilder\
                        --buildresult $RESULTDIR/$DIST\
                        -- --basepath $chrootdir


Slow copying and removing of the COW directory

What cowbuilder does is:

cp -al /var/cache/pbuilder/base.cow /tmp/new
rm -rf /tmp/new

Of course cowbuilder uses a different location than /tmp/new. You need to optimize those 2 commands on your computer. They should take around 0.2s each. If not, try to use the ext3 filesystem, for more details, see our benchmarks.