Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions os/v3/puppy/console-tui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ os/v3/puppy/console-tui/build-static.sh # cargo test + musl release build
CONSOLE_TUI_BIN=<that path> bash os/v3/puppy/build.sh resolute64
```

The last line it prints in the clean case is `build-static: ok <hash> <bytes> (HEAD <sha>, tree clean)`. **That hash
names a commit, and only a clean tree produces it**: with uncommitted changes under this crate it prints
`build-static: DIRTY <hash>-dirty <bytes> - NOT <sha>'s artifact …` on stderr and exits 1, while still printing the
binary path (it is fine to test with). The reason is engine#1326: `cargo fmt` re-wrapping one line moved the binary by
24 bytes - rustc embeds `file:line` in panic messages - and a hash built from the tree *before* that `cargo fmt` was
quoted as if it were the commit's, which the release lane had no way to tell from a real difference. Quote the clean
number, or rebuild from the merged tree.

`container-build.sh` installs the binary as `/usr/local/bin/1bit-console-tui`, refuses a `CONSOLE_TUI_BIN` that
does not *run* (`--version` must print `1bit-console-tui ...` - a program init cannot exec is how a console
becomes a dead screen), refuses a packed copy that is not executable, and merely notes the binary's absence:
Expand Down
23 changes: 21 additions & 2 deletions os/v3/puppy/console-tui/build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
# cannot start because of a loader is a dead screen. The musl target links with the bundled rust-lld, so no
# musl-gcc is needed. `--selftest` proves the binary answers without a terminal.
#
# Exit: 0 built and static, 1 the toolchain or the resulting binary is not what the image needs.
# Exit: 0 built and static, 1 the toolchain or the resulting binary is not what the image needs, or the tree has
# uncommitted changes in this crate - in that last case the hash it prints is marked `-dirty`, because a hash from a
# dirty tree is not the artifact of any commit and cannot be quoted in a hand-off (engine#1326).
set -eu

cd "$(dirname "$0")"
Expand Down Expand Up @@ -63,5 +65,22 @@ fi
"$OUT" --version > /dev/null
"$OUT" --snapshot 80x25 --fixture > /dev/null

echo "build-static: ok $(sha256sum "$OUT" | cut -c1-16) $(stat -c %s "$OUT") bytes"
# An artifact hash is quoted in cycle hand-offs and pinned as CONSOLE_TUI_BIN, so it has to belong to a COMMIT.
# A dirty tree produces a hash nobody else can reproduce - and not only by a little: rustc embeds `file:line` in
# panic messages, so `cargo fmt` re-wrapping a line moved this binary by 24 bytes (engine#1326, where the hash of a
# pre-`cargo fmt` tree was quoted as if it were #1323's head, and the release lane could not tell it apart from a
# real difference). The check is scoped to this crate: those are the only files that can change these bytes, and
# the engine tree is big enough that an unrelated edit elsewhere must not block a console build.
hash=$(sha256sum "$OUT" | cut -c1-16)
bytes=$(stat -c %s "$OUT")
head=$(git rev-parse --short HEAD 2> /dev/null || echo unknown)
dirty=$(git status --porcelain -- . 2> /dev/null || true)
if [ -n "$dirty" ]; then
echo "build-static: DIRTY $hash-dirty $bytes bytes - NOT $head's artifact: $(printf '%s\n' "$dirty" | wc -l | tr -d ' ') uncommitted path(s) under $PWD" >&2
echo "build-static: commit them and run this again to get a hash that names a commit (the binary below is fine to test with)" >&2
echo "$PWD/$OUT"
exit 1
fi

echo "build-static: ok $hash $bytes bytes (HEAD $head, tree clean)"
echo "$PWD/$OUT"
Loading