#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-3.0-or-later """Validate the remote-bound Phase-1.0BB source profile.""" from __future__ import annotations import argparse import hashlib import json import subprocess from pathlib import Path def git(repo: Path, *args: str) -> str: return subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True, text=True).stdout.strip() def main() -> int: parser = argparse.ArgumentParser() parser.add_argument("--root", type=Path, required=True) parser.add_argument("--retroarch-root", type=Path, required=True) args = parser.parse_args() data = json.loads((args.root / "manifests/retroarch/phase-1.0bb-source-only-launch-canary-profile.json").read_text(encoding="utf-8")) bind = data["source_bindings"] ba = args.root / "manifests/retroarch/phase-1.0ba-target-profile-callsite-audit.json" assert hashlib.sha256(ba.read_bytes()).hexdigest() == bind["phase10ba_manifest_sha256"] commit = bind["retroarch_commit"] assert git(args.retroarch_root, "rev-parse", "HEAD") == commit assert git(args.retroarch_root, "rev-parse", bind["remote_ref"]) == commit assert git(args.retroarch_root, "rev-parse", f"{commit}^") == bind["retroarch_parent_commit"] paths = {"makefile": "Makefile.ps5", "retroarch_c": "retroarch.c", "validator": "tools/validate_ps5_phase10bb.py", "tests": "tests/test_ps5_phase10bb.py", "source_doc": "docs/ps5-phase10bb-launch-canary-profile.md"} for key, source in paths.items(): assert git(args.retroarch_root, "rev-parse", f"{commit}:{source}") == bind[f"{key}_blob"] assert data["verification"]["launch_canary_artifact_absent"] assert data["authorizations"]["build_prerequisite_audit_authorized"] assert not data["authorizations"]["target_build_authorized"] assert not data["decision"]["cross_build_allowed"] print("Phase-1.0BB source-profile binding validation passed") return 0 if __name__ == "__main__": raise SystemExit(main())