Packaging Base

Status

Packaged base has been available in the FreeBSD 11 branch as of r298107, however will continue to be considered a beta feature until 12.0-RELEASE.

At this time, the major blockers and critical issues appear to have been resolved, and an official call-for-testing has been issued. Please note, as with any development branch, this is not yet intended for production environments. Testing on virtual machines or dedicated testing machines is strongly encouraged.

At present, the base system consists of 755 packages with the default build (empty src.conf(5) and make.conf(5)) for amd64. The number of packages depends on several factors, but for most cases a runtime binary is split into several components. In particular, most shared libraries are individually packaged, in addition to debugging symbols, profiling libraries, and 32-bit packaged separately.

Outstanding Issues

Please follow up on the freebsd-pkgbase@ mailing list with problems (and successes).

Initial Setup to Use PkgBase

  1. Update your version of pkg(8) to a version after 1.7.0.

  2. Update your FreeBSD source tree to a revision after r298107 (FreeBSD 11.0-RELEASE and later will work; PkgBase is not supported in the FreeBSD 10 branches or earlier).

  3. Build the userland and kernel as normal with the 'buildworld' and 'buildkernel' targets. Afterward, packages can be created with the 'packages' Makefile target.
    # cd /usr/src
    # make [make flags] buildworld
    # make [make flags] buildkernel
    # make packages
    The package repository will be created within /usr/obj/usr/src/repo by default.
  4. To enable the repository for use by the local machine, create /usr/local/etc/pkg/repos/FreeBSD-base.conf with the following contents:
    # FreeBSD base system repository
    FreeBSD-base: {
      url: "file:///usr/obj/usr/src/repo/${ABI}/latest",
      mirror_type: "none",
      enabled: yes
    }
  5. To enable the repository for use on remote machines, you can setup an NGINX webserver on the machine which built the packages, adding the following lines to /usr/local/etc/nginx/nginx.conf:
    location /FreeBSD-base {
            alias           /usr/obj/usr/src/repo;
            autoindex       on;
    }
    On the remote machines which will use the pkgbase repository, create /usr/local/etc/pkg/repos/FreeBSD-base.conf with the following contents:
    # FreeBSD base system repository
    FreeBSD-base: {
      url: "http://URL.TO.PKGBASE.MACHINE/FreeBSD-base/${ABI}/latest",
      enabled: yes
    }
  6. If installing inside a jail, do not forget to create that jail with the allow.chflags option set to 1. Without this option, pkg(8) will be unable to overwrite files with the schg flag set, such as /lib/libc.so.7 or /sbin/init
  7. To initially bootstrap the 'FreeBSD-*' packages, they must be forcibly installed. Package registration is not performed during 'installworld' or 'installkernel', and there are no immediate plans to do this. This can be done by running:
    # pkg update -r FreeBSD-base
    # pkg install -g 'FreeBSD-*'
  8. Use mergemaster(8) or etcupdate(8) after upgrading the base system with pkg(8) to ensure configuration files are merged. This is still required since there is an outstanding issue with configuration file merging in PkgBase.

Kernel Packages

It is possible to build multiple kernel packages by listing the kernel configuration names in the KERNCONF variable (separated by spaces) defined in make.conf(5), as long as NO_INSTALLEXTRAKERNELS is also set to no. The first listed kernel in KERNCONF is installed as /boot/kernel, and subsequent kernels in KERNCONF are installed as /boot/kernel.${KERNEL}.

Building GENERIC is not required, as each kernel package is named with the kernel name included.

For example, if make.conf(5) contains:

NO_INSTALLEXTRAKERNELS=no
KERNCONF=MYKERNEL1 MYKERNEL2

The following kernel packages will be created:

Upgrading with PkgBase

After the first time the source tree was built and installed with PkgBase, upgrades can simply be performed by completing the following steps:

  1. Update the FreeBSD source tree and build the userland and kernel as normal with the 'buildworld' and 'buildkernel' targets. Afterward, packages can be created with the 'packages' Makefile target.
    # cd /usr/src
    # svn up
    # make [make flags] buildworld
    # make [make flags] buildkernel
    # make packages
  2. Upgrade the packages installed on the system:
    # pkg upgrade -r FreeBSD-base
  3. Check if any new base packages were created during the build process which would not be installed during an upgrade, or if any base packages no longer exist which would not have been removed during an upgrade:
    $ diff <(pkg rquery -r FreeBSD-base %n) <(pkg query -e '%o = base' %n) | grep "^[<>]"

    Any lines beginning with "<" are base packages which were built and exist in the repo but are not installed on your system, whilst lines beginning with ">" are base packages which are installed on your system but were not built and do not exist in the repo. You should consider whether you need to install or remove these base packages, or whether there is a deliberate difference between the built repo and your system.

  4. Use mergemaster(8) or etcupdate(8) after upgrading the base system with pkg(8) to ensure configuration files are merged. This is still required since there is an outstanding issue with configuration file merging in PkgBase.

Major Version Upgrades

If upgrading to a new major version of FreeBSD (e.g. from 11 to 12), then you may be greeted by the following error when performing the pkg upgrade:

For this case, the following command will allow a successful upgrade:

Project Goals and Items Needing Resolution

In addition to the outstanding issues noted above, the following items also need to be addressed before packaged base can be considered for prime-time use:

PkgBase (last edited 2017-06-18 23:25:31 by JonathanAnderson)