omnet
aien-dev/omnet
Brought by drakestapleton
| 1 | #!/bin/sh |
| 2 | # Build the pinned seed-born Omega compiler and print its path. |
| 3 | # The compiler is born from omega-mv (served by Interplane) at the commit in omega.pin by the |
| 4 | # repository's own seed chain; its digest must equal the pinned digest. |
| 5 | # Usage: tools/omc.sh -> prints path of a verified omc on stdout |
| 6 | set -eu |
| 7 | root=$(cd "$(dirname "$0")/.." && pwd) |
| 8 | pin_commit=$(awk '$1 == "omega-mv" { print $2 }' "$root/omega.pin") |
| 9 | pin_sha=$(awk '$1 == "omc-sha256" { print $2 }' "$root/omega.pin") |
| 10 | src="$root/build/omega-mv" |
| 11 | omc="$src/seed/out/omc" |
| 12 | |
| 13 | if [ ! -d "$src/.git" ]; then |
| 14 | mkdir -p "$root/build" |
| 15 | git clone -q --filter=blob:none https://interplane.io/drakestapleton/omega-mv.git "$src" >&2 |
| 16 | fi |
| 17 | if [ "$(git -C "$src" rev-parse HEAD)" != "$pin_commit" ]; then |
| 18 | git -C "$src" fetch -q origin "$pin_commit" >&2 |
| 19 | git -C "$src" checkout -q --detach "$pin_commit" >&2 |
| 20 | fi |
| 21 | if [ ! -x "$omc" ] || [ "$(sha256sum "$omc" | cut -d' ' -f1)" != "$pin_sha" ]; then |
| 22 | (cd "$src" && sh seed/omega-from-seed.sh) >&2 |
| 23 | fi |
| 24 | # The birth script accepts any fixpoint and rewrites its own digest file, so the |
| 25 | # pinned digest is checked here, never seed/out/omc.sha256. |
| 26 | got=$(sha256sum "$omc" | cut -d' ' -f1) |
| 27 | if [ "$got" != "$pin_sha" ]; then |
| 28 | echo "omc.sh: omc digest $got does not match pin $pin_sha" >&2 |
| 29 | exit 1 |
| 30 | fi |
| 31 | echo "$omc" |