Setting up chroot NetBSD

To simplify building packages and trying other risky things with the system, I use chroot environments setup using pkgtools/pkg_comp. Here is my ~/pkg_comp/default.conf configuration:
AUTO_TARGET="bin-install"
BUILD_TARGET="bin-install"
DISTRIBDIR="/usr/obj/releasedir/amd64"
DESTDIR="/var/chroot/pkg_comp/default"
REAL_PACKAGES="/usr/pkgsrc/packages.x86_64"
ROOTSHELL="/bin/sh"
PKG_DEFAULT_OPTIONS="gnome official-mozilla-branding"
MKCONF_VARS="$MKCONF_VARS PKG_DEFAULT_OPTIONS"
USE_DESTDIR="yes"
MKCONF_VARS="$MKCONF_VARS USE_DESTDIR"
UPDATE_TARGET="bin-install"
MKCONF_VARS="$MKCONF_VARS UPDATE_TARGET"
BINPKG_SITES=""
MKCONF_VARS="$MKCONF_VARS BINPKG_SITES"
MAKE_JOBS="8"
MKCONF_VARS="$MKCONF_VARS MAKE_JOBS"
SKIP_LICENSE_CHECK="yes"
MKCONF_VARS="$MKCONF_VARS SKIP_LICENSE_CHECK"
It sets up an environment suitable for building packages. This will only work after build.sh release was used to build a NetBSD release in /usr/obj/releasedir.

Inspired by Mike Volokhov's response to Jared McNeill's post about building 32bit packages, I then set up a 32bit build environment: First, I built a 32bit NetBSD release in /usr/obj/releasedir by following my normal procedure and adding the argument -m i386 to build.sh. Here is my ~/pkg_comp/32bit that sets up a 32bit environment to build packages (I'm not sure yet what this could be used for, maybe for building JDK):

AUTO_TARGET="bin-install"
BUILD_TARGET="bin-install"
DISTRIBDIR="/usr/obj/releasedir/i386"
DESTDIR="/var/chroot/pkg_comp/32bit"
REAL_PACKAGES="/usr/pkgsrc/packages.i386"
ROOTSHELL="/bin/sh"
PKG_DEFAULT_OPTIONS="gnome official-mozilla-branding"
MKCONF_VARS="$MKCONF_VARS PKG_DEFAULT_OPTIONS"
USE_DESTDIR="yes"
MKCONF_VARS="$MKCONF_VARS USE_DESTDIR"
UPDATE_TARGET="bin-install"
MKCONF_VARS="$MKCONF_VARS UPDATE_TARGET"
BINPKG_SITES=""
MKCONF_VARS="$MKCONF_VARS BINPKG_SITES"
MAKE_JOBS="8"
MKCONF_VARS="$MKCONF_VARS MAKE_JOBS"
SKIP_LICENSE_CHECK="yes"
MKCONF_VARS="$MKCONF_VARS SKIP_LICENSE_CHECK"
Simply use this with pkg_comp -c 32bit.

Both configurations use the user-destdir method of building packages, which means that packages get installed underneath their work directory as opposed to /usr/pkg and the binary package created from there. To really install a package in /usr/pkg there is a package-install target. To get rid of the binary package you can use package-remove.

This procedure has obvious advantages over the old method where it was basically impossible to retroactively build a binary package for an already installed package.

I noticed that amd64 NetBSD has 32bit libraries installed in /usr/lib/i386, so it can run 32bit binaries unmodified.

Comments