release: a stale package work directory is rebuilt, not installed

Two bugs made the native release ship code from the day before:

- tools/pkgchroot.sh ran 'install' in a work directory pkgsrc had already
  built.  pkg_add printed 'already recorded as installed' and the step
  counted as done, so MCDE and splinter in the 2026-11-23e run were the
  binaries of 2026-11-22 21:39 while their distfiles were written 08:38
  (build/logs/release-2026-11-23e.log:30,44).  sandbox_stale() now drops a
  work directory that is older than its recipe, and the old registration
  goes with it -- the cross path in tools/userland.sh did that already.

- ensure_bootstrap returned at once for every mode but cross, so a fresh
  tree without build/pkg stopped in tools/makronix-set.sh (pkg_info) and in
  the reinstall logic (pkg_delete).  It now bootstraps in all three modes.

The target system needs none of it: /usr/bin/make and /usr/sbin/pkg_add are
in base-util-bin and base-pkgutil-bin.

Test: sandbox_stale() against a work directory dated 2026-11-22 21:39 and
the recipe of 2026-11-23 -- stale: removed; fresh: kept.  dash -n on both
scripts.  The release itself is not run yet.

ext/src/mcde 288d1383: dtphoto, one CMD_SHOWOPTIONS case
ext/src/splinter f7c374b: embed.c, <signal.h> for kill/SIGKILL
This commit is contained in:
lotherk committed 2026-11-23 11:41:40 +00:00
1 parent b8f1b70c43
commit d300fc1329
6 files changed
+78 -19

No files matched your search

+3
View File
@@ -56,3 +56,6 @@
[submodule "ext/src/mcde"]
path = ext/src/mcde
url = https://git.kropa.tech/hiddenbox/mcde
[submodule "pkgsrc"]
path = pkgsrc
url = https://github.com/NetBSD/pkgsrc.git
Submodule
+1
Submodule pkgsrc added at 3c1118e944.
+43
View File
@@ -99,6 +99,36 @@ sandbox_index()
# (tools/pkgsrc-cross.mk.conf), this one accepts it by name (measured
# 2026-11-23: five recipes stopped on "unacceptable license condition"). `install' builds the package and installs it
# into /usr/pkg -- which, inside the chroot, is the sysroot's /usr/pkg.
# pkgsrc keeps a work directory until it is told otherwise: the cookies
# (.build_done, .package_done) say the work is done, and `install' then takes
# the binary package that the last build produced. On this host that meant the
# release shipped MCDE and splinter as they were on 2026-11-22 21:39, while the
# distfiles of 2026-11-23 08:38 were never extracted -- pkg_add printed
# "already recorded as installed" and the step counted as done
# (build/logs/release-2026-11-23e.log:30,44). A work directory older than the
# recipe or the archive is not that package's build any more: it goes.
#
# The comparison is by mtime, not by content: the archive is written by
# tools/ext-dist.sh from the fork's HEAD, so a new commit gives it a new time,
# and a recipe edit touches its Makefile. -- 2026-11-23
sandbox_stale()
{
sr_path=$1
w=$(ls -d "$SB/work/$sr_path"/work.* 2>/dev/null | head -1)
[ -n "$w" ] || w=$SB/work/$sr_path/work
[ -d "$w" ] || return 1
# Everything pkgsrc reads before it builds: the Makefile, distinfo (which
# changes with the archive, tools/ext-dist.sh writes both), options,
# patches and the PLIST. No parsing of DISTFILES/DISTNAME: a recipe may
# name its archive either way, and a file in the recipe directory that is
# newer than the work directory is the one fact that matters.
newer=$(find "$TOP/pkgsrc/$sr_path" -newer "$w" -print -quit 2>/dev/null)
[ -n "$newer" ] || return 1
echo "pkgchroot: $sr_path: ${newer#$TOP/pkgsrc/$sr_path/} is newer than the work directory -- rebuilding"
rm -rf "$w"
return 0
}
sandbox_run()
{
# The names are prefixed on purpose: a plain `p=$1` here overwrote the
@@ -150,6 +180,19 @@ build)
trap 'umount_all' EXIT INT TERM HUP
for p in "$@"; do
echo "=== pkgchroot: $p"
# A rebuilt package must replace its registration: pkg_add only
# compares names, and the same name is what a changed recipe and a
# new archive produce. The old version goes before the install, the
# way the cross path does it (tools/userland.sh).
if sandbox_stale "$p"; then
# the name the recipe gives this build, as the recipe computes it
pn=$(chroot "$D" /usr/bin/env -i \
PATH=/usr/sbin:/usr/bin:/sbin:/bin HOME=/mnt/work \
/usr/bin/make -C "/mnt/pkgsrc/$p" WRKOBJDIR=/mnt/work \
-V PKGNAME 2>/dev/null)
[ -n "$pn" ] && chroot "$D" /usr/sbin/pkg_delete -f \
-K /usr/pkg/pkgdb "$pn" > /dev/null 2>&1 || true
fi
sandbox_run "$p" install
done
sandbox_clean
+29 -17
View File
@@ -165,27 +165,39 @@ ensure_mk_key()
mkdir -p "${kf%/*}" && printf "%s\n" "$key" > "$kf"
}
# pkgsrc's bootstrap: the prefix with bmake/pkg tools for this host. Needed
# for "from zero" (no build/pkg). Cross builds get the cross mk fragment as
# mk.conf so packages build for the target with this tree's toolchain
# (tools/pkgsrc-cross.mk.conf, AGENTS.md "Third-party packages").
# pkgsrc's bootstrap: the prefix with bmake and the package tools for this
# host, in build/pkg. Needed for "from zero": `make release` on a fresh tree
# has no build/pkg, and every mode reads it -- cross for the tool bmake, chroot
# and native for pkg_info and pkg_delete, which tools/makronix-set.sh and the
# reinstall logic call by that path. The target system does not need it: it
# has /usr/bin/make and /usr/sbin/pkg_add in its base sets (base-util-bin,
# base-pkgutil-bin), so pkgsrc works there with no bootstrap of its own.
ensure_bootstrap()
{
[ $MODE = cross ] || return 0
[ -x "$BMAKE" ] && return 0
[ $MODE = cross ] || die "no $BMAKE (pkgsrc bootstrap, AGENTS.md)"
echo "=== pkgsrc bootstrap ($MODE)"
# The bootstrap copies the fragment it is given into mk.conf, and a later
# change of tools/pkgsrc-cross.mk.conf then never took effect (13.11.: NATIVE_CC
# for devel/gmp; t0053). What it is given is a fragment that only includes
# the real one, so mk.conf always reads the file of the tree and holds no
# copy of its values.
frag=$TOP/build/pkgsrc-mk-fragment.conf
printf '# written by tools/userland.sh (ensure_bootstrap): the settings are in the tree\n.include "%s/tools/pkgsrc-cross.mk.conf"\n' "$TOP" > "$frag"
(cd "$PKGSRC/bootstrap" && env MAKRONIX_TOP="$TOP" \
./bootstrap --unprivileged --prefer-native=yes --prefix "$TOP/build/pkg" \
--mk-fragment "$frag" \
--workdir "$TOP/build/pkgsrc-bootstrap")
[ -d "$PKGSRC/bootstrap" ] || die "no $PKGSRC/bootstrap (pkgsrc submodule, PINS)"
if [ $MODE = cross ]; then
# The bootstrap copies the fragment it is given into mk.conf, and a later
# change of tools/pkgsrc-cross.mk.conf then never took effect (13.11.: NATIVE_CC
# for devel/gmp; t0053). What it is given is a fragment that only includes
# the real one, so mk.conf always reads the file of the tree and holds no
# copy of its values.
frag=$TOP/build/pkgsrc-mk-fragment.conf
printf '# written by tools/userland.sh (ensure_bootstrap): the settings are in the tree\n.include "%s/tools/pkgsrc-cross.mk.conf"\n' "$TOP" > "$frag"
(cd "$PKGSRC/bootstrap" && env MAKRONIX_TOP="$TOP" \
./bootstrap --unprivileged --prefer-native=yes --prefix "$TOP/build/pkg" \
--mk-fragment "$frag" \
--workdir "$TOP/build/pkgsrc-bootstrap")
else
# native and chroot build for this host, so the bootstrap's own
# defaults are right; --unprivileged because the build runs as the
# user who owns the tree (chroot installs into the sysroot, not into
# the host's /usr/pkg).
(cd "$PKGSRC/bootstrap" && env MAKRONIX_TOP="$TOP" \
./bootstrap --unprivileged --prefer-native=yes --prefix "$TOP/build/pkg" \
--workdir "$TOP/build/pkgsrc-bootstrap")
fi
[ -x "$BMAKE" ] || die "bootstrap did not produce $BMAKE"
}