Cowbuilder

To create the chroot to build your package in, PBuilder extracts a tarball. Especially for smaller packages, significant speedup can be gained if we do not copy all those files out of the tarball every time the package is built, but ise some copy-on-write construction instead.

Cowbuilder does just that.

Procedure 3.  Prepare for using cowbuilder

  1. Install the package

    apt-get install cowbuilder

  2. Edit ~/.pbuiderrc to suit cowbuilder

    Near the top op ~/.pbuilderrc, put:

    PDEBUILD_PBUILDER=cowbuilder
    <snip>
    	  

    Further down, add a line about BASEPATH:

    <snip>
    BASETGZ="/var/cache/pbuilder/$NAME-base.tgz"
    # Cowbuilder understands no BASETGZ, but uses BASEPATH
    BASEPATH=/var/cache/pbuilder/$NAME-base.cow
    <snip>
    	  

    and under "# Debian Configuration" add:

    DEBOOTSTRAPOPTS=(${DEBOOTSTRAPOPTS[@]/--keyring=*})
    DEBOOTSTRAPOPTS=(${DEBOOTSTRAPOPTS[@]} --keyring=/usr/share/keyrings/debian-archive-keyring.gpg)
    	  

  3. Remove the old pbuilder chroots

    sudo rm -rf /var/cache/pbuilder/*

  4. Create new chroots

    sudo DIST=precise cowbuilder --create --components "main universe multiverse"
    apprentice@host:~/packaging/hello-2.8$  sudo DIST=wheezy cowbuilder --create

  5. Use PBuilder with COWBuilder

    apprentice@host:~/packaging/hello-2.8$ DIST=trusty pdebuild
    apprentice@host:~/packaging/hello-2.8$ DIST=wheezy pdebuild

  6. Separate places for separate distros' packages

    If you amend the BUILDRESULT line in ~/.pbuilderrc a bit, like this:

    BUILDRESULT="/var/cache/pbuilder/$NAME/result/"
    if ! echo $@|grep -qe --create ; then
        BUILDRESULT=../build-area
        [ -n "${DIST}" ] && BUILDRESULT="${BUILDRESULT}/${DIST}"
    #    [ -n "${ARCH}" ] && BUILDRESULT="${BUILDRESULT}/${ARCH}"
        install -d "${BUILDRESULT}"
        export BUILDRESULT="${BUILDRESULT}"
    fi
    	  

    then after running

    apprentice@host:~/packaging/hello-2.8$ DIST=wheezy pdebuild

    you get:

    apprentice@host:~/packaging/hello-2.8$ ls -trl ../build-area/wheezy/amd64
    total 784
    -rw-rw-r-- 1 apprentice apprentice 697483 mei 28  2012 hello_2.8.orig.tar.gz
    -rw-rw-r-- 1 apprentice apprentice  12602 jun 29 21:25 hello_2.8-4.debian.tar.gz
    -rw-r--r-- 1 apprentice apprentice  68654 jun 29 21:25 hello_2.8-4_amd64.deb
    -rw-rw-r-- 1 apprentice apprentice   1617 jun 29 21:25 hello_2.8-4.dsc
    -rw-rw-r-- 1 apprentice apprentice   2165 jun 29 21:25 hello_2.8-4_amd64.changes