#!/usr/bin/env bash # fetch_ort.sh - download prebuilt ONNX Runtime 1.20.1 (MIT), checksum-verified. # linux-x64 -> headless validation builds # win-x64 -> the shipped Windows tracker (provides onnxruntime.dll + .lib) # # Source (pinned): the project third-party mirror # https://github.com/cga-management/third-party-mirror (tag onnxruntime-1.20.1) # The upstream microsoft/onnxruntime GitHub releases were removed on 2026-11-17; # the mirror hosts the unchanged official 1.20.1 assets. The SHA256 values below # pin the exact bytes, so a tampered, partial, or wrong asset aborts with a # non-zero exit. Extraction uses tar/unzip only - no Python. # # Overrides: # ORT_DEST= where onnxruntime-{linux,win}-x64/ are placed # (default tracker-native/third_party) # ORT_BASE_URL= release base URL (for a different mirror) set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" V="1.20.1" DEST="${ORT_DEST:-${HERE}/third_party}" BASE="${ORT_BASE_URL:-https://github.com/cga-management/third-party-mirror/releases/download/onnxruntime-${V}}" ORT_LINUX_SHA256="67db4dc1561f1e3fd42e619575c82c601ef89849afc7ea85a003abbac1a1a105" ORT_WIN_SHA256="78d447051e48bd2e1e778bba378bec4ece11191c9e538cf7b2c4a4565e8f5581" need() { command -v "$1" >/dev/null 2>&1 || { echo "FATAL: required tool '$1' not found on PATH" >&2; exit 3; }; } verify() { local f="$1" want="$2" label="${3:-$(basename "$1")}" got got="$(sha256sum "$f" | cut -d' ' -f1)" if [ "$got" != "$want" ]; then echo "FATAL: SHA256 mismatch for ${label}" >&2 echo " expected ${want}" >&2 echo " got ${got}" >&2 exit 2 fi echo "ok: ${label} sha256 verified" } need curl; need sha256sum; need tar; need unzip mkdir -p "${DEST}" cd "${DEST}" if [ ! -f "onnxruntime-linux-x64/lib/libonnxruntime.so.${V}" ]; then echo "fetching ONNX Runtime ${V} linux-x64 ..." curl -fSL --retry 3 --connect-timeout 30 -o ort-linux.tgz "${BASE}/onnxruntime-linux-x64-${V}.tgz" verify ort-linux.tgz "${ORT_LINUX_SHA256}" "onnxruntime-linux-x64-${V}.tgz" rm -rf onnxruntime-linux-x64 "onnxruntime-linux-x64-${V}" tar xzf ort-linux.tgz mv "onnxruntime-linux-x64-${V}" onnxruntime-linux-x64 rm -f ort-linux.tgz fi if [ ! -f "onnxruntime-win-x64/lib/onnxruntime.dll" ]; then echo "fetching ONNX Runtime ${V} win-x64 ..." curl -fSL --retry 3 --connect-timeout 30 -o ort-win.zip "${BASE}/onnxruntime-win-x64-${V}.zip" verify ort-win.zip "${ORT_WIN_SHA256}" "onnxruntime-win-x64-${V}.zip" rm -rf onnxruntime-win-x64 "onnxruntime-win-x64-${V}" unzip -q ort-win.zip mv "onnxruntime-win-x64-${V}" onnxruntime-win-x64 rm -f ort-win.zip fi echo echo "ONNX Runtime ${V} ready in ${DEST}:" ls -d onnxruntime-*-x64