When I add new software to my digital workflow, the first thing I do is learn how to customize it. This usually means scouring the internet for blog posts written by people who have successfully configured this software in a non-trivial way and implemented it into their long-running systems with stable uptimes. Recently, I came across a blog post by “vermaden” detailing a FreeBSD concept called “PkgBase”.
Personal FreeBSD PKGBASE Update Server
To my understanding, “PkgBase” is a way to encapsulate FreeBSD’s base system (comprising both kernel and userland) into standard FreeBSD packages that can be installed normally using `pkg`. Normally, a system would consume a single `pkg` repository that contains packages from the Ports collection. With “PkgBase”, you can add a second `pkg` repository containing “PkgBase” packages. The entire system (base and ports) can be upgraded in a single shot using `pkg upgrade`.
I find this really elegant. A clear divide between FreeBSD’s official sources and external third-party sources is still maintained, but distributing and installing all of it can be done in a unified manner. It’s quite convenient for me to just run a few commands to upgrade my entire system.
So far, I’ve been taking a rolling-release approach to my FreeBSD build systems. This involves:
I’ll just quickly summarize the first two bullets here using a 10-step process paraphrased from the FreeBSD handbook:
# cd /usr/src (1) # git checkout stable/14 (2) # git pull (3) get up-to-date on the news by reading the UPDATING file # make -j$(nproc) buildworld buildkernel (4) # make installkernel (5) # reboot (6) # etcupdate -p (7) # make -C /usr/src installworld (8) # etcupdate -B (9) # shutdown -r now (10)
How to build FreeBSD base from source
I’ve trimmed my configuration for each of these builds in this way:
This results in a lean, mean, FreeBSD machine. I’m happy with the level of fat that this method burns off for my personal use.
However, the second step of “installing the base system” is annoying. It mostly works fine for installing a base system onto the same host, but what about managing tons of hosts with heterogeneous hardware? I’d ideally like to have a fleet of lean, mean, FreeBSD machines, with tidy custom configuration. This is when I noticed the bit near the bottom of vermaden’s blog post:
I did not (yet) [investigate] the Poudriere way of doing it – but [Mina Galić] was kind enough to share [their] HOWTO on the topic.
Perfect. After searching the internet more on this topic, I came across an upstream Poudriere discussion on the same topic.
How to use poudriere to (only??) build pkgbase?
The only thing I need to do is create a Poudriere jail with the `-B` option. This is so simple!
poudriere jail -c -j poudriere_stable14_upstream -b -m git+https -v stable/14 -B -K MYKERNCONF -z myconfig
As mentioned, I’ve already been using Poudriere to create a personal Ports repository. What I learned from Mina’s post is that Poudriere can also be used to build a personal FreeBSD base repository.
This essentially means I can create my own carefully curated and trimmed personal FreeBSD distribution with just a single tool: Poudriere! This is incredible and I love this software. I’ll be writing more comprehensively in the future about how I use Poudriere to maintain my FreeBSD systems.
It seems that Poudriere has followed the UNIX philosophy perfectly. It really only does one thing, but it does it extremely well.