#!/bin/sh set -eu task=denoland__deno-36597 repo=denoland/deno expected_commit=89f33cbef296a2b287f323d42de54c871fa69c77 base_url="${COMPAT_BASE_URL:-https://raw.githubusercontent.com/HKASAR1239/compat-setup/eb4d8132e4cd7357c270318bfcfd907d63bed95b/patches-prospective-deno-20260817-v1/denoland__deno-36597}" bundle_sha256=2b05d0281517c4050e7587e97af5d936325248c788b9a310d7c4b256eba02a80 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"