rust-toolchain.sh

876 B · raw

1#!/bin/sh23PINNED_RUSTC_VERSION='rustc 1.96.1 (31fca3adb 2026-06-26)'4PINNED_CARGO_VERSION='cargo 1.96.1 (356927216 2026-06-26)'56require_pinned_rust_toolchain() {7    actual_rustc=$(rustc --version 2>/dev/null || true)8    actual_cargo=$(cargo --version 2>/dev/null || true)9    if [ "$actual_rustc" != "$PINNED_RUSTC_VERSION" ]; then10        echo "Rust compiler mismatch; required: $PINNED_RUSTC_VERSION" >&211        exit 112    fi13    if [ "$actual_cargo" != "$PINNED_CARGO_VERSION" ]; then14        echo "Cargo mismatch; required: $PINNED_CARGO_VERSION" >&215        exit 116    fi17}1819hash_file() {20    shasum -a 256 "$1" | awk '{print $1}'21}2223hash_rust_sources() {24    source_directory=$125    find "$source_directory" -type f -print | LC_ALL=C sort |26        while IFS= read -r source_file; do shasum -a 256 "$source_file"; done |27        shasum -a 256 | awk '{print $1}'28}29