| |
| """Verify the Ava release against artifact_manifest.json.""" |
|
|
| from __future__ import annotations |
|
|
| import hashlib |
| import json |
| from pathlib import Path |
|
|
|
|
| ROOT = Path(__file__).resolve().parent |
|
|
|
|
| def sha256(path: Path) -> str: |
| digest = hashlib.sha256() |
| with path.open("rb") as handle: |
| for chunk in iter(lambda: handle.read(1024 * 1024), b""): |
| digest.update(chunk) |
| return digest.hexdigest() |
|
|
|
|
| def main() -> None: |
| manifest = json.loads((ROOT / "artifact_manifest.json").read_text()) |
| for filename, expected in manifest["artifacts"].items(): |
| path = ROOT / filename |
| if not path.is_file(): |
| raise SystemExit(f"missing: {filename}") |
| actual_size = path.stat().st_size |
| actual_hash = sha256(path) |
| if actual_size != expected["bytes"]: |
| raise SystemExit( |
| f"size mismatch for {filename}: {actual_size} != {expected['bytes']}" |
| ) |
| if actual_hash != expected["sha256"]: |
| raise SystemExit( |
| f"hash mismatch for {filename}: {actual_hash} != {expected['sha256']}" |
| ) |
| print(f"ok {filename} {actual_hash}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|
|
|