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 / agora-page / check.sh

61 lines · 2420 bytes Raw Blame History
1#!/bin/sh
2# Regenerate the /agora/ skeleton and browser script using the pinned arm64 omc.
3# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten;
4# 5: nondeterministic output; 6: empty output. Compile/run failures propagate.
5set -eu
6cd "$(dirname "$0")"
7omc=${OMEGA_OMC:-$PWD/../hive-page/omc}
8pin=$(tr -d ' \n' < omc.sha256)
9if [ ! -f "$omc" ]; then
10 printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2
11 exit 2
12fi
13have=$(sha256sum "$omc" | cut -d' ' -f1)
14if [ "$have" != "$pin" ]; then
15 printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2
16 exit 3
17fi
18work=$(mktemp -d "${TMPDIR:-/tmp}/agora-page.XXXXXX")
19trap 'rm -rf "$work"' EXIT HUP INT TERM
20cat contract.om agora.om agora-js.om > "$work/agora.om"
21"$omc" < "$work/agora.om" > "$work/agora"
22chmod +x "$work/agora"
23"$work/agora" > "$work/first.html" 3> "$work/first.agora.js"
24"$work/agora" > "$work/second.html" 3> "$work/second.agora.js"
25stale=0
26publish() {
27 first=$1
28 second=$2
29 artifact=$3
30 sidecar=$4
31 if ! cmp -s "$first" "$second"; then
32 printf '%s: generator output differs between runs\n' "$artifact" >&2
33 exit 5
34 fi
35 if [ ! -s "$first" ]; then
36 printf '%s: generator wrote nothing\n' "$artifact" >&2
37 exit 6
38 fi
39 if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$first"; then
40 stale=1
41 fi
42 cp "$first" "$artifact"
43 hash=$(sha256sum "$artifact" | cut -d' ' -f1)
44 printf '%s %s\n' "$hash" "$artifact" > "$sidecar"
45 printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash"
46}
47publish "$work/first.html" "$work/second.html" main.html main.html.sha256
48publish "$work/first.agora.js" "$work/second.agora.js" ../../public/js/agora.js agora.js.sha256
49"$omc" < aienet.om > "$work/aienet"
50chmod +x "$work/aienet"
51"$work/aienet" > "$work/first.aienet.html" 3> "$work/first.aienet.js"
52"$work/aienet" > "$work/second.aienet.html" 3> "$work/second.aienet.js"
53publish "$work/first.aienet.html" "$work/second.aienet.html" aienet.html aienet.html.sha256
54publish "$work/first.aienet.js" "$work/second.aienet.js" ../../public/js/aienet.js aienet.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