build.sh: build the host pkg from opnsense/pkg, as tools checks

Since 26.7 the ports tree builds pkg from opnsense/pkg (2.8.4) and tools
compares the host's pkg with it; ports-mgmt/pkg is FreeBSD's 2.9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jeremy Karst 2026-11-23 19:38:52 -05:00
parent 87893ded3e
commit 8716b582b3
2 changed files with 15 additions and 12 deletions

View file

@ -265,7 +265,7 @@ release/vm.sh pull-out 15.1 26.7 # -> /scratch/mono-opnsense/out/26.7
too: Codeberg now compresses them with GNU gzip instead of git's own, and
the same tar comes out smaller. FreeBSD's distfile cache does not help
here. It keeps the originals only of FreeBSD's own ports, so it has
nothing for OPNsense's (e.g. the patches of `ports-mgmt/pkg`). For
nothing for OPNsense's (e.g. the patches of `opnsense/pkg`). For
`sysutils/sysinfo` it served the new archive as well (2026-11-22).
- Such ports are fetched on the build host with
`release/fetch-distfile.sh`. For a GitHub patch, it shortens the
@ -278,10 +278,11 @@ release/vm.sh pull-out 15.1 26.7 # -> /scratch/mono-opnsense/out/26.7
appended to the distfiles set, which
tools extracts into every ports step's chroot. A port whose distfiles
the set has already is skipped, so a rerun downloads nothing for it.
- `ports-mgmt/pkg` is fetched this way first: the ports step's chroot
builds pkg before anything else, and tools needs the same pkg version
on the build host (`pkg -v`), so `build` builds it there too when the
version differs (`vm.sh setup` installs FreeBSD's). Both take its
- `opnsense/pkg` (tools' `PKG_ORIGIN`, not `ports-mgmt/pkg`) is fetched
this way first: the ports step's chroot builds pkg before anything
else, and tools needs the same pkg version on the build host
(`pkg -v`), so `build` builds it there too when the version differs
(`vm.sh setup` installs FreeBSD's). Both take its
distfiles from the set, not from GitHub, which turned its patches
away for minutes at a time on 2026-11-20.
- Any other port whose distfiles fail to fetch ("Couldn't fetch it" in

View file

@ -150,23 +150,25 @@ ports_clean()
mv "${1}.new" "${1}"
}
# tools insists on a host pkg of the same major.minor as the ports tree's. Its
# tools insists on a host pkg of the same major.minor as the ports tree's, which
# its chroots build from PKG_PORT (tools' PKG_ORIGIN; not ports-mgmt/pkg). 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.
PKG_PORT=opnsense/pkg
host_pkg()
{
_want=$(make -C /usr/ports/ports-mgmt/pkg -v PORTVERSION | cut -d. -f1-2)
_want=$(make -C "/usr/ports/${PKG_PORT}" -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})"
# its distfiles come from the distfiles set, as the ports step's do: GitHub
# turns away its patches for minutes at a time
repair_distfiles ports-mgmt/pkg
repair_distfiles "${PKG_PORT}"
mkdir -p /var/tmp/gwbuild-host
# shellcheck disable=SC2046
tar -xf "$(distfiles_set)" -C /var/tmp/gwbuild-host $(port_distfiles ports-mgmt/pkg)
make -C /usr/ports/ports-mgmt/pkg BATCH=yes "${FETCH_REPAIR}" \
tar -xf "$(distfiles_set)" -C /var/tmp/gwbuild-host $(port_distfiles "${PKG_PORT}")
make -C "/usr/ports/${PKG_PORT}" BATCH=yes "${FETCH_REPAIR}" \
DISTDIR=/var/tmp/gwbuild-host/distfiles WRKDIRPREFIX=/var/tmp/gwbuild-host \
clean all reinstall clean
rm -rf /var/tmp/gwbuild-host
@ -196,8 +198,8 @@ build_ports()
"${SETS}/packages-${VERSION}-aarch64.tar" \
"${SERIES} ${VERSION} $(git -C /usr/ports rev-parse HEAD)"
# the ports step's chroot builds pkg before anything else
step "distfiles of ports-mgmt/pkg"
repair_distfiles ports-mgmt/pkg
step "distfiles of ${PKG_PORT}"
repair_distfiles "${PKG_PORT}"
step "ports"
ports_run ports
}