interplane.Get Omega
Read in your language

omnet

aien-dev/omnet

Brought by drakestapleton

branch main Branches Tags History

omnet / tools / omc.sh

31 lines · 1307 bytes Raw Blame History
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
6set -eu
7root=$(cd "$(dirname "$0")/.." && pwd)
8pin_commit=$(awk '$1 == "omega-mv" { print $2 }' "$root/omega.pin")
9pin_sha=$(awk '$1 == "omc-sha256" { print $2 }' "$root/omega.pin")
10src="$root/build/omega-mv"
11omc="$src/seed/out/omc"
12
13if [ ! -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
16fi
17if [ "$(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
20fi
21if [ ! -x "$omc" ] || [ "$(sha256sum "$omc" | cut -d' ' -f1)" != "$pin_sha" ]; then
22 (cd "$src" && sh seed/omega-from-seed.sh) >&2
23fi
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.
26got=$(sha256sum "$omc" | cut -d' ' -f1)
27if [ "$got" != "$pin_sha" ]; then
28 echo "omc.sh: omc digest $got does not match pin $pin_sha" >&2
29 exit 1
30fi
31echo "$omc"