29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Verify the checked-in source snapshots against their reviewed import manifests."""
|
|
from pathlib import Path
|
|
import hashlib
|
|
import json
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
def main():
|
|
total = 0
|
|
for manifest in sorted((ROOT / 'third_party/manifests').glob('*.json')):
|
|
record = json.loads(manifest.read_text())
|
|
directory = ROOT / record['directory']
|
|
actual = {p.relative_to(directory).as_posix(): hashlib.sha256(p.read_bytes()).hexdigest()
|
|
for p in directory.rglob('*') if p.is_file()}
|
|
expected = record['vendoredFileSHA256']
|
|
if actual != expected:
|
|
changed = sorted(k for k in actual.keys() | expected.keys() if actual.get(k) != expected.get(k))
|
|
raise SystemExit(f"{record['project']}: unexpected files or content: {changed}")
|
|
if any((directory / p).exists() for p in record['excludedFiles']):
|
|
raise SystemExit(f"{record['project']}: excluded source was reintroduced")
|
|
print(f"PASS {record['project']} {record['version']}: {len(actual)} files")
|
|
total += len(actual)
|
|
print(f'PASS: {total} reviewed source files; no downloaded binaries or ROMs required')
|
|
|
|
if __name__ == '__main__':
|
|
main()
|