aien-receipts
Append-only AIEN verification receipts, indexed by repository and exact source commit. Read verdicts, signatures and retained logs before making a claim.
Brought by drakestapleton
aien-receipts / audit / tls / omega-mv / repro / repro-build.sh
| 1 | #!/bin/sh |
| 2 | # Reproducible-build check for the Omega TLS client (host tooling; runs no network beyond git clone). |
| 3 | # usage: sh repro-build.sh SHA [REPO_URL] [OUTDIR] |
| 4 | # Clones omega-mv at SHA into two fresh directories with different paths, births omc from seed-0 in |
| 5 | # each (seed/omega-from-seed.sh: seed0 hex -> ... -> omc stage2 == stage3), checks the result against |
| 6 | # the committed seed/out/omc.sha256, then compiles every om/tls test driver with om/tls/build.sh in |
| 7 | # each tree. PASS only if every artifact is byte-identical across the two trees and omc equals the |
| 8 | # committed digest. Writes OUTDIR/hashes.txt (sha256 per artifact per tree) and prints PASS/FAIL. |
| 9 | set -eu |
| 10 | sha=${1:?usage: repro-build.sh SHA [REPO_URL] [OUTDIR]} |
| 11 | url=${2:-https://github.com/aien-dev/omega-mv.git} |
| 12 | out=${3:-$(pwd)/repro-out} |
| 13 | mkdir -p "$out"; : > "$out/hashes.txt" |
| 14 | work=$(mktemp -d "${TMPDIR:-/tmp}/omrepro.XXXXXX") |
| 15 | fail=0 |
| 16 | for t in A longer-path-B; do |
| 17 | d="$work/$t/omega-mv" |
| 18 | git clone -q --filter=blob:none --no-checkout "$url" "$d" |
| 19 | git -C "$d" checkout -q "$sha" |
| 20 | (cd "$d" && nice -n 19 sh seed/omega-from-seed.sh) > "$out/birth-$t.log" 2>&1 || { echo "FAIL birth $t" >&2; fail=1; } |
| 21 | want=$(git -C "$d" show "$sha:seed/out/omc.sha256" | cut -d' ' -f1) |
| 22 | got=$(sha256sum "$d/seed/out/omc" | cut -d' ' -f1) |
| 23 | echo "$t omc $got committed=$want" >> "$out/hashes.txt" |
| 24 | [ "$got" = "$want" ] || { echo "FAIL omc $t $got != committed $want" >&2; fail=1; } |
| 25 | for drv in "$d"/om/tls/test/*/driver.om "$d"/om/tls/test/tls/client.om; do |
| 26 | n=$(basename "$(dirname "$drv")") |
| 27 | [ "$n" = tls ] && n=tls-client |
| 28 | (cd "$d" && nice -n 19 sh om/tls/build.sh seed/out/omc "${drv#$d/}" "$work/$t/$n.bin") \ |
| 29 | > /dev/null 2>&1 || { echo "FAIL build $t $n" >&2; fail=1; continue; } |
| 30 | echo "$t $n $(sha256sum < "$work/$t/$n.bin" | cut -d' ' -f1)" >> "$out/hashes.txt" |
| 31 | done |
| 32 | done |
| 33 | # every artifact must have the same digest in both trees |
| 34 | for n in $(awk '$1=="A"{print $2}' "$out/hashes.txt"); do |
| 35 | a=$(awk -v n="$n" '$1=="A" && $2==n {print $3}' "$out/hashes.txt") |
| 36 | b=$(awk -v n="$n" '$1=="longer-path-B" && $2==n {print $3}' "$out/hashes.txt") |
| 37 | if [ "$a" = "$b" ]; then echo "SAME $n $a"; else echo "DIFF $n A=$a B=$b"; fail=1; fi |
| 38 | done | tee "$out/compare.txt" |
| 39 | grep -q DIFF "$out/compare.txt" && fail=1 |
| 40 | rm -rf "$work" |
| 41 | [ "$fail" = 0 ] && echo "PASS reproducible build at $sha" || { echo "FAIL reproducible build at $sha"; exit 1; } |