build: the host pkg's distfiles come from the distfiles set
host_pkg fetched pkg's distfiles again for every build of the host pkg, and GitHub turned one of its patches away four times in a row, which stopped the build. It now seeds them into the distfiles set (repair_distfiles, which skips what the set has) and extracts them from there. port_distfiles names a port's entries in the set, for both host_pkg and distfiles_in_set (whose awk now reads them from the environment). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f31a70765a
commit
fc2481ecac
3 changed files with 55 additions and 19 deletions
|
|
@ -238,8 +238,12 @@ release/vm.sh pull-out 14.3 26.1 # -> /scratch/mono-opnsense/out/26.1
|
|||
minute apart. The results are 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 before the ports step: its
|
||||
chroot builds pkg before anything else.
|
||||
- `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
|
||||
the step's output, `/var/tmp/gwbuild-ports.log`) is fetched this way
|
||||
and the ports step runs once more. It skips the packages it has
|
||||
|
|
|
|||
|
|
@ -129,6 +129,12 @@ host_pkg()
|
|||
_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
|
||||
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_PATCH}" \
|
||||
DISTDIR=/var/tmp/gwbuild-host/distfiles WRKDIRPREFIX=/var/tmp/gwbuild-host \
|
||||
clean all reinstall clean
|
||||
|
|
@ -243,13 +249,12 @@ fetch_failures()
|
|||
# rerun needs no download for it.
|
||||
repair_distfiles()
|
||||
{
|
||||
_set=$(ls "${SETS}"/distfiles-*.tar 2> /dev/null | head -1)
|
||||
[ -n "${_set}" ] || _set=${SETS}/distfiles-${VERSION}.tar
|
||||
_have=
|
||||
[ ! -f "${_set}" ] || _have=$(tar -tf "${_set}")
|
||||
_set=$(distfiles_set)
|
||||
_listing=
|
||||
[ ! -f "${_set}" ] || _listing=$(tar -tf "${_set}")
|
||||
_dir=$(mktemp -d /var/tmp/gwdistfiles.XXXXXX)
|
||||
for _rport; do
|
||||
if distfiles_in_set "${_rport}" "${_have}"; then
|
||||
if distfiles_in_set "${_rport}" "${_listing}"; then
|
||||
echo ">>> the distfiles set has the distfiles of ${_rport}"
|
||||
continue
|
||||
fi
|
||||
|
|
@ -264,14 +269,29 @@ repair_distfiles()
|
|||
rm -rf "${_dir}"
|
||||
}
|
||||
|
||||
# distfiles_in_set PORT LISTING: whether LISTING, the distfiles set's "tar -t", has
|
||||
# every distfile and patch file of PORT (distfiles/[DIST_SUBDIR/]NAME)
|
||||
distfiles_in_set()
|
||||
# distfiles_set: the distfiles set (tools names it after the version it was made for)
|
||||
distfiles_set()
|
||||
{
|
||||
_dset=$(ls "${SETS}"/distfiles-*.tar 2> /dev/null | head -1)
|
||||
echo "${_dset:-${SETS}/distfiles-${VERSION}.tar}"
|
||||
}
|
||||
|
||||
# port_distfiles PORT: the entries PORT's distfiles and patch files have in the
|
||||
# distfiles set, distfiles/[DIST_SUBDIR/]NAME, one per line
|
||||
port_distfiles()
|
||||
{
|
||||
_sub=$(make -C "/usr/ports/${1}" ARCH=aarch64 -V DIST_SUBDIR) || return 1
|
||||
_files=$(make -C "/usr/ports/${1}" ARCH=aarch64 -V ALLFILES) || return 1
|
||||
printf '%s\n' "${2}" | awk -v want="${_files}" -v pre="distfiles/${_sub:+${_sub}/}" '
|
||||
BEGIN { n = split(want, w, /[ \t]+/); for (i = 1; i <= n; i++) if (w[i] != "") need[pre w[i]] = 1 }
|
||||
echo "${_files}" | tr -s ' \t' '\n\n' | sed -e '/^$/d' -e "s|^|distfiles/${_sub:+${_sub}/}|"
|
||||
}
|
||||
|
||||
# distfiles_in_set PORT LISTING: whether LISTING, the distfiles set's "tar -t", has
|
||||
# every distfile and patch file of PORT
|
||||
distfiles_in_set()
|
||||
{
|
||||
_entries=$(port_distfiles "${1}") || return 1
|
||||
printf '%s\n' "${2}" | ENTRIES=${_entries} awk '
|
||||
BEGIN { n = split(ENVIRON["ENTRIES"], e, "\n"); for (i = 1; i <= n; i++) if (e[i] != "") need[e[i]] = 1 }
|
||||
{ delete need[$0] }
|
||||
END { for (f in need) exit 1 }'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -656,18 +656,30 @@ class DistfilesInSetTest(unittest.TestCase):
|
|||
"-C /usr/ports/cat/port ARCH=aarch64 -V ALLFILES") echo "${FAKE_FILES:-}";;
|
||||
*) exit 2;;
|
||||
esac""")
|
||||
self.func = subprocess.run(["sed", "-n", "/^distfiles_in_set()/,/^}/p", BUILD],
|
||||
capture_output=True, text=True, check=True).stdout
|
||||
self.assertIn("distfiles_in_set()", self.func)
|
||||
self.func = build_function("port_distfiles") + build_function("distfiles_in_set")
|
||||
|
||||
def sh(self, call, files, sub, *args):
|
||||
return subprocess.run(["sh", "-c", self.func + "\n" + call, "sh", *args],
|
||||
env={"PATH": f"{self.fx.bin}:/usr/bin:/bin", "FAKE_LOG": self.fx.log,
|
||||
"FAKE_FILES": files, "FAKE_SUB": sub},
|
||||
cwd=self.tmp, capture_output=True, text=True)
|
||||
|
||||
def in_set(self, listing, files, sub="", port="cat/port"):
|
||||
r = subprocess.run(["sh", "-c", self.func + '\ndistfiles_in_set "$1" "$2"', "sh", port, listing],
|
||||
env={"PATH": f"{self.fx.bin}:/usr/bin:/bin", "FAKE_LOG": self.fx.log,
|
||||
"FAKE_FILES": files, "FAKE_SUB": sub},
|
||||
cwd=self.tmp, capture_output=True, text=True)
|
||||
r = self.sh('distfiles_in_set "$1" "$2"', files, sub, port, listing)
|
||||
self.assertIn(r.returncode, (0, 1), r.stderr)
|
||||
return r.returncode == 0
|
||||
|
||||
def entries(self, files, sub="", port="cat/port"):
|
||||
r = self.sh('port_distfiles "$1"', files, sub, port)
|
||||
return r.returncode, r.stdout
|
||||
|
||||
def test_entries(self):
|
||||
self.assertEqual(self.entries(" a-1.0.tar.gz\tx.patch y.diff "),
|
||||
(0, "distfiles/a-1.0.tar.gz\ndistfiles/x.patch\ndistfiles/y.diff\n"))
|
||||
self.assertEqual(self.entries("perl-5.42.2.tar.xz", sub="perl"), (0, "distfiles/perl/perl-5.42.2.tar.xz\n"))
|
||||
self.assertEqual(self.entries(""), (0, ""))
|
||||
self.assertEqual(self.entries("a", port="cat/unknown")[0], 1)
|
||||
|
||||
LISTING = "distfiles/\ndistfiles/a-1.0.tar.gz\ndistfiles/x.patch\ndistfiles/perl/perl-5.42.2.tar.xz\n"
|
||||
|
||||
def test_all_present(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue