#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-3.0-or-later """Validate Phase-1.0AE against exact official shsrv worktrees.""" from __future__ import annotations import argparse import hashlib import json from pathlib import Path import subprocess def sha256(path: Path) -> str: return hashlib.sha256(path.read_bytes()).hexdigest() def git(root: Path, value: str) -> str: return subprocess.run(["git", "-C", str(root), "rev-parse", value], 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("--shsrv-root", type=Path, required=True) parser.add_argument("--shsrv-v07-root", type=Path, required=True) args = parser.parse_args() data = json.loads((args.root / "manifests/retroarch/phase-1.0ae-launcher-architecture.json").read_text(encoding="utf-8")) sources = data["official_sources"] for label, root in (("v019", args.shsrv_root), ("v07", args.shsrv_v07_root)): assert git(root, "HEAD") == sources[f"{label}_commit"] assert git(root, "HEAD^{tree}") == sources[f"{label}_tree"] assert sha256(args.shsrv_root / "bundles/hbldr/hbldr.c") == sources["v019_hbldr_sha256"] assert sha256(args.shsrv_root / "elfldr.c") == sources["v019_elfldr_sha256"] assert sha256(args.shsrv_root / "pt.c") == sources["v019_pt_sha256"] assert sha256(args.shsrv_v07_root / "bundles/hbldr/main.c") == sources["v07_hbldr_sha256"] assert sha256(args.shsrv_v07_root / "elfldr.c") == sources["v07_elfldr_sha256"] assert sha256(args.shsrv_v07_root / "pt.c") == sources["v07_pt_sha256"] v019 = (args.shsrv_root / "bundles/hbldr/hbldr.c").read_text(encoding="utf-8") v07 = (args.shsrv_v07_root / "bundles/hbldr/main.c").read_text(encoding="utf-8") assert "FAKE00000" in v019 and "remount_system_ex" in v019 assert "PPSA01659" in v07 and "FAKE00000" not in v07 and "nmount" not in v07 assert data["lineage_decision"]["selected_reference"] == "OFFICIAL_SHSRV_V0_7" assert data["mandatory_policy"]["kill_existing_bigapp"] is False assert data["decision"]["target_implementation_allowed"] is False assert data["decision"]["device_action_allowed"] is False assert not any(data["authorizations"].values()) print("Phase-1.0AE launcher architecture validation passed") return 0 if __name__ == "__main__": raise SystemExit(main())