Remove all work directories after each port in tools' ports step
Tools ran make clean after each port, which cleans every dependency with the port's own flavor: a dependency with another flavor, or none, looks for the wrong work-<flavor> and keeps its work directory. After a failure tools removes the dependencies it built, and the stale directory claims they are installed, so every later port needing them failed at once (Rust: cmake not found; libxslt.so not found). build now has tools' ports.sh remove every work directory instead, and stops if ports.sh no longer has the two cleans it replaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
01e09eccd2
commit
1bba2be945
3 changed files with 94 additions and 7 deletions
21
RELEASE.md
21
RELEASE.md
|
|
@ -229,13 +229,20 @@ release/vm.sh pull-out 14.3 26.1 # -> /scratch/mono-opnsense/out/26.1
|
|||
build-only dependencies are not kept and get rebuilt. A port that
|
||||
fails is recorded and the step goes on with the others, then fails at the
|
||||
end. Tools stops at the first failure only when its step is given an
|
||||
argument, and `build` gives none. A failed dependency that has no
|
||||
flavors, of a port that has them, keeps its half-built work directory
|
||||
for the rest of the step: the ports tree's clean passes the flavor on,
|
||||
and the dependency looks for `work-<flavor>` instead. Tools has removed
|
||||
its build tools by then, so every later port that needs it fails at
|
||||
once (2026-11-20: Rust, "Couldn't find required command: cmake"). The
|
||||
next `build` retries them in a fresh stage.
|
||||
argument, and `build` gives none.
|
||||
- After each port, tools ran `make clean` to remove its work directories
|
||||
and its dependencies'. That clean runs each dependency's clean with the
|
||||
port's own flavor, so a dependency with another flavor, or with none,
|
||||
looks for the wrong `work-<flavor>` and keeps its work directory.
|
||||
After a failure, tools removes the dependencies it built. A stale
|
||||
directory then claims they are installed, so every later port that
|
||||
needs them fails at once. On 2026-11-20 that happened to Rust ("Couldn't
|
||||
find required command: cmake") and to libxslt ("libxslt.so - not
|
||||
found").
|
||||
- So `build` changes tools' `ports.sh` at checkout: after each port it
|
||||
removes every work directory (`rm -rf /usr/obj/usr/ports`) instead of
|
||||
cleaning. The build stops if tools' `ports.sh` no longer has the two
|
||||
cleans it replaces.
|
||||
5. The ports fetch their distfiles as they build. Some no longer download as
|
||||
recorded in the ports tree's distinfo, chiefly patches GitHub generates
|
||||
on the fly (`github.com/<owner>/<repo>/commit/<hash>.patch`): GitHub
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ checkout_all()
|
|||
echo " /usr/core: $(git -C /usr/core describe --tags) with $(echo "${PATCHES}" | wc -l | tr -d ' ') patches"
|
||||
cp "${DEPS}/config/GATEWAY.conf" /usr/tools/device/
|
||||
ports_make_conf "/usr/tools/config/${SERIES}/make.conf"
|
||||
ports_clean /usr/tools/build/ports.sh
|
||||
echo " /usr/deps: $(git -C "${DEPS}" describe --tags --always --dirty)"
|
||||
}
|
||||
|
||||
|
|
@ -130,6 +131,23 @@ ports_make_conf()
|
|||
printf 'lang_rust_VARS=\tMAKE_JOBS_NUMBER_LIMIT=%s\n' "${_jobs}" >> "${1}"
|
||||
}
|
||||
|
||||
# ports_clean FILE: tools' ports.sh (FILE) removes every work directory after each
|
||||
# port instead of running its make clean, which leaves some behind (RELEASE.md,
|
||||
# build step 4); /usr/obj is WRKDIRPREFIX in tools' make.conf. Checkout resets it.
|
||||
ports_clean()
|
||||
{
|
||||
# shellcheck disable=SC2016
|
||||
if ! OLD='make -C ${PORTSDIR}/\${PORT} clean \${MAKE_ARGS}' NEW='rm -rf /usr/obj${PORTSDIR}' awk '
|
||||
{ line = $0; sub(/^[ \t]+/, "", line) }
|
||||
line == ENVIRON["OLD"] { sub(/[^ \t].*/, ENVIRON["NEW"]); n++ }
|
||||
{ print }
|
||||
END { exit n != 2 }' "${1}" > "${1}.new"; then
|
||||
rm -f "${1}.new"
|
||||
die "${1}: not the two port cleans expected"
|
||||
fi
|
||||
mv "${1}.new" "${1}"
|
||||
}
|
||||
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -993,5 +993,67 @@ class PortsMakeConfTest(unittest.TestCase):
|
|||
self.assertEqual(self.appended(805306368), "lang_rust_VARS=\tMAKE_JOBS_NUMBER_LIMIT=1")
|
||||
|
||||
|
||||
class PortsCleanTest(unittest.TestCase):
|
||||
"""build.sh's ports_clean: tools' ports.sh removes all work directories after a port."""
|
||||
|
||||
# tools' ports.sh, the build loop's lines with "clean" in them (26.1.11)
|
||||
LOOP = (
|
||||
'echo "${PORTSLIST}\n'
|
||||
'clean.up.post.build" | while read PORT_ORIGIN; do\n'
|
||||
'\tif [ \\${PORT} = "clean.up.post.build" ]; then\n'
|
||||
'\t\tcontinue\n'
|
||||
'\tfi\n'
|
||||
'\tif ! make -C ${PORTSDIR}/\\${PORT} install \\\n'
|
||||
'\t USE_PACKAGE_DEPENDS=yes \\${MAKE_ARGS}; then\n'
|
||||
'\t\tmake -C ${PORTSDIR}/\\${PORT} clean \\${MAKE_ARGS}\n'
|
||||
'\t\tcontinue\n'
|
||||
'\tfi\n'
|
||||
'\tmake -C ${PORTSDIR}/\\${PORT} clean \\${MAKE_ARGS}\n'
|
||||
'done\n'
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.mkdtemp(prefix="gw-pclean-")
|
||||
self.addCleanup(shutil.rmtree, self.tmp)
|
||||
self.ports_sh = os.path.join(self.tmp, "ports.sh")
|
||||
self.func = build_function("die") + build_function("ports_clean")
|
||||
|
||||
def run_clean(self, text):
|
||||
with open(self.ports_sh, "w") as f:
|
||||
f.write(text)
|
||||
r = subprocess.run(["sh", "-c", self.func + '\nports_clean "$1"', "sh", self.ports_sh],
|
||||
capture_output=True, text=True)
|
||||
with open(self.ports_sh) as f:
|
||||
out = f.read()
|
||||
self.assertEqual(os.listdir(self.tmp), ["ports.sh"])
|
||||
return r, out
|
||||
|
||||
def test_both_cleans_replaced(self):
|
||||
r, out = self.run_clean(self.LOOP)
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
expected = self.LOOP.replace("\t\tmake -C ${PORTSDIR}/\\${PORT} clean \\${MAKE_ARGS}\n",
|
||||
"\t\trm -rf /usr/obj${PORTSDIR}\n")
|
||||
expected = expected.replace("\tmake -C ${PORTSDIR}/\\${PORT} clean \\${MAKE_ARGS}\n",
|
||||
"\trm -rf /usr/obj${PORTSDIR}\n")
|
||||
self.assertEqual(out, expected)
|
||||
self.assertEqual(out.count("rm -rf /usr/obj${PORTSDIR}"), 2)
|
||||
self.assertNotIn(" clean ", out)
|
||||
self.assertIn('clean.up.post.build" ]', out)
|
||||
|
||||
def test_changed_tools_refused(self):
|
||||
# one clean only, already replaced, or a clean that does more
|
||||
for text in (self.LOOP.replace("\tmake -C ${PORTSDIR}/\\${PORT} clean \\${MAKE_ARGS}\ndone",
|
||||
"done"),
|
||||
self.LOOP.replace("make -C ${PORTSDIR}/\\${PORT} clean \\${MAKE_ARGS}",
|
||||
"rm -rf /usr/obj${PORTSDIR}"),
|
||||
self.LOOP.replace("clean \\${MAKE_ARGS}\n", "clean \\${MAKE_ARGS} || true\n"),
|
||||
""):
|
||||
with self.subTest(text=text[-80:]):
|
||||
r, out = self.run_clean(text)
|
||||
self.assertEqual(r.returncode, 1)
|
||||
self.assertIn("not the two port cleans expected", r.stderr)
|
||||
self.assertEqual(out, text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue