Agent review pass.

This commit is contained in:
hjozwiak committed 2026-11-24 11:12:17 -05:00
1 parent e9b2e9508b
commit 64ee749a8e
105 files changed
+2098 -320

No files matched your search

+26 -3
View File
@@ -97,9 +97,33 @@ if [[ -z $goCommand ]]; then
loongarch64) archiveArch=loong64 ;;
*) fail "No Go bootstrap archive configured for $(uname -m). Install Go 1.21 or newer."
esac
# Pinned SHA-256 digests of the official archives for the go.mod Go
# release. Never fetch a digest from the archive's own origin: a mirror
# that can replace the archive could replace its .sha256 file too.
# Update this table whenever the go directive in go.mod changes.
case "$requiredVersion:$archiveArch" in
1.27.2:amd64) expectedChecksum=ecbadb99091a3f46e31f5f934b068b1864eafa7995211b39eaddf76996045fe5 ;;
1.27.2:arm64) expectedChecksum=94f3e30b8e374bc285e7dadc11e0865726b9bc6e85b841ccceaabc0214c6b7c8 ;;
1.27.2:armv6l) expectedChecksum=e25a174051d8675f87ac720aedcd25bf89ac652c4b82f26aa47919524725ed95 ;;
1.27.2:386) expectedChecksum=93dae4b7f463ed1e9c65e05561ce9fc5f7cd5c4ffca5e336248d48f3a2eab5fc ;;
1.27.2:ppc64le) expectedChecksum=059d5f01b1607a724ea5ae87c5589041a51c577a6f3f20099e49d00f31c803fa ;;
1.27.2:riscv64) expectedChecksum=420f3b8dac8b5a9d11f51e12b496ac27f02ab31cbe495067e355ed43b9fe3aa1 ;;
1.27.2:s390x) expectedChecksum=dfd01d1e08e4dbece2cd91e259953f87b858752037fd151da2f674c4fa09aeef ;;
1.27.2:loong64) expectedChecksum=b49a3b2f090934ca588c7a897d64bc12f844348a2cd35e301d8f4f50eaf3bfdb ;;
*) fail "No pinned SHA-256 for Go $requiredVersion on Linux/$archiveArch. Install Go $requiredVersion or newer, or add its official digest to build-cthulhu.sh."
esac
toolchainDir="${XDG_CACHE_HOME:-$HOME/.cache}/cthulhu/toolchains/go${requiredVersion}.linux-${archiveArch}"
goCommand="$toolchainDir/go/bin/go"
if [[ ! -x $goCommand ]]; then
digestFile="$toolchainDir/.archive.sha256"
if [[ -x $goCommand ]]; then
# A cached toolchain is trusted only if a previous verified download
# recorded the pinned digest for it.
cachedChecksum=""
if [[ -f $digestFile ]]; then
IFS= read -r cachedChecksum < "$digestFile" || true
fi
[[ $cachedChecksum == "$expectedChecksum" ]] || fail "Cached Go toolchain at $toolchainDir is unverified. Remove it and rerun to download a verified copy."
else
for dependency in curl tar sha256sum; do
command -v "$dependency" >/dev/null || fail "Install $dependency to bootstrap Go, or install Go $requiredVersion or newer."
done
@@ -109,8 +133,6 @@ if [[ -z $goCommand ]]; then
archiveURL="https://dl.google.com/go/go${requiredVersion}.linux-${archiveArch}.tar.gz"
echo "Downloading Go $requiredVersion for Linux/$archiveArch..."
curlFlags=(--fail --location --silent --show-error --proto '=https' --proto-redir '=https')
expectedChecksum=$(curl "${curlFlags[@]}" "$archiveURL.sha256")
[[ $expectedChecksum =~ ^[[:xdigit:]]{64}$ ]] || fail "Invalid Go archive checksum."
curl "${curlFlags[@]}" --output "$downloadDir/go.tar.gz" "$archiveURL"
printf '%s %s\n' "$expectedChecksum" "$downloadDir/go.tar.gz" | sha256sum --check --status || fail "Go archive checksum mismatch."
tar -xzf "$downloadDir/go.tar.gz" -C "$downloadDir"
@@ -120,6 +142,7 @@ if [[ -z $goCommand ]]; then
mkdir -p -- "$toolchainDir"
mv -T -- "$downloadDir/go" "$toolchainDir/go" || [[ -x $goCommand ]]
fi
printf '%s\n' "$expectedChecksum" > "$digestFile"
fi
unset GOROOT
fi