Lately I’ve been playing with FreeBSD and its new technologies; PKGNG & poudriere and the new KMS/X.org stack that has been pushed to HEAD.
This is just my short how to for updating a FreeBSD CURRENT installation (10.0 at the moment of writing) with the new source code available on the FreeBSD servers.
Starting from FreeBSD 10.0 updating the base system through sources is performed with Subversion; and a lite version of it is shipped in the base system.
Table of Contents
Get the source
First of all we must proceed in downloading the full sources from the FreeBSD servers:
svnlite checkout svn://svn0.eu.FreeBSD.org/base/head /usr/src svnlite checkout svn://svn0.eu.FreeBSD.org/ports/head /usr/ports svnlite checkout svn://svn0.eu.FreeBSD.org/doc/head /usr/doc
The ports directory; which is quite large; can also be downloaded and put in place with the following commands:
portsnap fetch portsnap extract
This will populate all the directories with the required source code.
Define configuration for binaries
After getting the sources; we need to define some variables in the
/etc/make.conf file to play with the new technologies being introduced.
Many things like PKGNG, CLANG, etc. have been enabled by default in recent builds, so the list is quite small:
# These lines are required to make sure that the make update command works SVN=/usr/bin/svnlite SVN_UPDATE=yes # These lines enable the new X.org server (1.12.4) new Mesa libraries, KMS support, etc. WITH_NEW_XORG=yes WITH_KMS=yes WITH_GALLIUM=yes # Line for custom kernel configuration KERNCONF=CUSTOM
FreeBSD still ships by default with X.org server 1.7; Mesa 7.x and a lot of outdated components. The new X.org components have not been switched yet to default; so specific lines need to be put in place for compiling the required port versions.
After this file, we need to create the kernel configuration file that is specified by the
KERNCONF variable. I’m happy with the
GENERIC kernel as I run it on multiple systems; so I will not change any option inside the configuration. What I do is turn off debugging support that is enabled by default on unrealeased FreeBSD versions.
So let’s create
/usr/src/sys/amd64/conf/CUSTOM and put the following content inside:
include GENERIC ident CUSTOM # Disable debugging options nooptions DDB nooptions GDB nooptions DEADLKRES nooptions INVARIANTS nooptions INVARIANT_SUPPORT nooptions WITNESS nooptions WITNESS_SKIPSPIN nooptions MALLOC_DEBUG_MAXZONES
This kernel configuration file does nothing except specifying a new name and disabling the debugging options already enabled by default in the FreeBSD kernel. This way, when I update the sources; I don’t need to pay attention at which features are new or change in the
GENERIC kernel. Pretty smart system.
Update the base system
To update the system, launch the following commands as root (you can of course build the system without being root, but for this short how to this is much clear):
cd /usr/src make -s update make -s -j5 buildworld make -s -j5 buildkernel
The various make commands will make sure that you update the system with the latest sources and build all the toolchain required to compile the system and all the system commands and libraries. After this we’re good to go to install the new kernel and reboot the system:
make -s installkernel shutdown -r now
When rebooting, choose “Boot in single user mode” (
boot -s at the prompt) and perform the following commands to mount the root system in read/write mode:
mount -u / mount -a -t ufs
Then check for conflicting configuration files that are to be updated (in my case 90% of the time I just need to press “i” to install the new configuration file); install the updated binaries and reboot.
mergemaster -p cd /usr/src make -s installworld mergemaster reboot
Configure poudriere for generating packages
FreeBSD 10 does not ship anymore with legacy package management tools but only with PKGNG; so the old way of building ports feels “obsolete” after you’ve been using a Linux distribution with package management for years. Thanks, poudriere comes to the rescue.
First of all we install the bleeding edge poudriere package (hey, we’re on 10.0-CURRENT; so we are already bleeding!). To install the package, go to the ports directory and install it:
cd /usr/ports/ports-mgmt/poudriere-devel make install
After installing, we need to configure it and create a FreeBSD jail for building packages and some variables in poudriere’s configuration file.
cd /usr/local/etc/ cp poudriere.conf.sample poudriere.conf
Personally, this is what I have in my configuration file:
NO_ZFS=yes FREEBSD_HOST=ftp://ftp.freebsd.org RESOLV_CONF=/etc/resolv.conf BASEFS=/share USE_PORTLINT=no USE_TMPFS=yes DISTFILES_CACHE=/usr/ports/distfiles CHECK_CHANGED_OPTIONS=yes CHECK_CHANGED_DEPS=yes NOLINUX=yes
As you can see I don’t have a ZFS filesystem, I’m not interested in Linux support and I’m sharing the downloaded source tarball directory with the ports system.
/share directory is a separate mount point in my system where I link the base FreeBSD source folder, the ports directory, the documentation source directory and all the poudriere jails, work queues and package repositories. Make sure to have plenty of space!
We need to replicate the
/etc/make.conf of our base system inside the jail to make sure all the packages get the correct settings. Create the file
/usr/local/etc/poudriere.d/10-amd64-make.conf with the following contents:
Now we’re ready to start with poudriere. Issue the following commands:
poudriere ports -c poudriere jail -c -m ftp -v 10.0-CURRENT -j 10-amd64
This will download a recent copy of the ports tree and create a FreeBSD jail taking the most recent snapshot of 10.0-CURRENT directly from the FreeBSD ftp servers! Awesome.
To update the ports tree, just issue the following command:
poudriere ports -u
Now that we’re ready to go, it’s time to list what ports we would like to build. Create a text file and put the list of ports you want to build inside of it; for example:
x11/xorg x11/xorg-minimal x11/nvidia-driver x11/nvidia-settings ports-mgmt/poudriere-devel
If you want some additional specific per-port configuration options, you can use the options subcommand. For example; to disable Linux support in the Nvidia driver, perform the following command:
poudriere options x11/nvidia-driver
and deselect Linux; much like you would do using standard ports.
Generate package repositories from the ports collection
Now that all is in place it’s time to trigger the builds. Perform the following command:
poudriere bulk -f portslist.txt -j 10-amd64
Poudriere will take care of setting a parallel task for each cpu you have and make sure all the dependencies are built in the correct order.
After munching for a long time (better go hack some Ingress portals or leave it running night long…) you will have a repository ready for use on your system. Depending on the paths/names you’ve chosen for the FreeBSD jail and for the configuration file you will have something like the following:
# cd /share/data/packages/10-amd64-default
# ls -l
drwxr-xr-x 2 root wheel 8704 Sep 13 18:35 All
drwxr-xr-x 2 root wheel 512 Sep 13 11:51 Latest
-rw-r--r-- 1 root wheel 12508 Sep 13 18:35 digests.txz
-rw-r--r-- 1 root wheel 46344 Sep 13 18:35 packagesite.txz
-rw-r--r-- 1 root wheel 97092 Sep 13 18:35 repo.txz
You just need to add the repository to your system and you’re ready to install packages! The repository also contains the latest pkg package for distribution.
This folder can be published on the web, left locally or wherever you choose. The only thing you need to do is enable the repository on your system(s) through the
As an example, if you want to use the current package repository directly on the system where you’ve built everything just leave the following line in the configuration file:
Using package repositories
Finally a great package management for FreeBSD. First of all update the repository definition:
and then install the packages you want! For example:
pkg install xorg nvidia-driver
PKGNG will take care of everything.
To update packages, just re-update the ports tree with poudriere, rebuild with the bulk command (only the changed packages or the packages with changed dependencies will be rebuilt!) and upgrade your system!
poudriere ports -u poudriere bulk -f portslist.txt -j 10-amd64 pkg update pkg upgrade