pkgchroot: throw away a .destdir that no finished install left

pkgsrc removes DESTDIR on package-clean only; an install that died before
writing .install_done leaves the staging tree in place, and the next install
then fails on a file that is already there.  pkgconf's
'ln -s pkgconf .destdir/usr/pkg/bin/pkg-config: File exists' stopped
x11/mcde-motif and wm/mcde on the MacBook.

Test: with .build_done and no .install_done the .destdir is removed; with
.install_done it stays.  Both cases checked in a scratch tree.
This commit is contained in:
lotherk committed 2026-11-23 16:47:22 +00:00
1 parent f84bc2dd66
commit 7388548136
1 file changed
+11
+11
View File
@@ -161,6 +161,17 @@ sandbox_run()
# (measured 2026-11-21: xmlto, a dependency of wm/mcde, on the MacBook).
catalog=/usr/pkg/share/xsl/docbook/catalog.xml
[ -f "$D$catalog" ] || catalog=
# The staging tree of a run that died between install and package: pkgsrc
# removes .destdir on `package-clean' only, never before an `install', so
# a stale tree makes the next install fail on a file that is already
# there -- pkgconf's `ln -s pkgconf .../bin/pkg-config: File exists'
# stopped x11/mcde-motif and wm/mcde (measured 2026-11-23 on the MacBook).
# The cookie is what says whether that run finished.
sw=$(ls -d "$SB/work/$sr_path"/work.* 2>/dev/null | head -1)
[ -n "$sw" ] || sw=$SB/work/$sr_path/work
if [ -d "$sw/.destdir" ] && [ ! -f "$sw/.install_done" ]; then
rm -rf "$sw/.destdir"
fi
chroot "$D" /usr/bin/env -i \
PATH=/usr/sbin:/usr/bin:/sbin:/bin \
HOME=/mnt/work \