4.6.Â Building Packages with
Poudriere

Poudriere is a
BSD-licensed utility for creating and testing
FreeBSD packages. It uses FreeBSD jails to set up isolated
compilation environments. These jails can be used to build
packages for versions of FreeBSD that are different from the system
on which it is installed, and also to build packages for i386 if
the host is an amd64 system. Once the packages are
built, they are in a layout identical to the official mirrors.
These packages are usable by pkg(8) and other package
management tools.

Poudriere is installed using
the ports-mgmt/poudriere package
or port. The installation includes a sample configuration
file /usr/local/etc/poudriere.conf.sample.
Copy this file to
/usr/local/etc/poudriere.conf. Edit the
copied file to suit the local configuration.

While ZFS is not required on the system
running poudriere, it is beneficial.
When ZFS is used,
ZPOOL must be specified in
/usr/local/etc/poudriere.conf and
FREEBSD_HOST should be set to a nearby
mirror. Defining CCACHE_DIR enables the use
of devel/ccache to cache
compilation and reduce build times for frequently-compiled code.
It may be convenient to put
poudriere datasets in an isolated
tree mounted at /poudriere. Defaults for the
other configuration values are adequate.

The number of processor cores detected is used to define how
many builds will run in parallel. Supply enough virtual memory,
either with RAM or swap space. If virtual
memory runs out, the compilation jails will stop and be torn
down, resulting in weird error messages.

4.6.1.Â Initialize Jails and Port Trees

After configuration, initialize
poudriere so that it installs a
jail with the required FreeBSD tree and a ports tree. Specify a
name for the jail using -j and the FreeBSD
version with -v. On systems running
FreeBSD/amd64, the architecture can be set with
-a to either i386 or
amd64. The default is the
architecture shown by uname.

On a single computer, poudriere
can build ports with multiple configurations, in multiple
jails, and from different port trees. Custom configurations
for these combinations are called sets.
See the CUSTOMIZATION section of poudriere(8) for details
after ports-mgmt/poudriere or
ports-mgmt/poudriere-devel is
installed.

The basic configuration shown here puts a single jail-,
port-, and set-specific make.conf in
/usr/local/etc/poudriere.d.
The filename in this example is created by combining the jail
name, port name, and set name:
10amd64-local-workstation-make.conf.
The system make.conf and this new file
are combined at build time to create the
make.conf used by the build jail.

Packages to be built are entered in
10amd64-local-workstation-pkglist:

4.6.2.Â Configuring pkg Clients to Use a Poudriere
Repository

While it is possible to use both a custom repository along
side of the official repository, sometimes it is useful to
disable the official repository. This is done by creating a
configuration file that overrides and disables the official
configuration file. Create
/usr/local/etc/pkg/repos/FreeBSD.conf
that contains the following:

FreeBSD: {
enabled: no
}

Usually it is easiest to serve a poudriere repository to
the client machines via HTTP. Set up a webserver to serve up
the package directory, for instance:
/usr/local/poudriere/data/packages/10amd64,
where 10amd64
is the name of the build.

If the URL to the package repository is:
http://pkg.example.com/10amd64, then the
repository configuration file in
/usr/local/etc/pkg/repos/custom.conf
would look like: