Using Poudriere on FreeBSD

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

This post is about using Poudriere on FreeBSD

Introduction

Although not as popular as Linux, FreeBSD is an operating system with great features and a stable codebase. One of the many features of FreeBSD (and most BSD based systems in general) is the Port Collection is. FreeBSD has been offering users to build software from source long before Gentoo adopted it. However, using the ports system proves difficult when you have to use them for multiple machines. That’s where poudriere (pronounced poo-DRE-er) comes to the rescue. Poudriere is a collection of various scripts that use existing FreeBSD features like jails to build and manage packages. With Poudriere, we also make private repositories to be used by our various systems. Nevertheless, it can be also used on a personal machine if we want to use pkg as well as build packages from source with custom configurations. That way it’s less likely that conflicts will occur between our binary packages (from pkg) and the packages build from the ports tree. In this article, I will go over how I have setup and am using poudriere while learning about FreeBSD. This is by no means an exhaustive tutorial so you should definitely also check out the links in the references below.

Setup

I have a freshly installed virtual machine running FreeBSD 13.1-RC5. And, I have installed nothing on it so that we have a clean state.

I’m using ZFS whose features can be used by poudriere. By default, poudriere will put its work files under /usr/local/poudriere. So, let’s create datasets for it.

Creating datasets for poudriere

Now we’ll need some software.

Installing poudriere

Now that we have installed poudriere. Let’s configure it. Since we’re in BSD land, every package we installed will have it’s files and folders under /usr/local/. As such, the file we need is /usr/local/etc/poudriere.conf. That file is self-documented, so I will only specify what I’ve changed.

ZPOOL=zroot
ZROOTFS=/usr/local/poudriere
FREEBSD_HOST=https://ftp4.tw.freebsd.org
CCACHE_DIR=/var/cache/ccache
DISTFILES_CACHE=/usr/ports/distfiles

Note that I’ve set the FREEBSD_HOST as one of the nearest mirrors to me. You can always just go with the suggested one: https://download.FreeBSD.org. Furthermore, since we’re specifying the CCACHE_DIR, we’ll need to install devel/ccache.
# pkg install ccache
Finally, poudriere can share the distfiles with the host whose location is defined with the DISTFILES_CACHE option. Therefore, we’ll need to make sure that directory exists.
# mkdir -p /usr/ports/distfiles

Creating a Jail

Since I’m using FreeBSD 13.1, I’ll create a jail for the 13.0-RELEASE version.

# poudriere jail -c -j amd64-13-0 -v 13.0-RELEASE

Creating a jail

This will take a while.

Install a Ports Tree

Nice thing about using poudriere is we can use different ports trees for different builds. For now, our jail doesn’t contain any ports. We can create one using the following command.
# poudriere ports -cp head
Specify the name with the-p flag.

Needed git

That tells us we also need git. My bad. I haven’t installed the ports tree on my base system so we’ll also have to do it using pkg.
# pkg install git

Installing Packages

Let’s start by defining the package list. The usual place is in /usr/local/etc/poudriere.d/pkglist. For now, I’ll specify only a few packages.

Defining pkglist

The sole purpose we’re building from ports is so that we can configure it. Let’s do that:
# poudriere options -j amd64-13-0 -p head -f /usr/local/etc/poudriere.d/pkglist

Now build the packages with:
poudriere bulk -j amd64-13-0 -p head -f /usr/local/etc/poudriere.d/pkglist

Building packages

Using the Private Repository

We can do this by specifying a repository to be used by pkg.

# mkdir -p /usr/local/etc/pkg/repos

Let’s disable the default configuration file:

# printf "FreeBSD: {\n\tenabled: no\n}\n" > /usr/local/etc/pkg/FreeBSD.conf

Now create a separate file and specify the poudriere packages:

/usr/local/etc/pkg/amd64-13-0.conf:
amd64-13-0: {
url: file:///usr/local/poudriere/data/packages/amd-13-0-head,
enabled: yes
}

Our host is now ready to use these packages. Let’s tell pkg to reinstall all of the packages.
# pkg install -fy

And that’s it.

References:

  1. Absolute FreeBSD by Michael W. Lucas (book)
  2. The FreeBSD Handbook
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Pratik Devkota
Pratik Devkota
Software engineering student interested in UNIX (GNU/Linux, *BSD, etc.), security as well as free and open-source software.

2 COMMENTS

  1. Thanks! I essentially followed this tutorial for my first steps with Poudriere.

    Just a small correction: /usr/local/etc/pkg/FreeBSD.conf should be /usr/local/etc/pkg/repos/FreeBSD.conf, you forgot the ‘repos’ in the path name. Occurs in a few other places too.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook