Pbuilder Component
Useful Articles
Building Packages
Once you have the pbuilder component installed and started you can simply build packages like this:
DIST=eoan sudo pbuilder build lcfg-example_1.2.71-1.dsc
(remove the sudo command if running as root).
The string passed in via the
DIST
environment variable is required and refers to one of your configured chroots.
The results will be stored in the location in the
BUILDRESULT
variable for the chroot (usually
/var/cache/pbuilder/result/$DIST
).
LCFG Configuration
A basic configuration using the pbuilder component is done something like this:
#define LCFG_PBUILDER_USE_LINTIAN
#define LCFG_PBUILDER_USE_RESULTS
#define LCFG_PBUILDER_USE_SUDO
#include <lcfg/options/pbuilder.h>
The following options are supported:
-
LCFG_PBUILDER_USE_LINTIAN
- Run lintian on the results of the build to check for common packaging errors
-
LCFG_PBUILDER_USE_RESULTS
- Make the results of a build available for subsequent builds through a local apt package repository.
-
LCFG_PBUILDER_USE_SUDO
- This is necessary if you want to run pbuilder as a normal user. Add the users to the local pbuilder group or configure sudoers (via the lcfg sudo component) as required.
Currently the following chroots are configured by default:
- Debian buster/stable
- Ubuntu bionic
- Ubuntu disco
- Ubuntu eoan
- Ubuntu focal
Defaults
See
lcfg/defaults/pbuilder.h
for the current set of defaults. To set your own defaults for all chroots you can use the
PBUILDER_DEFAULT
macro, for example:
PBUILDER_DEFAULT(TIMEOUT_TIME,2h)
Some options are treated as lists so to make it easier to modify them we have
PBUILDER_DEFAULT_BINDMOUNT
and
PBUILDER_DEFAULT_EXTRAPACKAGE
, for example:
PBUILDER_DEFAULT_EXTRAPACKAGE(ca-certificates)
PBUILDER_DEFAULT_BINDMOUNT($BUILDRESULT:/var/local_packages)
Distros
A
distro is just a set of options which a
chroot can inherit from. Using Debian as an example:
!pbuilder.distros mADD(debian)
PBUILDER_DISTRO_OPTION(debian,MIRRORSITE,http://ftp.uk.debian.org/debian/)
PBUILDER_DISTRO_OPTION(debian,COMPONENTS,main contrib non-free)
PBUILDER_DISTRO_OPTION(debian,KEYRING,/usr/share/keyrings/debian-archive-keyring.gpg)
That configures the apt repository appropriately for a Debian based chroot.
You can then configure a chroot which inherits those settings like:
PBUILDER_CHROOT(buster,debian)
chroots
Adding a new chroot can usually be done quite simply with the
PBUILDER_CHROOT
macro, there is also a
PBUILDER_CHROOT_OPTION
macro for setting options. For example:
PBUILDER_CHROOT(buster,debian)
!pbuilder.chrt_aliases_buster mADD(stable)
PBUILDER_CHROOT_OPTION(buster,DISTRIBUTION,buster)
That creates a new Debian-based chroot, named
buster. It also gives the chroot an alias of
stable so that either may be used in pbuilder commands.
You can inspect the generated configuration in the
pbuilder.dir_chroots
directory (which is usually
<%sysinfo.path_lcfgconf%>/pbuilder/chroot
).
To check the configuration for a chroot use the dumpconfig command, for example:
DIST=buster pbuilder dumpconfig
Hooks
Hooks are scripts which are run at various stages of the build process. They are well described in the
pbuilder manpage
. The file name has an initial letter that signifies the stage at which it should be called, followed by a 2 digit number which controls the order in which scripts are called.
Several standard scripts are provided:
- B90lintian
- Runs lintian at the end of the build process to check for common packaging errors.
- D70results
- Makes the build results available for subsequent builds as a local apt repository.
- E01inf_sources
- Configures apt to use the Informatics Debian package repositories.
You can add your own scripts. They should be placed in the
pbuilder.hooks_base
directory (which is usually
<%sysinfo.path_lcfgdata%>/pbuilder/hooks
). Add the file name to the
pbuilder.hooks
resource and it will activated with a symlink into the
pbuilder.hooks_dir
directory (which is usually
<%sysinfo.path_lcfgconf%>/pbuilder/hooks
).
--
squinney - 2019-12-09