Skip to content

tools/kernel-pr-check: work the --help range out from the file - #529

Merged
derekross merged 1 commit into
derekross:mainfrom
only21mil:build/kernel-pr-check-help-range
Nov 9, 2026
Merged

derekross merged 1 commit into
derekross:mainfrom
only21mil:build/kernel-pr-check-help-range

Conversation

@only21mil

@only21mil only21mil commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What and why

tools/kernel-pr-check --help printed a hard-coded range of its header comment (sed -n '3,NNp'), so every header edit had to move the range by hand. #287 and #288 each added a header line, and with #310 the range became 3,46p/3,47p and then 3,49p. Each time, whichever change missed the update cut the header's last line. On #287 the maintainer suggested working the range out from the file.

--help now prints from line 3 to the first line that isn't a comment. It's 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 the output is byte for byte what 3,49p printed (cmp before/after: identical).

tests/kernel-pr-check gains a check: on a copy of the tool with one more header line, --help must equal the header up to the line before set -uo pipefail. It fails with the old range (the last header line is missing) and passes with this change.

Other tools with the same hard-coded pattern, not changed here: fetch-toolchain, build-flame-probe, release-upload, install-phone, build-rootfs, build-packages, fetch-published, make-bundle, release, phone-smoke, publish-kernel, repo-publish, and usage() in phone-demo and phone-mirror. If you'd like, a shared helper in tools/lib could replace them in a separate PR.

Device and build

  • Phone: none: laptop tool only
  • Kernel release (uname -r): n/a
  • Packages changed, with versions: none

Checks (no phone needed)

  • tools/pr-check origin/main passes
  • tests/all passes
  • tests/packages passes (or the packages I touched: none)
  • Each changed package has its version bumped, and the new version is in the commit subject (no package changed)
  • Commits have area prefixes and bodies that say why; any AI help is a Co-Authored-By: or Assisted-by: trailer, never a Signed-off-by:

On the phone

  • I ran this on my own phone, booted into this build: n/a, laptop tool only
  • Runbook steps passed (plan, step, result): n/a
  • What I did not test: on a phone (nothing here runs on one); the other tools listed above
  • Nothing in this change writes outside slot B and userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)
tools/phone-smoke report

Not applicable: a laptop-tool change (CONTRIBUTING.md §6.5).

Generated with Claude Opus 5.5 in T3 Code Nightly

--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>
@derekross

Copy link
Copy Markdown
Owner

Thank you, Victor. Small and right: I checked that the new line prints exactly what 3,49p printed on today's header, and your test will catch the next header edit, which is the point. Merging. A shared helper for the other tools would be welcome as its own PR whenever you like.

@derekross
derekross merged commit 760ed3d into derekross:main Nov 9, 2026
2 checks passed
derekross added a commit that referenced this pull request Nov 9, 2026
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>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…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>
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants