pkgchroot: force builds the package it was named, not its category

sandbox_run() assigned c=$1 and p=${1%/*} without local, so the second
sandbox_run in force's loop saw p=wm instead of p=wm/mcde: `pkgchroot force
wm/mcde` cleaned mcde and then ran `make -C /mnt/pkgsrc/wm reinstall`, a bulk
reinstall of every window manager in the category (measured 2026-11-22 on the
MacBook: after "Cleaning for mcde-0.1.0" it began to fetch 2bwm and afterstep).

The variables are prefixed (sr_path, sr_dir) so they cannot collide with a
caller's loop variable.

Measured: sh -n tools/pkgchroot.sh rc=0.
This commit is contained in:
lotherk committed 2026-11-22 11:29:52 +01:00
1 parent 9f471c2847
commit 71ccd4b0b9
1 file changed
+8 -4
+8 -4
View File
@@ -79,9 +79,13 @@ sandbox_mount()
# into /usr/pkg -- which, inside the chroot, is the sysroot's /usr/pkg.
sandbox_run()
{
c=$1
p=${1%/*}
mkdir -p "$SB/work/$p"
# The names are prefixed on purpose: a plain `p=$1` here overwrote the
# caller's loop variable, so `force wm/mcde` ran its second sandbox_run
# with p=wm and reinstalled the whole category instead of the package
# (measured 2026-11-22, the MacBook began to build 2bwm and afterstep).
sr_path=$1
sr_dir=${1%/*}
mkdir -p "$SB/work/$sr_dir"
# docbook's stylesheets are local: without the catalog libxslt resolves the
# URL in the stylesheet PI and stops with "failed to load external entity
# http://docbook.sourceforge.net/..." when the build host has no route to it
@@ -93,7 +97,7 @@ sandbox_run()
HOME=/mnt/work \
TMPDIR=/mnt/tmp \
XML_CATALOG_FILES=$catalog \
/usr/bin/make -C "/mnt/pkgsrc/$c" \
/usr/bin/make -C "/mnt/pkgsrc/$sr_path" \
WRKOBJDIR=/mnt/work \
PACKAGES=/mnt/packages \
DISTDIR=/mnt/distfiles \