build.sh: build the host pkg outside the ports tree

Its distfiles stayed in /usr/ports/distfiles, the lower layer of the
unionfs mount tools puts in every chroot, and the ports step's
rm -rf of distfiles/ there failed with "Operation not supported".
Fetch and build it under /var/tmp instead and remove that afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jeremy Karst 2026-11-18 15:30:51 -05:00
parent 5665956249
commit c40ca350b6

View file

@ -117,14 +117,20 @@ checkout_all()
echo " /usr/deps: $(git -C "${DEPS}" describe --tags --always --dirty)"
}
# tools insists on a host pkg of the same major.minor as the ports tree's
# tools insists on a host pkg of the same major.minor as the ports tree's. Its
# distfiles and work directory stay out of /usr/ports: tools mounts the tree
# into its chroots with unionfs and replaces distfiles/ there, which fails on
# files in the lower layer.
host_pkg()
{
_want=$(make -C /usr/ports/ports-mgmt/pkg -v PORTVERSION | cut -d. -f1-2)
_have=$(pkg -v | cut -d. -f1-2)
if [ "${_want}" != "${_have}" ]; then
step "building host pkg ${_want} from the ports tree (have ${_have})"
make -C /usr/ports/ports-mgmt/pkg BATCH=yes "${FETCH_PATCH}" clean all reinstall clean
make -C /usr/ports/ports-mgmt/pkg BATCH=yes "${FETCH_PATCH}" \
DISTDIR=/var/tmp/gwbuild-host/distfiles WRKDIRPREFIX=/var/tmp/gwbuild-host \
clean all reinstall clean
rm -rf /var/tmp/gwbuild-host
fi
}