Repository navigation
tools/kernel-pr-check: a --build one level above the kernel tree no longer deletes it - #287
Conversation
…deletes The builds delete and rewrite OUT/src, OUT/src-base, OUT/build and OUT/build-base, but --build was only refused inside the kernel tree. An OUT one level above a tree named src (-C /x/src --build /x) passed, and the builds' rm -rf of OUT/src deleted the checkout the tool promises never to touch. An OUT/src that holds a worktree's git directory went the same way, and a symlink at OUT/build into the tree had make build in the tree and the device-tree step delete its arch/arm64/boot/dts. Resolve every directory the builds delete or rewrite, symlinks included, and refuse an OUT where one of them is the tree or its git directory, holds it or lies inside it. The tree's own path is now resolved physically too, so a symlinked -C is compared by what it points at. An OUT beside the tree, or holding a tree under another name, still builds. The guard and the deletes share one list of what is deleted, so a new delete can't slip past it. The header says where the builds go, and --help now prints all of it (it stopped a line short before). tests/kernel-pr-check covers these layouts, and a symlink deeper in OUT/build, with an rm that records what it is asked to delete under the fixtures and deletes none of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks: a guard that resolves every path the build deletes, symlinks included, and that shares one list with the deletes is the right shape. I checked it three ways:
One thing to know: #288 also edits the header and the Minor, no change needed: inside a container where git refuses the tree as "dubious ownership", the git-directory half of the check finds nothing and quietly skips. The tree half still applies, and our documented container command sets |
|
Thanks again. Since my last note, #310 has landed on
|
…lers; --help prints the header, 3,48p)
…tions, --help 3,49p; tests: main's --no-checkpatch and trailer tests before the checker tests)
… one line longer here, 3,49p)
|
Note 🤖 Opus 5.5 replying on behalf of Victor. Thanks for resolving the conflicts here. As you suggested, #529 works the |
--help printed a hard-coded line range of the header comment, so every change to the header had to move the range by hand: #287 and #288 each added a header line and both set it to '3,37p', and with #310 on main the merged ranges became '3,46p' and '3,47p'. Whichever change missed the update cut the header's last line. On #287 the maintainer suggested working the range out from the file instead. --help now prints from line 3 to the first line that isn't a comment, with the awk line tools/nv-backup and tools/phone-provision already use (without their "# " stripping, so the output keeps its current form). On today's header its output is byte for byte what '3,49p' printed. tests/kernel-pr-check gains a check that runs --help on a copy of the tool with one more header line, and compares it with the header up to the line before `set -uo pipefail`. It failed with the old range (the last header line was missing) and passes with this change. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fourteen tools printed --help as a hard-coded line range of their header comment (sed -n '3,NNp'), the pattern that cut kernel-pr-check's header after #287, #288 and #310 each edited it. On #287 the maintainer suggested working the range out from the file; #529 did that for kernel-pr-check alone. This moves all of them onto one helper, tools/lib/usage.sh: usage_from_header prints the comment lines from line 3 up to the first line that isn't a comment (#529's awk line), with "# " taken off or, with --raw, kept. Tools load it only for --help, so the copies the tests make of a tool, with only the lib files it needs, still run. kernel-pr-check moves onto it too. Ten tools print byte for byte what they printed before (cmp of stdout, stderr and exit status, and of phone-demo's and phone-mirror's error usage). Five ranges were already wrong, and print the header now: fetch-toolchain and build-flame-probe printed two lines of code after it; install-phone cut --reinstall, --unsigned and its last paragraph, build-rootfs cut --channel, and release cut its check-bundle stage. build-packages, phone-demo and release print only the start of a longer header, so the helper takes a paragraph count (a bare "#" line ends one) and their output stays what the range meant. install-phone keeps the awk line inline, as nv-backup and phone-provision already do: make-bundle ships these three alone, without tools/lib (review lesson L-497). tests/tools-help fails if any tool still hard-codes the range, and runs --help on every tool that prints its header (the helper's users and the three inline ones): it must print the header, or whole paragraphs from its start, and no code, and a copy whose header has grown by a line must print that line too. It replaces #529's single-tool check in tests/kernel-pr-check. On the base it fails on the range check, and the per-tool check fails for 13 of the 15 tools. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Derek Ross <derekross@gmail.com>
tests/tools-help refuses a hard-coded line range for a tool's help (derekross#287): this one still had sed -n '3,12p', the only one left, and the test failed on it. Use usage_from_header like every other tool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onger deletes it (derekross#287) …deletes The builds delete and rewrite OUT/src, OUT/src-base, OUT/build and OUT/build-base, but --build was only refused inside the kernel tree. An OUT one level above a tree named src (-C /x/src --build /x) passed, and the builds' rm -rf of OUT/src deleted the checkout the tool promises never to touch. An OUT/src that holds a worktree's git directory went the same way, and a symlink at OUT/build into the tree had make build in the tree and the device-tree step delete its arch/arm64/boot/dts. Resolve every directory the builds delete or rewrite, symlinks included, and refuse an OUT where one of them is the tree or its git directory, holds it or lies inside it. The tree's own path is now resolved physically too, so a symlinked -C is compared by what it points at. An OUT beside the tree, or holding a tree under another name, still builds. The guard and the deletes share one list of what is deleted, so a new delete can't slip past it. The header says where the builds go, and --help now prints all of it (it stopped a line short before). tests/kernel-pr-check covers these layouts, and a symlink deeper in OUT/build, with an rm that records what it is asked to delete under the fixtures and deletes none of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ross#529) --help printed a hard-coded line range of the header comment, so every change to the header had to move the range by hand: derekross#287 and derekross#288 each added a header line and both set it to '3,37p', and with derekross#310 on main the merged ranges became '3,46p' and '3,47p'. Whichever change missed the update cut the header's last line. On derekross#287 the maintainer suggested working the range out from the file instead. --help now prints from line 3 to the first line that isn't a comment, with the awk line tools/nv-backup and tools/phone-provision already use (without their "# " stripping, so the output keeps its current form). On today's header its output is byte for byte what '3,49p' printed. tests/kernel-pr-check gains a check that runs --help on a copy of the tool with one more header line, and compares it with the header up to the line before `set -uo pipefail`. It failed with the old range (the last header line was missing) and passes with this change. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ekross#559) Fourteen tools printed --help as a hard-coded line range of their header comment (sed -n '3,NNp'), the pattern that cut kernel-pr-check's header after derekross#287, derekross#288 and derekross#310 each edited it. On derekross#287 the maintainer suggested working the range out from the file; derekross#529 did that for kernel-pr-check alone. This moves all of them onto one helper, tools/lib/usage.sh: usage_from_header prints the comment lines from line 3 up to the first line that isn't a comment (derekross#529's awk line), with "# " taken off or, with --raw, kept. Tools load it only for --help, so the copies the tests make of a tool, with only the lib files it needs, still run. kernel-pr-check moves onto it too. Ten tools print byte for byte what they printed before (cmp of stdout, stderr and exit status, and of phone-demo's and phone-mirror's error usage). Five ranges were already wrong, and print the header now: fetch-toolchain and build-flame-probe printed two lines of code after it; install-phone cut --reinstall, --unsigned and its last paragraph, build-rootfs cut --channel, and release cut its check-bundle stage. build-packages, phone-demo and release print only the start of a longer header, so the helper takes a paragraph count (a bare "#" line ends one) and their output stays what the range meant. install-phone keeps the awk line inline, as nv-backup and phone-provision already do: make-bundle ships these three alone, without tools/lib (review lesson L-497). tests/tools-help fails if any tool still hard-codes the range, and runs --help on every tool that prints its header (the helper's users and the three inline ones): it must print the header, or whole paragraphs from its start, and no code, and a copy whose header has grown by a line must print that line too. It replaces derekross#529's single-tool check in tests/kernel-pr-check. On the base it fails on the range check, and the per-tool check fails for 13 of the 15 tools. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Derek Ross <derekross@gmail.com>
What and why
tools/kernel-pr-check --build OUTclearsOUT/srcandOUT/src-basebefore it exports the commits it builds. The only check was that OUT is not inside the kernel tree. So-C /x/src --build /xpassed, and the build step'srm -rf OUT/srcdeleted the checkout the tool promises never to touch. AnOUT/srcthat holds a worktree's git directory went the same way, and a symlink atOUT/buildinto the tree had make build in the tree and the device-tree step delete itsarch/arm64/boot/dts.The tool now resolves every path the builds delete or rewrite, symlinks included:
OUT/src,OUT/src-base,OUT/build,OUT/build-baseand the stale outputs it removes inside the build directories. It refuses (exit 2) an OUT where any of them is the tree or its git directory, holds it or lies inside it. The guard and the deletes share one list, so a new delete can't slip past the check. The tree's path is resolved physically too. An OUT beside the tree, or one that holds the tree under another name (--build ~/omamobile-kernelwith-C ~/omamobile-kernel/linux), still builds as before.Two small cleanups come with it: the header now says where the builds go, and
--helpprints the whole header (it stopped a line short).tests/kernel-pr-checkcovers four layouts: OUT holding a tree namedsrc,OUT/buildlinking to the tree,OUT/build/archlinking into it, andOUT/srcholding a worktree's git directory. The tool runs with stub clang and ld.lld, so it would reach the builds. Itsrmis a stand-in that records anything under the fixtures it is asked to delete and deletes none of it, so a regression reports the deletion instead of making it. Run against the old tool, the test fails withnot ok - OUT holds a tree named src: deleted …/collide/src, and the fixture tree is still there.Not in this change: the tool still clears whatever sits at
OUT/srcandOUT/src-basewhen that is not the kernel tree. That is what--buildhas always done with its output directory, and an ownership marker would change behaviour for existing output directories, CI's included. It also doesn't police symlinks a user puts deeper insideOUT/build, beyond the paths it deletes.Device and build
tools/kernel-pr-checkruns on the laptop and in CI, never on a phone; CONTRIBUTING §6.5)uname -r): n/aChecks (no phone needed)
tools/pr-checkpasses (against the branch point,af8c0f0)tests/allpassestests/packagespasses (or the packages I touched: ...): no package touchedversionbumped, and the new version is in the commit subject: no package changedCo-Authored-By:orAssisted-by:trailer, never aSigned-off-by:On the phone
--build. The tests use a stand-in tree, stub compilers and a recordingrm, by design, so nothing real is deleted.userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)Found by Terra 6.1 Max and Sol 6.1 xhigh in a code audit of the repository.
Generated with Claude Opus 5.5 and GPT-6.1 Sol in T3 Code Nightly