cortex
aien-dev/cortex
Brought by drakestapleton
| 1 | #!/bin/sh |
| 2 | # tools/omc.sh : print the path of the pinned Omega compiler. The pin is written only in PIN at the |
| 3 | # repository root (`omega-mv <rev>` and `omc-sha256 <sha256>`); this script, build.sh, the gate |
| 4 | # labels and CI read it from there, and tools/pincheck.om (run by build.sh) fails the build when any |
| 5 | # tracked file restates it. Uses $OMC when set; otherwise extracts seed/out/omc at the pinned rev |
| 6 | # once from an omega-mv repository ($OMEGA_REPO, default the local Radicle storage of omega-mv, |
| 7 | # rad:z6do9WDBhuSnvopDkgFdFr1yWA62) into build/omc-<sha256>. Exit 1 on a pin mismatch, a malformed |
| 8 | # PIN, or when no repository holds the pinned rev. |
| 9 | set -u |
| 10 | R=$(cd "$(dirname "$0")/.." && pwd) |
| 11 | PIN_REV= |
| 12 | PIN_SHA= |
| 13 | while read -r k v; do |
| 14 | case $k in |
| 15 | omega-mv) PIN_REV=$v ;; |
| 16 | omc-sha256) PIN_SHA=$v ;; |
| 17 | esac |
| 18 | done < "$R/PIN" |
| 19 | [ ${#PIN_REV} -eq 40 ] && [ ${#PIN_SHA} -eq 64 ] || { echo "omc.sh: $R/PIN must name omega-mv <40 hex> and omc-sha256 <64 hex>" >&2; exit 1; } |
| 20 | if [ -z "${OMC:-}" ]; then |
| 21 | OMC=$R/build/omc-$PIN_SHA |
| 22 | if [ ! -x "$OMC" ]; then |
| 23 | mkdir -p "$R/build" |
| 24 | REPO=${OMEGA_REPO:-${RAD_HOME:-$HOME/.radicle}/storage/z6do9WDBhuSnvopDkgFdFr1yWA62} |
| 25 | if ! git -C "$REPO" show "$PIN_REV:seed/out/omc" > "$OMC.tmp"; then |
| 26 | echo "omc.sh: cannot read $PIN_REV:seed/out/omc from $REPO (rad clone rad:z6do9WDBhuSnvopDkgFdFr1yWA62, or set OMEGA_REPO)" >&2 |
| 27 | rm -f "$OMC.tmp" |
| 28 | exit 1 |
| 29 | fi |
| 30 | chmod +x "$OMC.tmp" && mv "$OMC.tmp" "$OMC" |
| 31 | fi |
| 32 | fi |
| 33 | have=$(sha256sum "$OMC" | cut -d' ' -f1) |
| 34 | if [ "$have" != "$PIN_SHA" ]; then |
| 35 | echo "omc.sh: $OMC sha256 $have != pinned $PIN_SHA (PIN)" >&2 |
| 36 | exit 1 |
| 37 | fi |
| 38 | echo "$OMC" |