Skip to content

1bit-update --latest [--channel] [--download-only]: a SIGNED download, then the same slot install (OS updater U2) - #3444

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-release/updater-latest
Nov 24, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-release/updater-latest

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

OS updater, brief OS-UPDATER.md item 2. Builds on U1 (--check, #3441) and cl-buildenv's signing (#3442: tools/release_sign.py, shipped as /usr/lib/1bit/release_sign.py, with the release public key baked at /etc/1bit/release-pub; the key is the NPU release key npu-v2). Both are merged.

1bit-update --latest (root, installed system, the same rules as 1bit-update <image>):

  • Picks the channel's newest release. If it isn't newer: "up to date", exit 0.
  • Refuses before downloading when there's no image asset, or no signed SHA256SUMS (SHA256SUMS + SHA256SUMS.sig): only signed releases are installed.
  • Checks free space first: about 8× the compressed image plus 2 GiB in /data/updates, else it refuses before a byte moves.
  • Downloads to /data/updates/<tag>/: HTTPS only, also across GitHub's redirect (--proto =https --proto-redir =https). The image resumes (-C -); SHA256SUMS and its .sig are always fetched fresh.
  • update_verify runs release_sign.py verify-image: the release key's signature over SHA256SUMS, then the image's streamed sha256 against the line naming it. Any refusal removes the download and installs nothing. No verifier or no public key in the image is also a refusal.
  • Then it keeps the fetched release plus one previous (update_prune), decompresses (zstd), and hands the .img to the existing install. That install verifies the set's own SHA256SUMS and never touches the running slot, so --rollback stays available.

--download-only stops after the verified download, for the console menu (U4) and web UI (U5), which install later.

Measured: tests/update_latest_test.sh (new, ctest update_latest) signs a fake release with a throwaway key using main's own tools/release_sign.py:

  • a good release verifies (exit 0);
  • each of these is refused, exit 2: an image changed after signing, a SHA256SUMS changed after signing, an unsigned release, another key's signature, no public key, no verifier;
  • prune keeps two.

8/8 under dash (env -i) and busybox ash. update_check: ok. Pre-PR checks after the rebase: 17 green, 3 skipped.

Not done here: a real --latest end to end, because no published release carries SHA256SUMS.sig yet. That's U7 (a release-check row and a QEMU test with a locally signed image).

🤖 Generated with Claude Code

…, then the same slot install (OS updater U2)

Brief OS-UPDATER.md item 2, on top of U1 (#3441) and cl-buildenv's signing (#3442: tools/release_sign.py shipped as
/usr/lib/1bit/release_sign.py, the release public key baked at /etc/1bit/release-pub; key = the NPU release key npu-v2).

--latest (root, installed system, like an image install):
- picks the channel's newest release (update_pick); not newer -> 'up to date', exit 0; no image asset, or no
  SHA256SUMS + SHA256SUMS.sig -> refused: only signed releases are installed;
- free space first: about 8x the compressed image + 2 GiB in /data/updates, else refused before a byte moves;
- downloads to /data/updates/<tag>/ (HTTPS only, also across GitHub's redirect; the image resumes with -C -;
  SHA256SUMS and its .sig always fresh);
- update_verify: release_sign.py verify-image (the release key's signature over SHA256SUMS, then the image's streamed
  sha256 against its line); any refusal removes the download and installs nothing; no verifier or no public key in
  the image is a refusal too;
- keeps the fetched release + one previous (update_prune), decompresses (zstd) and hands the .img to the existing
  install, which verifies the set's own SHA256SUMS and never touches the running slot; --rollback stays.
--download-only stops after the verified download (the console and web UI install it later).

tests/update_latest_test.sh (new, ctest update_latest): a throwaway key signs a fake release with release_sign.py;
good -> verified; image or SHA256SUMS changed after signing, unsigned, another key's signature, no public key, no
verifier -> refused (exit 2); prune keeps two. 8/8 under dash (env -i) and busybox ash.

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:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

The update_prune function may remove directories incorrectly if the ls -1td command produces unexpected output or if the directory names contain special characters that interfere with the shell parsing. This could lead to unintended deletion of directories or failure to prune correctly.

update_prune() {
    _keep=$1 _n=0
    for _d in $(ls -1td "$UPDATE_DIR"/v*/ 2> /dev/null); do
        _d=${_d%/}
        [ "${_d##*/}" = "$_keep" ] && continue
        _n=$((_n + 1)); [ "$_n" -le 1 ] && continue
        rm -rf "${_d:?}" && say "removed the older download ${_d##*/}"
    done
}
Possible Issue

The update_latest function checks for free space using df -Pk and calculates _need based on the compressed image size. However, the calculation assumes a fixed compression ratio (8x) and does not account for potential variations in actual compression or disk usage, which could lead to incorrect space estimation.

# room for the compressed download, its decompressed image (about 7x) and 2 GiB of margin, before any byte moves
_have=$(df -Pk "$UPDATE_DIR" | awk 'NR==2 {print $4}')
_need=$(( (_size / 1024) * 8 + 2097152 ))
[ "${_have:-0}" -ge "$_need" ] || die "$UPDATE_DIR has $((_have / 1048576)) GiB free, $_tag needs about $((_need / 1048576)) GiB"

@bong-water-water-bong
bong-water-water-bong merged commit 030af36 into main Nov 24, 2026
11 of 12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-release/updater-latest branch November 24, 2026 02:30
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

cl-release, after merge: an end-to-end run against the real published v2026.49-rc1 (strixhalo, the installed rc1, main's 1bit-update + tools/release_sign.py + the release public key, run from /data/dev):

1bit-update --latest --channel test --download-only
downloading v2026.49-rc1 (1324 MiB) into …/updates/v2026.49-rc1
verified: release_sign: OK 1bit-os-v2026.49-rc1.img.zst matches the signed SHA256SUMS (key npu-v2)
downloaded and verified: …/1bit-os-v2026.49-rc1.img.zst

Without ONEBIT_UPDATE_ANY=1 (which skips only the newer-than-running test), the same command correctly answers "up to date: running v2026.49-rc1". So the release-side signature (#3442), the published SHA256SUMS.sig, the baked public key and --latest chain together on real data. The download was removed afterwards; nothing was installed.

🤖 Generated with Claude Code

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