[CFT] packaging the base system with pkg(8)

Glen Barber gjb at FreeBSD.org
Wed Mar 2 23:54:31 UTC 2016

For those who have missed the initial email surrounding this topic, we
are planning on packaging the base system with pkg(8) for 11.0-RELEASE.


At this time, I believe the major blockers and critical issues have been
resolved where it is time for an official call-for-testing.

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.

Also note (as repeated below), running 'pkg delete -a' will implicitly
remove base system packages after they are installed.

To obtain the sources for testing, please use the projects/release-pkg

 # svn co svn://svn.freebsd.org/base/projects/release-pkg /usr/src

The projects/release-pkg branch is (at this time) in sync with head
revision r296327.

After checking out the project branch, build the userland and kernel as
normal with the 'buildworld' and 'buildkernel' targets.  Afterward,
packages can be created with the 'packages' target.

 # cd /usr/src
 # make [make flags] buildworld
 # make [make flags] buildkernel
 # make packages

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.

The package repository will be created within /usr/obj/usr/src/repo by

To enable the repository, create /usr/local/etc/pkg/repos/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

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-*'

Please note the following:

1) The pkg(8) binary is required for this to work, however an additional
   patch against the ports-mgmt/pkg port is required to properly track
   base system shared libraries.  The patch against the ports-mgmt/pkg
   port is attached.  In my testing, excluding this patch has not caused
   anything horrible to happen, however applying both patches is
   suggested at this point.  The main noticeable effect of excluding the
   patch is system binary packages and their dependent library packages
   are not directly linked, which makes it possible to delete a library
   package that is required by a runtime binary.

2) At present, running 'pkg delete -a' will implicitly remove the
   'FreeBSD-*' packages, leaving the system in an unusable state.  There
   are valid use cases for removing all packages, such as test chroot(8)
   or jail(8) environments, so a solution to avoid accidental foot
   shooting is still being investigated.

3) With the attached patch, /lib32 and /usr/lib32 shared libraries are
   not tracked.  Since they are optional and do not affect the default
   running userland, this should not prevent testing, however it is
   worth noting.

4) For kernel packages, 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 'KERNCONF=MYLOCALKERNEL' is set in make.conf(5), the resulting
   kernel package will be 'FreeBSD-kernel-mylocalkernel-release', and
   the debug symbols as 'FreeBSD-kernel-mylocalkernel-debug'.

5) There are still a few outstanding issues with configuration file
   merging, which is still being investigated.

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

Many suggestions were made, such as further granularity between runtime
binaries and daemons (rwho(1) and rwhod(8) is one example I recall
off-hand), that have not been implemented yet (and also not forgotten).

Thank you in advance to everyone that can test this, so we can get this
completed in time for 11.0-RELEASE.


-------------- next part --------------
Index: ports-mgmt/pkg/files/patch-libpkg_pkg__config.c
--- ports-mgmt/pkg/files/patch-libpkg_pkg__config.c	(nonexistent)
+++ ports-mgmt/pkg/files/patch-libpkg_pkg__config.c	(working copy)
@@ -0,0 +1,15 @@
+--- libpkg/pkg_config.c.orig	2016-01-26 23:32:05 UTC
++++ libpkg/pkg_config.c
+@@ -390,6 +390,12 @@ static struct config_entry c[] = {
+ 		"pkg+http,pkg+https,https,http,ftp,file,ssh",
+ 	},
++	{
++		"NO",
++		"Enable base libraries analysis",
++	},
+ };
+ static bool parsed = false;
Index: ports-mgmt/pkg/files/patch-libpkg_pkg__elf.c
--- ports-mgmt/pkg/files/patch-libpkg_pkg__elf.c	(nonexistent)
+++ ports-mgmt/pkg/files/patch-libpkg_pkg__elf.c	(working copy)
@@ -0,0 +1,40 @@
+--- libpkg/pkg_elf.c.orig	2015-09-21 08:53:23 UTC
++++ libpkg/pkg_elf.c
+@@ -85,23 +85,28 @@ static int
+ filter_system_shlibs(const char *name, char *path, size_t pathlen)
+ {
+ 	const char *shlib_path;
++	bool packaging_base = pkg_object_bool(pkg_config_get("ALLOW_BASE_SHLIBS"));
+-	shlib_path = shlib_list_find_by_name(name);
+-	if (shlib_path == NULL) {
+-		/* dynamic linker could not resolve */
+-		return (EPKG_FATAL);
++	if (!packaging_base) {
++		shlib_path = shlib_list_find_by_name(name);
++		if (shlib_path == NULL) {
++			/* dynamic linker could not resolve */
++			return (EPKG_FATAL);
++		}
+ 	}
+-	/* match /lib, /lib32, /usr/lib and /usr/lib32 */
+-	if (strncmp(shlib_path, "/lib", 4) == 0 ||
+-	    strncmp(shlib_path, "/usr/lib", 8) == 0)
+-		return (EPKG_END); /* ignore libs from base */
++	if (!packaging_base) {
++		/* match /lib, /lib32, /usr/lib and /usr/lib32 */
++		if (strncmp(shlib_path, "/lib", 4) == 0 ||
++		    strncmp(shlib_path, "/usr/lib", 8) == 0)
++			return (EPKG_END); /* ignore libs from base */
++	}
+ 	if (path != NULL)
+ 		strncpy(path, shlib_path, pathlen);
+ 	return (EPKG_OK);
+ /* ARGSUSED */
+ static int
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-pkgbase/attachments/20160302/6f4aa34a/attachment.sig>

More information about the freebsd-pkgbase mailing list