interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / om / allen-page / check.sh

61 lines · 2524 bytes Raw Blame History
1#!/bin/sh
2# Regenerate the /allen/ skeleton and browser 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. CI on x86_64 checks the committed artifacts
5# against their recorded hashes. OMEGA_OMC overrides the compiler path, never its pin.
6# OMEGA_ACCEPT_CHANGE=1 accepts rewritten artifacts; otherwise stale output exits 4.
7# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten;
8# 5: nondeterministic output; 6: empty output. Compile/run failures propagate.
9set -eu
10cd "$(dirname "$0")"
11omc=${OMEGA_OMC:-$PWD/../hive-page/omc}
12pin=$(tr -d ' \n' < ../hive-page/omc.sha256)
13if [ ! -f "$omc" ]; then
14 printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2
15 exit 2
16fi
17have=$(sha256sum "$omc" | cut -d' ' -f1)
18if [ "$have" != "$pin" ]; then
19 printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2
20 exit 3
21fi
22work=$(mktemp -d "${TMPDIR:-/tmp}/allen-page.XXXXXX")
23trap 'rm -rf "$work"' EXIT HUP INT TERM
24# One executable shares the contract between markup (fd 1) and script (fd 3).
25# Concatenation composes Omega units; it does not implement generation in shell.
26cat contract.om allen.om allen-js.om > "$work/allen.om"
27"$omc" < "$work/allen.om" > "$work/allen"
28chmod +x "$work/allen"
29"$work/allen" > "$work/first.html" 3> "$work/first.allen.js"
30"$work/allen" > "$work/second.html" 3> "$work/second.allen.js"
31stale=0
32publish() {
33 first=$1
34 second=$2
35 artifact=$3
36 sidecar=$4
37 if ! cmp -s "$first" "$second"; then
38 printf '%s: generator output differs between runs\n' "$artifact" >&2
39 exit 5
40 fi
41 if [ ! -s "$first" ]; then
42 printf '%s: generator wrote nothing\n' "$artifact" >&2
43 exit 6
44 fi
45 if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$first"; then
46 stale=1
47 fi
48 cp "$first" "$artifact"
49 hash=$(sha256sum "$artifact" | cut -d' ' -f1)
50 printf '%s %s\n' "$hash" "$artifact" > "$sidecar"
51 printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash"
52}
53publish "$work/first.html" "$work/second.html" main.html main.html.sha256
54publish "$work/first.allen.js" "$work/second.allen.js" ../../public/js/allen.js allen.js.sha256
55printf 'omc sha256 %s\n' "$have"
56if [ "$stale" = 1 ]; then
57 printf 'Generated artifacts were rewritten; commit them with their Omega sources\n' >&2
58 if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then
59 exit 4
60 fi
61fi