Packaging FreeBSD base
PkgBase is the FreeBSD base operating system (OS), packaged.
Use of pkg(8) is the norm for installation of, and updates to, ported software that runs on the OS.
Where it becomes possible to also use pkg for the OS:
Packages will be provided from FreeBSD 14.0 onwards:
In addition, to aid exploration and adoption, an unofficial repository https://pkg.freebsd.evilham.com/images is provided by Evilham (Andrés).
In Bugzilla:
Use of a virtual machine, or a dedicated test machine, is encouraged.
PkgBase comprises a few hundred packages with the default build (empty src.conf(5) and make.conf(5)) for amd64. The number of packages depends on several factors.
In most cases, a runtime binary is split into multiple components. Debugging symbols and most shared libraries are packaged individually. 32-bit is bit packaged separately.
Content below this line is outdated, will be updated …
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.
/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
}
/usr/local/etc/nginx/nginx.conf:location /FreeBSD-base {
alias /usr/obj/usr/src/repo;
autoindex on;
}
On remote machines that 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
}
allow.chflags 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/initinstallworld 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-*'
Caution: There is currently no built-in mechanism for bootstrapping pkg info from the existing system, and files (such as /etc/master.passwd) will be replaced with default copies from the newly installed packages. Existing files will be renamed with a .pkgsave extension.
Files that may be of particular interest include:
WARNINGS:
After upgrading, if you have the following message from su
su: who are you?
It means that you have replaced your master.passwd file during the upgrade, in order to restore your user and rebuild the passwd database, you can do the commands below, then login again:
# cp /etc/master.passwd.pkgsave /etc/master.passwd # /usr/sbin/pwd_mkdb -p /etc/master.passwd
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:
After the first time the source tree was built and installed with PkgBase, an upgrade involves the following steps:
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 update-packages
Note that for make update-packages working correctly you need WITH_REPRODUCIBLE_BUILD=yes in /etc/src.conf as it compares the internal package data.
# pkg upgrade -r FreeBSD-base
$ diff <(pkg rquery -r FreeBSD-base %n) <(pkg query -e '%o = base' %n) | grep "^[<>]"
Lines beginning with < are base packages that were built and exist in the repo but are not installed on your system. Lines beginning with > are base packages that are installed on your system but were not built and do not exist in the repo. Consider whether (a) you need to install or remove these packages; or (b) there is a deliberate difference between the built repo and your system.
When attempting a major upgrade of FreeBSD (e.g. from 11 to 12), you may find the following error:
# pkg upgrade -r FreeBSD-base Updating FreeBSD-base repository catalogue... Fetching meta.txz: 100% 268 B 0.3kB/s 00:01 Fetching packagesite.txz: 100% 52 KiB 52.9kB/s 00:01 Processing entries: 0% pkg: wrong architecture: freebsd:12:x86:64 instead of FreeBSD:11:amd64 pkg: repository FreeBSD-base contains packages with wrong ABI: freebsd:12:x86:64 Processing entries: 100% Unable to update repository FreeBSD-base All repositories are up-to-date. pkg: Repository FreeBSD-base cannot be opened. 'pkg update' required Checking for upgrades (0 candidates): 100% Processing candidates (0 candidates): 100% Checking integrity... done (0 conflicting) Your packages are up to date.
For this case, the following command will allow a successful upgrade:
# env ABI=freebsd:12:x86:64 pkg-static upgrade -r FreeBSD-base
pkg upgrade. This is particularly problematic if files are moved from an existing package to a new dedicated package, which will result in them being deleted during the next pkg upgrade. This was noticed after r299840, which moves /etc/rc.d/[zfs|zvol] from the existing FreeBSD-runtime package to a new FreeBSD-zfs package, and resulted in them being deleted during the next pkg upgrade..if ! ${.CURDIR:M/usr/src*})Please follow up on the freebsd-pkgbase@ mailing list with problems (and successes).
The following items need to be addressed before PkgBase can be considered for production use:
installworld target will need to be pkg(8)-aware, and must be able to handle non-networked systems) (manu@ : working on it)/boot/kernel and /boot/kernel.$KERNCONF for multi-kernel support needs to be addressed (Note: while both kernels can be installed simultaneously as packages, the one that gets installed to /boot/kernel is a dependency of the runtime package. Additionally, changing from make KERNCONF="GENERIC GENERIC-NODEBUG" buildkernel to make KERNCONF="GENERIC-NODEBUG GENERIC" does properly replace /boot/kernel and /boot/kernel.GENERIC-NODEBUG with /boot/kernel and /boot/kernel.GENERIC.) (manu@ : working on it)pkg install -f or similar.pkg register with the version from freebsd-version as it finds files that belong to pkgs.A call for testing was made in March 2016.
Major blockers and critical issues appeared to be resolved.
Userland packages sets – can someone clarify what exactly this means?
TODO:
Package containing the source tree that a [base] package set was built from. Note: while I think this is a good idea, I have concerns about behavioral consistency between pkg upgrade and svn up ''/usr/src''. Some things that come to mind immediately are:
pkg upgrade; svn up changing checksums recorded in the pkg(8) database;/usr/src?Add SVN rev of source tree to pkg metadata (or equivalent, plus indicate if the tree has been modified similarly to uname(1)) (Note: committed as r322412.)
RDBMS-backed web application to collect file checksums from every official package and allow users to verify files on-line.
Using pkgdb as an IDS?