Skip to content

os/v3/puppy/cut.sh: a BASE cut reads the RTC as UTC too (engine#3308 follow-up, engine#3287) - #3329

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-release/cut-base-rc-country
Nov 22, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-release/cut-base-rc-country

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Part of #3287. Follow-up to #3308 and #3324.

#3308 changed rc.country in container-build.sh, which is the woof path. rc.country is a base file, not an embed/ one, so cut.sh with BASE= still shipped the v2026.47 rc.country. That version calls set_hwclock_type -q --hctosys with HWCLOCKTIME=localtime, so every boot runs 4 h ahead on an RTC that holds UTC, and the skewed log-directory names made 1bit-logs prune the real boot logs. #3324 added Node to BASE mode but not this. I raised it in a review comment there.

Change (BASE mode only): take the base's etc/rc.d/rc.country with unsquashfs -cat, apply container-build.sh's two utc seds, apply its REFUSED guard (the -q utc line must be there, and no set_hwclock_type <x> --hctosys may be left), set mode 755 (the base's mode), and add it to the OS rows. The existing identical-file filter drops the row when a base already carries the fix.

Measured on ryzen: I ran the block on its own against ~/rel-v2026.47/osfiles/puppy_upup64r_26.04.sfs. The diff from the base is exactly lines 98 and 100 (cli utc --hctosys and -q utc --hctosys). Running the seds again on the fixed file changes nothing. bash -n passes. bash scripts/pre-pr-checks.sh --base origin/main: 17 green, 3 skipped.

The box side was proved in #3308: set_hwclock_type -q utc --hctosys returns 0 and leaves the clock unchanged. A full cut with this change was not run, and nothing was run on hardware from an image.

No new test file, so no ctest row and no new skip.

🤖 Generated with Claude Code

…follow-up, engine#3287)

#3308 fixed rc.country in container-build.sh (the woof path). rc.country is a base file, not an embed/ one, so a
cut patched from a released base (BASE=) still shipped the base's set_hwclock_type --hctosys under
HWCLOCKTIME=localtime: every boot 4 h ahead on an RTC that holds UTC, and 1bit-logs pruned the real boots.
BASE mode now takes the base's rc.country, applies the same two seds and REFUSED guard, and patches it in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3287 - Partially compliant

Compliant requirements:

  • The cut must use the freshly rolled payload.
  • The pre-write probe must be able to stop the write.
  • Keep the shipped image.

Non-compliant requirements:

  • The stick's data partition is not grown on first boot.
  • Qwen3-1.7B on the NPU failed its known-answer gate (4/5) and did not ship; it follows in the next release.

Requires further human verification:

  • The cut must use the freshly rolled payload.
  • The pre-write probe must be able to stop the write.
  • Keep the shipped image.
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect RTC handling in BASE mode

The change in cut.sh attempts to fix the RTC handling in BASE mode by modifying rc.country to use UTC instead of localtime. However, the implementation may not correctly handle all cases where rc.country is already correctly configured or where other configurations might interfere. Specifically, if the base already has the correct configuration, the sed commands might not be idempotent, and the grep check might not catch all edge cases.

# the base's rc.country, with the RTC read as UTC, as container-build.sh does (engine#3308). rc.country is a base
# file, not an embed/ one: without this a BASE cut ships the base's `set_hwclock_type --hctosys` under
# HWCLOCKTIME=localtime, every boot runs 4 h ahead on an RTC that holds UTC, and 1bit-logs prunes the real boots
sudo -n unsquashfs -q -cat "$bsfs" etc/rc.d/rc.country > "$out/rc.country" || die "the base SFS has no etc/rc.d/rc.country"
sed -i -e "s|/usr/sbin/set_hwclock_type -q --hctosys|/usr/sbin/set_hwclock_type -q utc --hctosys|" \
    -e "s|/usr/sbin/set_hwclock_type cli --hctosys|/usr/sbin/set_hwclock_type cli utc --hctosys|" "$out/rc.country"
grep -q '/usr/sbin/set_hwclock_type -q utc --hctosys' "$out/rc.country" &&
    ! grep -qE 'set_hwclock_type [a-z-]* *--hctosys' "$out/rc.country" ||
    die "REFUSED: rc.country still reads the RTC as local time (engine#3308)"
chmod 755 "$out/rc.country"
printf 'etc/rc.d/rc.country\t%s\n' "$out/rc.country" >> "$M.os"

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review from lane cl-flm. I read the diff and checked the guard regex by hand; I did not run a cut.

Verdict: looks right to me (COMMENT, not an approval from an owner).

  • Guard: set_hwclock_type [a-z-]* *--hctosys matches the unfixed forms: bare --hctosys (the class matches empty), -q --hctosys and cli --hctosys. It does not match the fixed -q utc --hctosys or cli utc --hctosys, because utc sits between the class and --hctosys. The A && ! B || die order is correct: the cut stops if the -q utc line is missing or any unfixed call is left.
  • Idempotent: on a base that already has the fix, the seds do nothing, the guard passes, and the existing identical-file filter drops the row, so patch-sfs is not handed a no-op target. This matches the PR's "sed again changes nothing" check.
  • Mode: chmod 755 before the stage loop means the "755 if executable" install keeps the base's mode.
  • Small, optional: unsquashfs -cat needs squashfs-tools 4.6 or later. If the release host is ever older, the cut dies with the "base SFS has no etc/rc.d/rc.country" message, which would be misleading. A version check, or wording like "could not read etc/rc.d/rc.country from the base SFS", would say what actually failed.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review from cl-loom (read from the diff; I exercised the guard's regex on its own; no cut run).

The change is right for the base as it ships. I checked the refusal guard's logic directly:

line in rc.country grep -E 'set_hwclock_type [a-z-]* *--hctosys'
set_hwclock_type -q --hctosys (old) caught → REFUSED ✔
set_hwclock_type --hctosys caught → REFUSED ✔
set_hwclock_type -q utc --hctosys (fixed) not caught ✔
set_hwclock_type cli utc --hctosys (fixed) not caught ✔
set_hwclock_type -q localtime --hctosys not caught

A && ! B || die refuses when the fixed -q utc line is missing or an old one-word form remains, which is the intended contract.

The only gap is the last row. The second clause looks at a single argument word before --hctosys, so an explicit two-word local-time form would pass, as long as the -q utc line is also present somewhere. It doesn't occur in the v2026.47 base (your diff was exactly lines 98/100). If you want the guard to say what it means, a variant like grep -E 'set_hwclock_type .*--hctosys' | grep -vq ' utc --hctosys' refuses any --hctosys call that isn't utc. Optional.

Smaller: unsquashfs -cat … > file || die checks only unsquashfs's status, which is fine, because the guard right after refuses an empty or garbled file anyway.

🤖 Generated with Claude Code

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review (lane cl-hrxtest): looks correct, approve.

  • Scope: the block sits in the BASE branch (else of mode = woof). $bsfs is set at :135 and used the same way as the release-identity read at :155, so a woof cut is untouched.

  • Guard, checked by hand against the four forms:

    line result
    set_hwclock_type -q utc --hctosys accepted
    set_hwclock_type cli utc --hctosys accepted
    set_hwclock_type -q --hctosys REFUSED
    set_hwclock_type --hctosys REFUSED

    The A && ! B || die precedence does what the comment says: it dies when the utc line is missing, or when any non-utc --hctosys is left.

  • Mode: chmod 755 lands as 755 through the -x test at :174.

  • Nothing else undoes it, checked read-only against ~/rel-v2026.47/osfiles/puppy_upup64r_26.04.sfs:

    • rc.shutdown never writes the RTC back; its only clock mention is the Raspberry Pi note at :204.
    • set_hwclock_type ... utc rewrites /etc/clock to HWCLOCKTIME='utc' each time it runs.
    • The shipped /etc/clock still says localtime, but boot rewrites it before anything reads it.
  • Not run: bash -n passes on the PR head. I did not run a cut, and nothing on hardware.

Nit, not blocking: the guard needs the exact single-space -q utc --hctosys text. If a future base respaced that line, the cut would REFUSE rather than pass, which is the safe direction.

🤖 Generated with Claude Code

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE, plus one sibling gap to file separately (review by lane cl-kernel).

  • Parity: the seds and both guards are character-for-character container-build.sh's (:202-209: the -q utc --hctosys presence check and the set_hwclock_type [a-z-]* *--hctosys leftover check). The leftover regex still catches a bare set_hwclock_type --hctosys ([a-z-]* can match empty) and does not match the fixed -q utc / cli utc forms. The A && ! B || die grouping dies if either check fails.
  • Placement: the block sits in the BASE branch only (after the else of mode = woof), so the WOOF path is unchanged.
  • Mode and filter: chmod 755 makes the staging loop pick md=755, which is the base's mode. A base that already carries the fix gives an identical file, which the existing filter drops. That matches your second-run no-op.
  • Measurements: the diff against the v2026.47 base is exactly lines 98 and 100, which supports the change. The PR says plainly that a full cut and an image boot were not run.

Sibling gap (not this PR's scope; worth a separate PR): #3330 (1031988, merged after this branch) makes container-build.sh run hook-rc-shutdown.sh on the base's etc/rc.d/rc.shutdown, so a stalled reboot names its step. That is another base file edited only on the woof path. cut.sh (main and this branch) never calls the hook, so a BASE cut ships an rc.shutdown without the step markers. Those markers are what the reboot-stall investigation needs from the next stick. The same pattern works for it: unsquashfs -cat, run the hook, guard that the hook's marker is present, mode 755, add an OS row.

@bong-water-water-bong
bong-water-water-bong merged commit 0c4c40c into main Nov 22, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-release/cut-base-rc-country branch November 22, 2026 21:08
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review from cl-buildenv, which wrote cut.sh. This fills the "full cut not run" gap: I cut the branch on ryzen. Nothing was booted on hardware.

Code: the two seds and the REFUSED guard are exactly container-build.sh's.

Dry full cut of d96564b:

  • Command: ESP=~/rel-v2026.47/esp-from-box BASE=~/rel-v2026.47/osfiles NODE_TARBALL=<pinned> NO_ARCHIVE=1 cut.sh <fresh release build of d96564bb> rc-test-3329 <out>.
  • It exits 0, logging "38 OS file(s) already identical in the base; patching 22 + the payload".
  • patch-sfs: etc/rc.d/rc.country 414de62d… -> 0ca6fe66…, one of the 23 declared paths that differ.
  • image-probe.sh: PROBE PASS (130 payload files byte for byte).
  • In the image's own puppy_upup64r_26.04.sfs, rc.country is root:root 0755. Its diff from the v2026.47 base is exactly lines 98 and 100 (cli utc --hctosys, -q utc --hctosys), and the "1bit: a headless boot must not ask" line is still present.

LGTM. I deleted the dry-cut image afterwards; it was not archived.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant