ccache + pbuilder

As it looks like there is some ccache hype lately in Planet Debian, I’ll add some of my own.

I use pbuilder to build my packages and it was a real PITA when some big package like wesnoth or kdesomething failed to build and I’d to restart the build from scratch, so (after several months of procastination) I decided to add ccache powers to my pbuilder setup. In fact, it was quite easy, although a bit “dirty”.

  1. Create a directory to store the ccache cache for your pbuilder, for example,
    /var/cache/pbuilder/ccache
  2. Create a directory to put the needed pbuilder hooks, for example, ~/debian/pbuilder-hooks/
  3. Add an A (run just before starting the build) hook to set up ccache, for example, A01ccache:

    #!/bin/sh
    echo "Setting up ccache"
    apt-get install ccache
    cd /usr/lib/ccache
    for c in *
    do
       ln -s /usr/bin/ccache /usr/sbin/$c
    done
    ln -s /var/cache/pbuilder/ccache /root/.ccache

    This is the dirty bit, as I can’t set $PATH from one of the hooks, I link the ccache stuff into /usr/sbin/ which precedes /usr/bin/ in $PATH, if somebody knows any other clean way (i.e., without modifying the chroot) to do this, please tell me.
  4. I’ve two more hooks, to run interactive shells when the package finishes building (or fails building), note that you need to run the shell like this:

    /bin/bash < /dev/tty > /dev/tty
  5. Run pbuilder with the correct options, I’ve a script named wonderbuild to do this:

    #!/bin/sh
    pdebuild -- --bindmounts /var/cache/pbuilder/ccache --hookdir ~/debian/pbuilder-hooks/ $*

I expect this to be useful to somebody else, it works really great for me :) Any improvement would be welcome.

3 Responses to “ccache + pbuilder”

  1. glandium.org Says:

    pbuilder and ccache

    Isaac, there is actually a cleaner way to do the same as your hook. Just add the following to your .pbuilderrc file :

    export CCACHE_DIR=”/var/cache/pbuilder/ccache”
    export PATH=”/usr/lib/ccache:${PATH}”
    EXTRAPACKAGES=ccache
    BINDMOUNTS=”${CCACH…

  2. isaac Says:

    I’m not sure how but I managed to delete a very useful comment/trackback from Mike Hommey. http://web.glandium.org/blog/?p=55

    “Isaac, there is actually a cleaner way to do the same as your hook. Just add the following to your .pbuilderrc file :
    export CCACHE_DIR=”/var/cache/pbuilder/ccache”
    export PATH=”/usr/lib/ccache:${PATH}”
    EXTRAPACKAGES=ccache
    BINDMOUNTS=”${CCACHE_DIR}”

  3. Pierre Says:

    Playing The Angel

    Lick the light switch …

Leave a Reply