This is a draft step-by-step instruction about how to create a permanent pbuilder chroot. The permanent chroot does not need to be unpacked, thus using it speeds up your pbuilder builds. However: consider the result a dirty environment to do some quick builds in: in the end you will need to test build in a normal, clean pbuilder chroot.
The general idea is to force pbuilder into not cleaning up the chroot by generating an error. The error is generated with an update hook. After that you can use the chroot with the --buildplace option. For details about pbuilder hooks and the options used below: see the pbuilder(1) manual page.
This is a first draft. Please do send me your feedback. My contact info is on https://launchpad.net/~mouz.
If you have not done so already, create a normal pbuilder chroot:
$ sudo pbuilder create
Create a script that generates an error (replace /path/to/hooks with some convenient path):
$ mkdir -p /path/to/hooks/disabled/ $ cat > /path/to/hooks/disabled/error #!/bin/sh echo echo ERROR IS DELIBERATE. exit 127 ^D $ chmod +x /path/to/hooks/disabled/error
Create a symbolic link to make it an update hook:
$ cd /path/to/hooks/ $ ln -s ./disabled/error E00error
Make sure there are no other symlinks or scripts in /path/to/hooks/. Then use the script as a pbuilder hook:
$ sudo pbuilder update \ --hookdir /path/to/hooks/ \ --debug ... ++ basename /var/cache/pbuilder/build//54321/tmp/hooks/E00error + chroot /var/cache/pbuilder/build//54321 tmp/hooks/E00error ERROR IS DELIBERATE. $
Pbuilder will not clean up the unpacked environment (which is what you want). Make a note of its location, ex. /var/cache/pbuilder/build/54321/.
Unmount the mounts left behind:
$ sudo umount /var/cache/pbuilder/build/54321/proc $ sudo umount /var/cache/pbuilder/build/54321/dev/pts
Remove the symbolic link to disable the update hook:
$ rm /path/to/hooks/E00error
You can build in this environment using the --no-targz option:
$ sudo pbuilder build \ --no-targz \ --buildplace /var/cache/pbuilder/build/54321 \ <foo-1.2-3ubuntu4>.dsc
The build result can be found in /var/cache/pbuilder/build/54321/tmp/buildd/. Any Build-Depends installed and anything else you do in this chroot will be preserved, which is an important reason to consider this chroot 'quick and dirty'.
pbuilder setup and usage: PbuilderHowto
pbuilder user manual: http://www.netfort.gr.jp/~dancer/software/pbuilder-doc/pbuilder-doc.html
- manual page: pbuilder(1)
alternative permanent chroot setup: DebootstrapChroot