File size: 1,010 Bytes
1d60d59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
"""Verify the SHA-256 manifest for the STRATA Native LM v1 release."""

from __future__ import annotations

import hashlib
from pathlib import Path


def digest(path: Path) -> str:
    value = hashlib.sha256()
    with path.open("rb") as handle:
        for block in iter(lambda: handle.read(1024 * 1024), b""):
            value.update(block)
    return value.hexdigest()


def main() -> None:
    root = Path(__file__).resolve().parent
    manifest = root / "MANIFEST.sha256"
    failures: list[str] = []
    entries = 0
    for line in manifest.read_text(encoding="utf-8").splitlines():
        if not line:
            continue
        expected, relative = line.split("  ", 1)
        path = root / relative
        entries += 1
        if not path.is_file() or digest(path) != expected:
            failures.append(relative)
    if failures:
        raise SystemExit(f"verification failed: {failures}")
    print(f"VERIFIED {entries} files")


if __name__ == "__main__":
    main()