#!/usr/bin/env bash # # Build the pinned toolchain and prove the committed oracle still reproduces. # # ./tools/reference-toolchain/verify.sh # verify the hash only # ./tools/reference-toolchain/verify.sh --full # regenerate and compare # # --full runs all 123 cases through OpenSCAD. On the staging host that takes a # while: the solvers are single-threaded and the CPU is old. That is expected. set -euo pipefail REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" IMAGE="mechcomp/reference-toolchain:8.0.0" EXPECTED="ddd0f1548379205dd0c652ec07285b0dae331e52ff0a0437005dfc6cddcc2cb2" echo "==> building ${IMAGE}" docker build -t "${IMAGE}" "${REPO}/tools/reference-toolchain" echo echo "==> toolchain versions" docker run --rm "${IMAGE}" openscad --version docker run --rm "${IMAGE}" git -C /BOSL2 rev-parse HEAD 2>/dev/null \ || echo "(BOSL2 .git removed at build time; commit is pinned by ARG)" echo echo "==> verifying the committed oracle" python3 "${REPO}/fixtures/strap-beam-8.0.0/make_fixtures.py" --verify if [[ "${1:-}" == "--full" ]]; then echo echo "==> regenerating all 123 cases inside the pinned toolchain" tmp="$(mktemp -d)" trap 'rm -rf "${tmp}"' EXIT cp "${REPO}/fixtures/strap-beam-8.0.0/strap-beam-fixtures-8.0.0.json" "${tmp}/before.json" docker run --rm -v "${REPO}:/repo" "${IMAGE}" \ python3 /repo/fixtures/strap-beam-8.0.0/make_fixtures.py --regenerate echo echo "==> comparing against the committed oracle" if diff -q "${tmp}/before.json" \ "${REPO}/fixtures/strap-beam-8.0.0/strap-beam-fixtures-8.0.0.json" >/dev/null; then echo "OK - byte-identical." else echo "DIFFERS from the committed oracle." >&2 echo "The 'frozen' date changes on every regeneration, so a one-line" >&2 echo "diff there is expected. Any other difference means the toolchain" >&2 echo "has drifted; investigate before proceeding." >&2 diff "${tmp}/before.json" \ "${REPO}/fixtures/strap-beam-8.0.0/strap-beam-fixtures-8.0.0.json" | head -40 >&2 || true cp "${tmp}/before.json" \ "${REPO}/fixtures/strap-beam-8.0.0/strap-beam-fixtures-8.0.0.json" echo >&2 echo "The committed oracle has been restored. Nothing was overwritten." >&2 exit 1 fi fi echo echo "expected sha256: ${EXPECTED}"