All checks were successful
android-ci / android (pull_request) Successful in 12m20s
README, android/README, VERIFY and the two release scripts all named v0.14.0, a version that was never tagged or released - the newest tag is v0.4.0, so the documented download URLs were dead. Align them with the version this release cuts (minor bump off v0.4.0 -> v0.5.0). VERIFY.md gains a Check 0: /releases/latest/download/... is not served by this Forgejo (404, pin the tag), and Cloudflare answers a non-browser User-Agent with 403 error code 1010 even on a correct URL (measured: browser 206, curl 206, Python-urllib 403).
124 lines
No EOL
4.9 KiB
Shell
Executable file
124 lines
No EOL
4.9 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# Rebuild a released OnionWire binary from source and compare it, byte for
|
|
# byte, with the asset on the release page.
|
|
#
|
|
# Usage:
|
|
# scripts/verify-reproducible.sh <tag> [published .sha256 file or URL]
|
|
#
|
|
# ./scripts/verify-reproducible.sh v0.5.0
|
|
# ./scripts/verify-reproducible.sh v0.5.0 /path/to/onionwire-x86_64-unknown-linux-gnu.sha256
|
|
#
|
|
# Why this exists: "the source is public" is not a check anyone can run. This
|
|
# is. It rebuilds the tag's exact tree inside the same pinned builder image CI
|
|
# uses and tells you whether the bytes match. A mismatch is a finding — it means
|
|
# the published binary did not come from this source with this recipe.
|
|
#
|
|
# What it needs: docker, git, and the tag in your local clone (`git fetch --tags`).
|
|
# It never touches your working tree: the tag tree is exported with
|
|
# `git archive`, and everything is built in a temp dir that is removed on exit.
|
|
#
|
|
# What it does NOT depend on: your rustc, your distro, your glibc, your
|
|
# CPU count. All of that is inside the pinned image.
|
|
set -euo pipefail
|
|
|
|
BUILDER_IMAGE="rust@sha256:93ce27a88655056a51dbdd8f5f2d7ddc071c7b0070fb288a37b5a285fc83971e"
|
|
RELEASE_BASE="${ONIONWIRE_RELEASE_BASE:-https://forgejo.siriusdevops.com/sirius/onionwire/releases/download}"
|
|
|
|
die() { echo "verify: $*" >&2; exit 1; }
|
|
|
|
tag="${1:?usage: verify-reproducible.sh <tag> [published .sha256 file or URL]}"
|
|
expect_src="${2:-}"
|
|
|
|
command -v docker >/dev/null 2>&1 || die "docker is required to rebuild in the pinned builder image"
|
|
command -v git >/dev/null 2>&1 || die "git is required"
|
|
|
|
repo="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
sha="$(git -C "$repo" rev-parse --verify "$tag^{commit}" 2>/dev/null)" \
|
|
|| die "tag $tag not found locally — run: git fetch --tags"
|
|
sde="$(git -C "$repo" log -1 --format=%ct "$sha")"
|
|
|
|
echo "verify: tag $tag"
|
|
echo "verify: commit $sha"
|
|
echo "verify: source_date_epoch $sde"
|
|
echo "verify: builder image $BUILDER_IMAGE"
|
|
|
|
work="$(mktemp -d)"
|
|
trap 'rm -rf "$work"' EXIT
|
|
|
|
# Export the tag, not the working tree: a dirty checkout would otherwise build
|
|
# something that was never released.
|
|
mkdir -p "$work/src" "$work/out" "$work/target"
|
|
git -C "$repo" archive "$sha" | tar -x -C "$work/src"
|
|
[ -f "$work/src/scripts/reproducible-build.sh" ] \
|
|
|| die "$tag has no scripts/reproducible-build.sh — it predates reproducible releases"
|
|
|
|
echo "verify: building (this is a full release build; expect several minutes)"
|
|
docker volume create onionwire-verify-registry >/dev/null
|
|
|
|
docker run --rm \
|
|
-v "$work/src:/src:ro" \
|
|
-v onionwire-verify-registry:/usr/local/cargo/registry \
|
|
-v "$work/target:/target" \
|
|
-v "$work/out:/out" \
|
|
-e SOURCE_DATE_EPOCH="$sde" \
|
|
-e BUILDER_IMAGE="$BUILDER_IMAGE" \
|
|
-e CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-}" \
|
|
-w /src \
|
|
"$BUILDER_IMAGE" \
|
|
bash scripts/reproducible-build.sh
|
|
|
|
sha_file="$(ls "$work"/out/*.sha256 2>/dev/null | head -1)" || true
|
|
[ -n "${sha_file:-}" ] || die "the build produced no .sha256 — see the build output above"
|
|
asset="$(basename "$sha_file" .sha256)"
|
|
|
|
mine="$(cut -d' ' -f1 < "$sha_file")"
|
|
echo "verify: rebuilt $asset"
|
|
echo "verify: rebuilt sha256 $mine"
|
|
|
|
# The published hash: an explicit path/URL if given, else the release asset.
|
|
tmp_expect="$work/expect.sha256"
|
|
if [ -n "$expect_src" ]; then
|
|
if [ -f "$expect_src" ]; then
|
|
cp "$expect_src" "$tmp_expect"
|
|
else
|
|
echo "verify: fetching $expect_src"
|
|
curl -fsSL "$expect_src" -o "$tmp_expect" \
|
|
|| die "could not fetch the published checksum from $expect_src"
|
|
fi
|
|
else
|
|
url="$RELEASE_BASE/$tag/$asset.sha256"
|
|
echo "verify: fetching $url"
|
|
curl -fsSL "$url" -o "$tmp_expect" \
|
|
|| die "could not download $url — pass the published .sha256 as the second argument instead"
|
|
fi
|
|
|
|
theirs="$(cut -d' ' -f1 < "$tmp_expect")"
|
|
echo "verify: published sha256 $theirs"
|
|
|
|
echo
|
|
if [ "$mine" = "$theirs" ]; then
|
|
echo "RESULT: MATCH — the published $asset is byte-for-byte the output of"
|
|
echo " commit $sha built with the documented recipe."
|
|
echo
|
|
echo "The rebuilt binary is at:"
|
|
echo " $work/out/$asset"
|
|
echo "(it is deleted when this script exits; copy it out first if you want it)"
|
|
# Keep the artifact for the user: the trap would remove it, so copy next to
|
|
# the caller unless they asked for a scratch run.
|
|
if [ -n "${ONIONWIRE_VERIFY_KEEP:-}" ]; then
|
|
mkdir -p "$ONIONWIRE_VERIFY_KEEP"
|
|
cp "$work/out/$asset" "$ONIONWIRE_VERIFY_KEEP/"
|
|
echo "copied to $ONIONWIRE_VERIFY_KEEP/$asset (ONIONWIRE_VERIFY_KEEP)"
|
|
fi
|
|
else
|
|
echo "RESULT: MISMATCH — the published binary does NOT match a rebuild of this tag." >&2
|
|
echo " rebuilt: $mine" >&2
|
|
echo " published: $theirs" >&2
|
|
echo >&2
|
|
echo "This is a real finding, not a glitch to shrug at. Report it, and do not" >&2
|
|
echo "run the published binary until it is explained. Two honest causes to rule" >&2
|
|
echo "out first: the release was built from a different commit than the tag, or" >&2
|
|
echo "the builder image digest moved (compare build-info-*.txt on the release)." >&2
|
|
exit 1
|
|
fi |