aien
aien-dev/aien
Brought by drakestapleton
aien / scripts / bots / build.sh
| 1 | #!/bin/sh |
| 2 | # Named migration build adapter only; runtime logic is src/bots/bots.om. |
| 3 | set -eu |
| 4 | HERE=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) |
| 5 | OUT=${1:?usage: build.sh OUTPUT} |
| 6 | : "${OMEGA_OMC:?set OMEGA_OMC to e5b32567 omc}" |
| 7 | : "${OMEGA_MV:?set OMEGA_MV to a checkout containing 55845e70}" |
| 8 | [ "$(sha256sum < "$OMEGA_OMC" | cut -c1-64)" = 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f ] || { echo 'BLOCKED: omc pin mismatch' >&2; exit 3; } |
| 9 | T=$(mktemp -d) |
| 10 | trap 'rm -rf "$T"' EXIT HUP INT TERM |
| 11 | git -C "$OMEGA_MV" show 55845e70:om/sha256/sha256-om2.om > "$T/sha.om" |
| 12 | [ "$(sha256sum < "$T/sha.om" | cut -c1-64)" = dbf002dd6aa36585632b9d01d98ac3f0bd2fa0f0475082940de53638847994bb ] || { echo 'BLOCKED: SHA unit mismatch' >&2; exit 3; } |
| 13 | sed 's/^export fn /fn /' "$T/sha.om" > "$T/unit.om" |
| 14 | cat "$T/unit.om" "${BOTS_SOURCE:-$HERE/src/bots/bots.om}" > "$T/source.om" |
| 15 | "$OMEGA_OMC" < "$T/source.om" > "$T/bots" |
| 16 | chmod +x "$T/bots" |
| 17 | mv "$T/bots" "$OUT" |
| 18 | sha256sum "$OUT" |