StreamPA / scripts /verify_bundle.py
faeea's picture
Release frozen StreamPA seed 1337 with validated standalone inference
f8a1702 verified
Raw
History Blame Contribute Delete
867 Bytes
"""Verify every published entity against the release SHA256SUMS."""
import argparse
import hashlib
from pathlib import Path
def verify(root):
root=Path(root).resolve(); count=0
for row in (root/'SHA256SUMS').read_text().splitlines():
digest,name=row.split(' ',1); path=(root/name).resolve()
if root not in path.parents: raise ValueError('Invalid manifest path')
h=hashlib.sha256()
with path.open('rb') as f:
for block in iter(lambda:f.read(1048576),b''): h.update(block)
if h.hexdigest()!=digest: raise RuntimeError(f'Checksum mismatch: {name}')
count+=1
print(f'PASS: {count} published files verified')
return count
if __name__=='__main__':
p=argparse.ArgumentParser(); p.add_argument('--bundle-dir',default=Path(__file__).resolve().parents[1])
verify(p.parse_args().bundle_dir)