Some checks failed
Windows project source guards / test (push) Failing after 39s
Работа параллельной сессии, проверена перед Android v0.4.4: - prepare_core_release.py требует, чтобы Android HYSTERIA_CORE_TAG совпадал с выбранным для Windows app/vX.Y.Z (иначе — перегенерация core-patches по android/docs/CORE_UPDATE.md), и записывает hysteria в заморозку; check_core_release_freeze.py (байт-в-байт с Android) сверяет её. - Toolchain Amnezia в локе: go1.26.8 (в паре с Android GO_VERSION). Тесты заморозки/резолвера/релиза: 51 OK.
61 lines
3.3 KiB
Python
61 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Offline validation of one coordinated Windows/Android core version freeze."""
|
|
from __future__ import annotations
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
|
|
def digest(path: Path) -> str:
|
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
|
|
|
|
|
def verify(root: Path, platform: str, version: str) -> dict:
|
|
freeze = json.loads((root / "core-release-freeze.json").read_text(encoding="utf-8"))
|
|
if freeze["schema"] != 1 or freeze["releases"][platform] != version:
|
|
raise ValueError("Core freeze belongs to a different release; prepare this release first")
|
|
for name, expected in freeze["inputs"][platform].items():
|
|
path = root / name
|
|
if path.resolve().is_relative_to(root.resolve()) is False or digest(path) != expected:
|
|
raise ValueError(f"Frozen core input changed: {name}")
|
|
pin = freeze["amnezia"]
|
|
# Both platforms ship the one sing-box-extended release selected at freeze time.
|
|
core = freeze["singbox"]
|
|
# ...and the one official Hysteria release (older receipts predate this pin).
|
|
hysteria = freeze.get("hysteria")
|
|
if platform == "windows":
|
|
lock = json.loads((root / "scripts/core-lock.windows-x64.json").read_text(encoding="utf-8"))
|
|
if lock["amnezia"] != pin:
|
|
raise ValueError("Windows Amnezia differs from coordinated freeze")
|
|
if {key: lock["singbox_build"][key] for key in ("version", "commit")} != core:
|
|
raise ValueError("Windows sing-box differs from coordinated freeze")
|
|
if hysteria is not None:
|
|
source = next((item for item in lock["sources"] if item.get("id") == "hysteria"), {})
|
|
if source.get("version") != hysteria["version"]:
|
|
raise ValueError("Windows Hysteria differs from coordinated freeze")
|
|
else:
|
|
properties = dict(line.split("=", 1) for line in (root / "core.properties").read_text().splitlines() if "=" in line)
|
|
if (properties["CORE_TAG"], properties["CORE_COMMIT"]) != (core["version"], core["commit"]):
|
|
raise ValueError("Android sing-box differs from coordinated freeze")
|
|
expected = f'{pin["module"]}@{pin["version"]}'
|
|
if any(properties.get(key) != expected for key in ("ANDROID_WIREGUARD_GO", "ANDROID_AMNEZIAWG_GO")):
|
|
raise ValueError("Android Amnezia differs from coordinated freeze")
|
|
if properties["GO_VERSION"] != pin["toolchain"]["version"].removeprefix("go"):
|
|
raise ValueError("Android and Windows Go toolchains differ")
|
|
if hysteria is not None and properties.get("HYSTERIA_CORE_TAG") != hysteria["version"]:
|
|
raise ValueError(
|
|
"Android Hysteria differs from coordinated freeze: regenerate core-patches/0003 "
|
|
"for the Windows-selected release (docs/CORE_UPDATE.md)"
|
|
)
|
|
return freeze
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("platform", choices=("windows", "android"))
|
|
parser.add_argument("version")
|
|
parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1])
|
|
args = parser.parse_args()
|
|
pin = verify(args.root, args.platform, args.version)["amnezia"]
|
|
print(f'Frozen official Amnezia: {pin["version"]} @ {pin["commit"]}')
|