interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tools / require_physics_pin.sh

26 lines · 1497 bytes Raw Blame History
1#!/bin/sh
2# require_physics_pin.sh PHYSICS_DIR
3# omega#456: the chip runners build against a Physics checkout given on their command line (default
4# ~/workspace/physics-own30b-k). They build single targets, so the Makefile's check-physics-lock (run by `all`)
5# never ran for them. Each runner calls this first, before it writes evidence or builds anything: it refuses
6# (exit 2) unless PHYSICS_DIR's commit, trees, blobs, raw worktree bytes and modes exactly match physics.lock.
7# PHYSICS_LOCK_CHECK=0 skips the check, the same override the Makefile honours, and says so on stderr.
8set -u
9PHYS="${1:?usage: require_physics_pin.sh PHYSICS_DIR}"
10ROOT="$(cd "$(dirname "$0")/.." && pwd)" || exit 2
11if [ "${PHYSICS_LOCK_CHECK:-1}" = "0" ]; then
12 echo "require_physics_pin: PHYSICS_LOCK_CHECK=0, Physics pin NOT checked for $PHYS" >&2
13 exit 0
14fi
15[ -f "$ROOT/physics.lock" ] || { echo "require_physics_pin: REFUSED: $ROOT/physics.lock not found" >&2; exit 2; }
16locked=$(tr -d '[:space:]' < "$ROOT/physics.lock")
17printf '%s' "$locked" | grep -qxE '^[0-9a-f]{40}$' || {
18 echo "require_physics_pin: REFUSED: physics.lock must contain exactly one lowercase 40-hex commit" >&2
19 exit 2
20}
21if ! "$ROOT/tools/pinned_checkout.sh" verify "$PHYS" "$locked" >/dev/null; then
22 printf '%s\n' "require_physics_pin: REFUSED: PHYSICS_DIR=$PHYS is not an exact worktree of physics.lock ($locked)" >&2
23 echo " pass an unmodified checkout at the pin, or set PHYSICS_LOCK_CHECK=0" >&2
24 exit 2
25fi
26exit 0