pbuilder(1)
Personal builder: constructs Debian packages in a clean chroot environment to verify build dependencies and package integrity.
Synopsis
pbuilder [OPTION] {create|update|build|login|execute|clean|dumpconfig}Description
pbuilder creates and maintains a clean chroot-based build environment (a "base.tgz" filesystem image) for building Debian packages. This ensures reproducible builds by isolating them from the host system's package state and testing that declared build dependencies are complete and correct.
The tool works by creating a minimal Debian system in a tarball, then extracting it for each build. Common workflows include: creating a fresh base environment, updating it with latest packages, building packages within it, and accessing the environment interactively for debugging.
Common options
| Flag | What it does |
|---|---|
--create | Create a new base.tgz chroot environment from scratch |
--update | Update an existing base.tgz with latest packages from the repository |
--build | Build a .dsc (Debian source) package or .deb file inside the chroot |
--login | Open an interactive shell inside the chroot environment for debugging |
--execute | Execute a single command inside the chroot (e.g., pbuilder execute -- apt-get update) |
--clean | Clean up temporary build directories and extracted chroots |
--basetgz FILE | Specify path to the base.tgz image (default: /var/cache/pbuilder/base.tgz) |
--distribution DIST | Set target Debian distribution (e.g., bookworm, jammy, bullseye) |
--mirror URL | Set Debian package mirror URL for apt (e.g., http://deb.debian.org/debian) |
--debbuilddir DIR | Specify directory inside chroot where packages are built (default: /tmp/buildd) |
--save-after-login | Save the chroot state back to base.tgz after exiting a login session |
--configfile FILE | Load configuration from a pbuilderrc file instead of /etc/pbuilderrc |
Examples
Create a fresh Debian bookworm chroot environment and save it to base.tgz
sudo pbuilder create --distribution bookwormUpdate the existing base.tgz with latest package versions from the mirror
sudo pbuilder updateBuild a Debian package from its .dsc source file in the clean chroot; result stored in /tmp/buildd/result
sudo pbuilder build mypackage_1.0-1.dscStart an interactive shell in the chroot to inspect or manually test; changes persist after exit
sudo pbuilder login --save-after-loginRun a single command (apt-cache search nginx) inside the chroot without opening a full shell
sudo pbuilder execute -- apt-cache search nginxBuild a package using a specific Debian mirror URL instead of the default
sudo pbuilder build --mirror http://deb.debian.org/debian myapp_2.1.dscBuild using an alternate base chroot image for Bullseye instead of the default
sudo pbuilder build --basetgz /var/cache/pbuilder/bullseye.tgz package.dscRemove all temporary build directories and extracted working copies
sudo pbuilder clean