Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-packages/blob/main/scripts/omc-from-seed.sh # omega-packages aien-dev/omega-packages Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-packages / scripts / omc-from-seed.sh` 60 lines ยท 2830 bytes Raw Blame History 1 #!/bin/sh 2 # omc-from-seed.sh WORKDIR -- fetch the pinned omega-mv source archive, check its sha256, birth omc 3 # from the 408-byte seed with omega-mv's own seed/omega-from-seed.sh, and check the result's sha256. 4 # 5 # sh scripts/omc-from-seed.sh build # writes build/omc and keeps build/omega-mv-/ 6 # 7 # Environment (used by the negative controls; leave unset for a normal build): 8 # EXPECT_SRC_SHA256 expected archive sha256 (default: OMEGA_MV_TARBALL_SHA256 in pins.env) 9 # EXPECT_OMC_SHA256 expected omc sha256 (default: OMC_SHA256 in pins.env) 10 # SRC_ARCHIVE use this local archive instead of downloading (it is still hash-checked) 11 # TAMPER_SEED=1 flip one hex digit of seed/rung0/seed0.hex before the birth (must FAIL) 12 # 13 # Exit 0 = PASS, 1 = FAIL, 2 = usage, 3 = NOT_RUN (not AArch64 Linux). 14 # Host glue only: curl, tar, gzip, sha256sum. Every byte of omc is written by the seed programs. 15 set -eu 16 here=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) 17 . "$here/pins.env" 18 [ $# -eq 1 ] || { echo "usage: omc-from-seed.sh WORKDIR" >&2; exit 2; } 19 if [ "$(uname -s)/$(uname -m)" != Linux/aarch64 ]; then 20 echo "NOT_RUN: the seed programs are AArch64 Linux ELF files; this host is $(uname -s)/$(uname -m)" 21 exit 3 22 fi 23 w=$1 24 mkdir -p "$w" 25 w=$(CDPATH= cd -- "$w" && pwd) 26 fail() { printf 'FAIL %s\n' "$*" >&2; exit 1; } 27 28 arc=$w/omega-mv-$OMEGA_MV_COMMIT.tar.gz 29 if [ -n "${SRC_ARCHIVE:-}" ]; then 30 cp "$SRC_ARCHIVE" "$arc" 31 elif [ ! -s "$arc" ]; then 32 curl -fsSL --retry 3 -o "$arc" "https://github.com/aien-dev/omega-mv/archive/$OMEGA_MV_COMMIT.tar.gz" 33 fi 34 want=${EXPECT_SRC_SHA256:-$OMEGA_MV_TARBALL_SHA256} 35 got=$(sha256sum "$arc" | cut -d' ' -f1) 36 [ "$got" = "$want" ] || fail "source archive sha256 $got, pinned $want" 37 printf 'PASS source archive %s\n' "$got" 38 39 tree=$w/omega-mv-$OMEGA_MV_COMMIT 40 rm -rf "$tree" 41 tar -xzf "$arc" -C "$w" 42 [ -f "$tree/seed/omega-from-seed.sh" ] || fail "archive has no seed/omega-from-seed.sh" 43 44 if [ "${TAMPER_SEED:-}" = 1 ]; then 45 # Negative control: change the first hex word of the hand-written seed. The chain must refuse it. 46 f=$tree/seed/rung0/seed0.hex 47 cp "$f" "$w/seed0.hex.orig" 48 awk 'done!=1 && /^[0-9a-fA-F]/ { c=substr($0,1,1); r=(c=="0")?"1":"0"; $0=r substr($0,2); done=1 } {print}' \ 49 "$w/seed0.hex.orig" > "$f" 50 ! cmp -s "$f" "$w/seed0.hex.orig" || fail "tamper edit changed nothing" 51 echo "CONTROL seed0.hex tampered: $(cmp "$f" "$w/seed0.hex.orig" || true)" 52 fi 53 54 (cd "$tree" && sh seed/omega-from-seed.sh) || fail "seed/omega-from-seed.sh refused the tree" 55 want=${EXPECT_OMC_SHA256:-$OMC_SHA256} 56 got=$(sha256sum "$tree/seed/out/omc" | cut -d' ' -f1) 57 [ "$got" = "$want" ] || fail "omc sha256 $got, pinned $want" 58 cp "$tree/seed/out/omc" "$w/omc" 59 chmod 0755 "$w/omc" 60 printf 'PASS omc %s %s bytes\n' "$got" "$(wc -c < "$w/omc" | tr -d ' ')"