Skip to the note
zecrazytux.net sysadmin  |  note index

~ / sysadmin / netbsd / build host

sysadmin

Building pkgsrc packages on a build machine

Sysadmin NetBSD pkgsrc Packaging

Keeping compilers off production machines is good practice. The heavy bulk build frameworks are not always needed for that: a build host can produce exactly the packages you name, and their dependencies, on demand.

Why bother

  • Production machines stay clean and have no toolchain installed.
  • There is no need to build the entire package collection to get one program.
  • The layered bulk build machinery can be skipped for a small set of packages.

Ask for packages, not installs

The trick is to tell the package framework that, for dependencies as well as the program itself, the target is to produce a package rather than to install one. A single setting in the configuration file does this.

# in the package build configuration
DEPENDS_TARGET= install package
cd /usr/pkgsrc/category/program
make install package

The result is a package for the program and one for every dependency it needed, all ready to be copied to the target machine.

Making an index for the package manager

The lightweight package manager needs a summary file next to the packages. It is generated from the installed metadata and then compressed.

cd /usr/pkgsrc/packages/All
pkg_info -X -a > pkg_summary
gzip -f pkg_summary

One known wart

The summary produced this way can be missing the recorded package sizes, and the package manager will warn that a package has an empty file size on the repository. It is cosmetic for a private mirror and can be lived with, but a fuller build framework generates a more complete summary if that warning matters.

The packaging guide is linked from the resources page.