Skip to content
Michael Forney edited this page Aug 21, 2020 · 3 revisions

pkgsrc is a framework for building packages on NetBSD and other operating systems. It consists of a huge repository of packages, and is a convenient way to extend oasis with packages that aren't available in the base system.

Getting pkgsrc

See http://www.netbsd.org/docs/pkgsrc/getting.html for the official documentation.

I maintain a branch of the pkgsrc git mirror, and recommend using that and cloning into /src/pkgsrc.

git clone -c 'core.sharedRepository=group' https://github.com/oasislinux/pkgsrc.git /src/pkgsrc

Bootstrap

To avoid a circular dependency with flex, bash, and bison, make sure to install flex in oasis.

Since oasis uses unconventional tools compared to most Linux systems, a few tweaks are needed to get it to bootstrap and function correctly.

doas env groupsprog='id -Gn' FGREP='/bin/grep -F' EGREP='/bin/grep -E' TOUCH_FLAGS= \
	./bootstrap/bootstrap --prefix /pkg --prefer-pkgsrc yes --mk-fragment - <<EOF
MACHINE_GNU_PLATFORM=	x86_64-unknown-linux-musl
BUILDLINK_TRANSFORM+=	rm:-lbsd
COMPILER_INCLUDE_DIRS=	/include
LIBABISUFFIX=
ROOT_CMD=		doas sh -c
TOOLS_PLATFORM.bash=
TOOLS_PLATFORM.lex=	/bin/lex
TOOLS_PLATFORM.flex=	/bin/flex
TOOLS_PLATFORM.gm4=
TOOLS_PLATFORM.gsed=
TOOLS_PLATFORM.m4=	/bin/m4
TOOLS_PLATFORM.ninja=	/bin/samu
TOOLS_PLATFORM.patch=	/bin/patch
TOOLS_PLATFORM.pax=	/bin/pax
TOOLS_PLATFORM.sed=	/bin/sed
TOUCH_FLAGS=
EOF

Here is an explanation for the purpose of the various make variables:

  • MACHINE_GNU_PLATFORM: Otherwise, this gets set to x86_64-unknown-linux, which gets canonicalized as x86_64-unknown-linux-gnu.
  • BUILDLINK_TRANSFORM: Some X11 packages include <bsd/stdlib.h> based on the presence of libbsd.a. We don't have this header, so instead, pretend that libbsd.a doesn't exist.
  • COMPILER_INCLUDE_DIRS: Search for headers in /include, not /usr/include.
  • LIBABISUFFIX: Search for libraries in /lib, not /lib64.
  • ROOT_CMD: We don't have su, so use doas instead.
  • TOOLS_PLATFORM.bash: On Linux, bash is assumed to be installed, but we don't have it.
  • TOOLS_PLATFORM.flex: flex isn't auto-detected on Linux, so specify it explicitly.
  • TOOLS_PLATFORM.gm4: On Linux, any m4 is assumed to be GNU m4, but we use OpenBSD m4.
  • TOOLS_PLATFORM.gsed: On Linux, any sed is assumed to be GNU sed, but we use sbase sed.
  • TOOLS_PLATFORM.ninja: We have samurai instead of ninja, and ninja currently fails to build against musl libc.
  • TOOLS_PLATFORM.sed: On Linux, this is set to ${TOOLS_PLATFORM.gsed} which we cleared, so set this explicitly.
  • TOUCH_FLAGS: sbase touch doesn't support -f (a no-op compatibility flag), which is applied by default.

If you only want to install pkgsrc locally, pass --unprivileged.

You may also want to set MAKE_JOBS in your /etc/mk.conf.

Clone this wiki locally