$linuxjunkies
>

pbuilder(1)

Personal builder: constructs Debian packages in a clean chroot environment to verify build dependencies and package integrity.

UbuntuDebianFedoraArch

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

FlagWhat it does
--createCreate a new base.tgz chroot environment from scratch
--updateUpdate an existing base.tgz with latest packages from the repository
--buildBuild a .dsc (Debian source) package or .deb file inside the chroot
--loginOpen an interactive shell inside the chroot environment for debugging
--executeExecute a single command inside the chroot (e.g., pbuilder execute -- apt-get update)
--cleanClean up temporary build directories and extracted chroots
--basetgz FILESpecify path to the base.tgz image (default: /var/cache/pbuilder/base.tgz)
--distribution DISTSet target Debian distribution (e.g., bookworm, jammy, bullseye)
--mirror URLSet Debian package mirror URL for apt (e.g., http://deb.debian.org/debian)
--debbuilddir DIRSpecify directory inside chroot where packages are built (default: /tmp/buildd)
--save-after-loginSave the chroot state back to base.tgz after exiting a login session
--configfile FILELoad 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 bookworm

Update the existing base.tgz with latest package versions from the mirror

sudo pbuilder update

Build 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.dsc

Start an interactive shell in the chroot to inspect or manually test; changes persist after exit

sudo pbuilder login --save-after-login

Run a single command (apt-cache search nginx) inside the chroot without opening a full shell

sudo pbuilder execute -- apt-cache search nginx

Build a package using a specific Debian mirror URL instead of the default

sudo pbuilder build --mirror http://deb.debian.org/debian myapp_2.1.dsc

Build using an alternate base chroot image for Bullseye instead of the default

sudo pbuilder build --basetgz /var/cache/pbuilder/bullseye.tgz package.dsc

Remove all temporary build directories and extracted working copies

sudo pbuilder clean

Related commands