aienos.com
Source of www.aienos.com, served from my own hardware
Brought by drakestapleton
aienos.com / om / allen-panes / check.sh
| 1 | #!/bin/sh |
| 2 | # Regenerate the Allen glass panes script using the pinned arm64 omc. |
| 3 | # The compiler is the one vendored for the Hive page; its pin is recorded once, |
| 4 | # in ../hive-page/omc.sha256. contract.om is the canonical pane contract (owned |
| 5 | # by the science protocol); its kinds, events, version and byte limits are |
| 6 | # compiled into the script. CI on x86_64 checks the committed artifact against |
| 7 | # its recorded hash. OMEGA_OMC overrides the compiler path, never its pin. |
| 8 | # OMEGA_ACCEPT_CHANGE=1 accepts a rewritten artifact; otherwise stale output exits 4. |
| 9 | # Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten; |
| 10 | # 5: nondeterministic output; 6: empty output. Compile/run failures propagate. |
| 11 | set -eu |
| 12 | cd "$(dirname "$0")" |
| 13 | omc=${OMEGA_OMC:-$PWD/../hive-page/omc} |
| 14 | pin=$(tr -d ' \n' < ../hive-page/omc.sha256) |
| 15 | if [ ! -f "$omc" ]; then |
| 16 | printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2 |
| 17 | exit 2 |
| 18 | fi |
| 19 | have=$(sha256sum "$omc" | cut -d' ' -f1) |
| 20 | if [ "$have" != "$pin" ]; then |
| 21 | printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2 |
| 22 | exit 3 |
| 23 | fi |
| 24 | work=$(mktemp -d "${TMPDIR:-/tmp}/allen-panes.XXXXXX") |
| 25 | trap 'rm -rf "$work"' EXIT HUP INT TERM |
| 26 | # Concatenation composes Omega units; it does not implement generation in shell. |
| 27 | cat contract.om panes.om > "$work/panes.om" |
| 28 | "$omc" < "$work/panes.om" > "$work/panes" |
| 29 | chmod +x "$work/panes" |
| 30 | "$work/panes" > "$work/first.js" |
| 31 | "$work/panes" > "$work/second.js" |
| 32 | if ! cmp -s "$work/first.js" "$work/second.js"; then |
| 33 | printf 'allen-panes.js: generator output differs between runs\n' >&2 |
| 34 | exit 5 |
| 35 | fi |
| 36 | if [ ! -s "$work/first.js" ]; then |
| 37 | printf 'allen-panes.js: generator wrote nothing\n' >&2 |
| 38 | exit 6 |
| 39 | fi |
| 40 | artifact=../../public/js/allen-panes.js |
| 41 | stale=0 |
| 42 | if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$work/first.js"; then |
| 43 | stale=1 |
| 44 | fi |
| 45 | cp "$work/first.js" "$artifact" |
| 46 | hash=$(sha256sum "$artifact" | cut -d' ' -f1) |
| 47 | printf '%s %s\n' "$hash" "$artifact" > allen-panes.js.sha256 |
| 48 | printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash" |
| 49 | printf 'omc sha256 %s\n' "$have" |
| 50 | if [ "$stale" = 1 ]; then |
| 51 | printf 'Generated artifact was rewritten; commit it with its Omega sources\n' >&2 |
| 52 | if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then |
| 53 | exit 4 |
| 54 | fi |
| 55 | fi |