#!/usr/bin/env bash # Download the musl release tarball into the download cache (default cache/) # and check it against the SHA256 pinned in musl.sha256. Nothing downloaded # is ever committed: cache/ is git-ignored. # # Offline? Put the tarball in cache/ yourself (any copy with the right # SHA256 is fine), or set MUSL_TARBALL=/path/to/musl-1.2.5.tar.gz. # # Usage: toolchain/musl/fetch.sh [CACHE_DIR] set -euo pipefail HERE=$(cd "$(dirname "$0")" && pwd) CACHE=${1:-cache} mkdir -p "$CACHE" read -r sum name < "$HERE/musl.sha256" url=$(cat "$HERE/musl.url") dest=$CACHE/$name if [ -n "${MUSL_TARBALL:-}" ] && [ ! -f "$dest" ]; then cp "$MUSL_TARBALL" "$dest"; fi if [ ! -f "$dest" ]; then echo "[musl] downloading $url" curl -fL --retry 3 -o "$dest.part" "$url" && mv "$dest.part" "$dest" fi if echo "$sum $dest" | sha256sum -c --quiet -; then echo "[musl] $dest: SHA256 OK" else echo "[musl] $dest: SHA256 MISMATCH -- delete it and try again"; exit 1 fi