AtlatestRepositorycore-channel

core-channel / tree / seed / scriptsgate-crosspath.sh

1#!/bin/sh
2set -eu
3
4seed=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
5repo=$(CDPATH= cd -- "$seed/.." && pwd)
6scratch=$(mktemp -d /tmp/sigil-channel-crosspath.XXXXXX)
7clone="$scratch/clone"
8cleanup() { rm -rf "$scratch"; }
9trap cleanup EXIT HUP INT TERM
11fetch_sources() {
12 target=$1
13 mkdir -p "$target/seed/sources"
14 while IFS=' ' read -r hash url file rest; do
15 case "$hash" in ''|'#'*) continue ;; esac
16 curl --fail --location --silent --show-error "$url" --output "$target/seed/$file"
17 actual=$(sha256sum "$target/seed/$file" | awk '{print $1}')
18 [ "$actual" = "$hash" ] || { echo "source hash mismatch: $file" >&2; exit 1; }
19 done < "$target/seed/MANIFEST.sources"
22fetch_sources "$repo"
23"$seed/scripts/build-seed.sh"
24primary=$(awk '{print $1}' "$seed/seed-x86_64-linux.tar.gz.sha256")
26git clone --quiet --no-hardlinks "$repo" "$clone"
27SIGIL_BOOTSTRAP_SEED_URL="${SIGIL_BOOTSTRAP_SEED_URL:-}" \
28SIGIL_BOOTSTRAP_ZIG_URL="${SIGIL_BOOTSTRAP_ZIG_URL:-}" "$clone/bootstrap"
29fetch_sources "$clone"
30"$clone/seed/scripts/build-seed.sh"
31rebuilt=$(awk '{print $1}' "$clone/seed/seed-x86_64-linux.tar.gz.sha256")
33echo "primary=$primary"
34echo "crosspath=$rebuilt"
35if [ "$primary" != "$rebuilt" ]; then
36 echo "cross-path seed hash mismatch" >&2
37 exit 1
38fi
39echo "MATCH"