====================================[ ]==========

Wishing for shorter build times when (re)compiling large packages with pbuilder?

Enter ccache. Basically, it’s a layer between your compiler and code that leverages caching to improve build times by only recompiling where absolutely necessary.

Configuring pbuilder to use ccache in Ubuntu 10.04 (Lucid Lynx) is simple:

First, edit your ~/.pbuilderrc

EXTRAPACKAGES="ccache"
export CCACHE_DIR=/var/cache/pbuilder/ccache
export CCACHE_UMASK=002
BUILDUSERNAME=pbuilder
BUILDUSERID=$(grep $BUILDUSERNAME /etc/passwd | cut -d: -f3)
BINDMOUNTS="$BINDMOUNTS $CCACHE_DIR"
export PATH=&"/usr/lib/ccache:$PATH"

Create a user and group for ccache with permission to write from pbuilder’s chroot to a local directory (which must be created).

sudo addgroup --system ccache
sudo adduser --quiet --system --ingroup ccache --home /var/cache/pbuilder --no-create-home pbuilder
sudo chown pbuilder:ccache /var/cache/pbuilder/ccache
sudo chmod g+ws /var/cache/pbuilder/ccache

Don’t forget to create the ccache directory!

sudo mkdir /var/cache/pbuilder/ccache
===============================================================
====================================[ ]==========

The server kinda, uh… exploded.

Please stand-by as I toil tirelessly to bring the content back online ;)

===============================================================