omega-kernel-smoke
Minimal Omega GPU kernel smoke verification harness
Brought by drakestapleton
omega-kernel-smoke / tools / fetch.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Fetch the pinned toolchain named in toolchain.lock into .okt/ and refuse any file |
| 4 | # whose sha256 differs. Sources are GitHub only: raw files of aien-dev/omega-mv at an |
| 5 | # exact commit, and the PoCL release asset of this template repository. |
| 6 | # INTERIM host glue (POSIX sh + curl). Successor: an Omega fetch-and-verify unit once |
| 7 | # seeded Omega has an HTTPS client word; until then curl moves bytes and sha256sum, |
| 8 | # not curl, decides what is accepted. |
| 9 | # usage: sh tools/fetch.sh [all|omega|pocl] |
| 10 | set -eu |
| 11 | cd "$(dirname "$0")/.." |
| 12 | . ./toolchain.lock |
| 13 | what=${1:-all} |
| 14 | D=.okt |
| 15 | mkdir -p "$D/tools" |
| 16 | |
| 17 | get() { |
| 18 | url=$1; out=$2; want=$3 |
| 19 | if [ -f "$out" ] && [ "$(sha256sum "$out" | cut -d ' ' -f 1)" = "$want" ]; then |
| 20 | echo "fetch: cached $want $out" |
| 21 | return 0 |
| 22 | fi |
| 23 | curl -fsSL --retry 3 -o "$out.part" "$url" |
| 24 | got=$(sha256sum "$out.part" | cut -d ' ' -f 1) |
| 25 | if [ "$got" != "$want" ]; then |
| 26 | rm -f "$out.part" |
| 27 | echo "fetch: REFUSED $url sha256 $got, pinned $want" >&2 |
| 28 | exit 1 |
| 29 | fi |
| 30 | mv "$out.part" "$out" |
| 31 | echo "fetch: OK $want $out" |
| 32 | } |
| 33 | |
| 34 | if [ "$what" = all ] || [ "$what" = omega ]; then |
| 35 | raw=https://raw.githubusercontent.com/$OMEGA_MV_REPO/$OMEGA_MV_COMMIT |
| 36 | get "$raw/seed/out/omc" "$D/tools/omc" "$OMC_SHA256" |
| 37 | chmod +x "$D/tools/omc" |
| 38 | get "$raw/seed/spirv/irspirv.om" "$D/tools/irspirv.om" "$IRSPIRV_OM_SHA256" |
| 39 | get "$raw/seed/spirv/opencl-host.c" "$D/tools/opencl-host.c" "$OPENCL_HOST_C_SHA256" |
| 40 | get "$raw/seed/spirv/parity.py" "$D/tools/parity.py" "$PARITY_PY_SHA256" |
| 41 | fi |
| 42 | |
| 43 | if [ "$what" = all ] || [ "$what" = pocl ]; then |
| 44 | [ "$POCL_SHA256" != PENDING ] || { echo 'fetch: PoCL asset not yet published (POCL_SHA256=PENDING)' >&2; exit 3; } |
| 45 | get "https://github.com/$POCL_REPO/releases/download/$POCL_TAG/$POCL_ASSET" \ |
| 46 | "$D/$POCL_ASSET" "$POCL_SHA256" |
| 47 | rm -rf "$D/pocl" |
| 48 | mkdir -p "$D/pocl" |
| 49 | tar -xzf "$D/$POCL_ASSET" -C "$D/pocl" --strip-components=1 |
| 50 | [ -f "$D/pocl/$POCL_LIB" ] || { echo "fetch: $POCL_LIB missing from $POCL_ASSET" >&2; exit 1; } |
| 51 | echo "fetch: PoCL unpacked at $D/pocl" |
| 52 | fi |