Files
makronix/tools/vm-pkgbuild.sh
T
lotherkandClaude Sonnet 5.5 840782e24c sysinst, media, tests: desktop defaults, four CDs, Portuguese, AHCI test VMs
- sysinst simple mode: sshd on with root login by password, npf firewall,
  mDNS (mdnsd, nsswitch), PulseAudio, CUPS, dbus; extra programs from N
  package CDs (extras.c); cgd root fix (mnt2_mounted)
- Portuguese (pt_BR) catalogs and patch 0013; welcome text for DVD/CDs
- media: console=auto (0008), RAM-disk installer with two CDs (0012),
  package CDs and DVD packages (cd3.sh), userland.sh for the build VM
- tests: line-by-line checks, mDNS pattern, UEFI Enter loop, VMSH_AHCI
  (QEMU 11.1.2 loses PIIX IDE interrupts under load)
- docs: UPDATING.md, npf-default.conf, AGENTS.md updates

Measured 2026-11-07: simple 37 PASS, DVD+sources 42 PASS, cgd BIOS 35 PASS;
cgd UEFI with console=auto not green yet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 21:09:35 +00:00

105 lines
3.7 KiB
Bash
Executable File

#!/bin/sh
# vm-pkgbuild.sh -- build pkgsrc packages natively, inside the Makronix build VM.
#
# Runs IN THE GUEST, as root (docs/BUILD-VM.md):
#
# vm-pkgbuild.sh bootstrap once: pkgsrc's bootstrap into /usr/pkg
# vm-pkgbuild.sh build PKGPATH ... bmake package for each, binary packages
# into /var/tmp/packages/All
# vm-pkgbuild.sh pack PKGNAME ... the files of these installed packages and of
# everything they need at run time, as
# /var/tmp/usrpkg.tar.gz (paths from /)
#
# Why not cross-built on the host: pkgsrc's cross mode refuses recipes that
# need `sh:run' or `awk:run' (AGENTS.md, "Where a Linux build host stops").
# On NetBSD the same recipe builds, so those packages are built here, natively,
# from /usr/msrc/pkgsrc exactly as it was installed, and their binary packages
# are unpacked into the host's sysroot for the "makronix" set
# (tools/vm-pkgcollect.sh on the host).
#
# Nothing in pkgsrc changes. Configuration is /usr/pkg/etc/mk.conf, written
# once by `bootstrap': the work directory and the packages directory are out
# of the pkgsrc tree, the distfiles are the ones of /usr/msrc (what is missing
# is fetched there and has to be added to packages.list on the host).
set -eu
PKGSRC=${PKGSRC:-/usr/msrc/pkgsrc}
PREFIX=/usr/pkg
WORK=/var/tmp/pkgsrc-work
PACKAGES=/var/tmp/packages
JOBS=${JOBS:-8}
case ${1:-} in
bootstrap)
[ -x $PREFIX/bin/bmake ] && { echo "already bootstrapped"; exit 0; }
cd $PKGSRC/bootstrap
./bootstrap --prefix $PREFIX --workdir /var/tmp/pkgsrc-bootstrap \
--make-jobs "$JOBS" --prefer-native=yes
cat >> $PREFIX/etc/mk.conf <<EOF
# Makronix build VM (tools/vm-pkgbuild.sh)
WRKOBJDIR= $WORK
PACKAGES= $PACKAGES
DISTDIR= /usr/msrc/distfiles
MAKE_JOBS= $JOBS
EOF
;;
build)
shift
[ $# -ge 1 ] || { echo "usage: $0 build PKGPATH ..." >&2; exit 1; }
mkdir -p $WORK $PACKAGES
# wm/cde meets GCC 14 (tools/vmbuild/mk-cde.conf, which the host copies to
# /root): the block is added to mk.conf once, scoped to wm/cde by its own
# PKGPATH test
if [ -f /root/mk-cde.conf ] && ! grep -q CWRAPPERS_APPEND.cc $PREFIX/etc/mk.conf; then
cat /root/mk-cde.conf >> $PREFIX/etc/mk.conf
fi
for p in "$@"; do
echo "=== $p"
extra=
# the dialect NetBSD builds its own tree with (bsd.sys.mk:68); autoconf
# 2.72 would take C23, where CDE's `int f();' is `int f(void)'
[ "$p" = wm/cde ] && extra=FORCE_C_STD=gnu11
(cd $PKGSRC/$p && $PREFIX/bin/bmake $extra package-install)
done
;;
pack)
shift
[ $# -ge 1 ] || { echo "usage: $0 pack PKGNAME ..." >&2; exit 1; }
PATH=$PREFIX/bin:$PREFIX/sbin:$PATH
export PATH
# What a Makronix system needs is what pkg_add would pull in: the closure
# is walked over the "@pkgdep" lines of +CONTENTS (as tools/vmbuild/
# stage6-pack.sh did for CDE); build tools (perl, autoconf, ...) are not
# in it.
seen=" "
while [ $# -gt 0 ]; do
pkg=$1
shift
case "$seen" in
*" $pkg "*) continue ;;
esac
seen="${seen}${pkg} "
for dep in $(awk '$1 == "@pkgdep" { print $2 }' \
"$PREFIX/pkgdb/$pkg/+CONTENTS"); do
r=$(pkg_info -e "$dep" | head -1)
[ -n "$r" ] && set -- "$@" "$r"
done
done
echo "--- runtime closure:"
for p in $seen; do echo "$p"; done | sort
for p in $seen; do pkg_info -qL "$p"; done | sort -u > /var/tmp/files.txt
# a listed file the install removed again would stop tar halfway
while IFS= read -r f; do [ -e "$f" ] && echo "$f"; done \
< /var/tmp/files.txt > /var/tmp/files.ok || true
tar -czpf /var/tmp/usrpkg.tar.gz -T /var/tmp/files.ok
echo "--- files: $(wc -l < /var/tmp/files.ok)"
ls -l /var/tmp/usrpkg.tar.gz
;;
*)
echo "usage: $0 bootstrap | build PKGPATH ... | pack PKGNAME ..." >&2
exit 1
;;
esac