From a537a3b57d866da1c43ec33efe43a2b24dd1920a Mon Sep 17 00:00:00 2001 From: lotherk Date: Sun, 22 Nov 2026 21:56:11 +0000 Subject: [PATCH] pkgchroot: force deinstalls, and `mount' keeps its mounts Two bugs, both measured on 2026-11-22 while rebuilding wm/mcde: 1. `force' ran `clean' + `reinstall'. reinstall is `install-clean install' (mk/install/deinstall.mk:50) and install-clean only removes state files, it does not deinstall. So pkg_add saw the package already recorded, refused with "package `mcde-0.1.0' already recorded as installed" and returned 0 -- the sysroot kept the pre-fix binaries: dtphoto stayed at 15:15 while the binary package carried the 21:28 build. pkgsrc documents the way itself in mk/install/install.mk:225: `make deinstall reinstall'. `deinstall || true' because the package may not be installed yet. 2. sandbox_mount set `trap umount_all EXIT INT TERM HUP', so the `mount' subcommand unmounted everything again before the caller could use it, and still printed "pkgchroot: mounted". The trap belongs to the modes that mount and work: build and force. Test: `pkgchroot.sh mount' leaves 5 mounts standing and /mnt/pkgsrc/wm/mcde is visible in the chroot; `pkgchroot.sh umount' brings it back to 0. `deinstall' in the chroot removed /usr/pkg/dt/bin/dtphoto and deregistered mcde-0.1.0. --- tools/pkgchroot.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/pkgchroot.sh b/tools/pkgchroot.sh index 55ae3c2fc0..3a7cffd5e2 100755 --- a/tools/pkgchroot.sh +++ b/tools/pkgchroot.sh @@ -64,7 +64,6 @@ sandbox_mount() mount -t null "$TOP/pkgsrc" "$MNT/pkgsrc" mount | grep -q " on $MNT/distfiles " || mount -t null "${DISTFILES:-$TOP/distfiles}" "$MNT/distfiles" - trap 'umount_all' EXIT INT TERM HUP mount | grep -q " on $MNT/work " || mount -t null "$SB/work" "$MNT/work" # the binary packages go where the cross build puts them, so tools/make_repo @@ -144,6 +143,7 @@ mount) sandbox_mount; echo "pkgchroot: mounted" ;; build) shift sandbox_mount + trap 'umount_all' EXIT INT TERM HUP for p in "$@"; do echo "=== pkgchroot: $p" sandbox_run "$p" install @@ -158,9 +158,11 @@ force) # Settings change went into no build at all) shift sandbox_mount + trap 'umount_all' EXIT INT TERM HUP for p in "$@"; do echo "=== pkgchroot (force): $p" sandbox_run "$p" clean + sandbox_run "$p" deinstall || true sandbox_run "$p" reinstall done sandbox_clean