#!/usr/bin/env python3 """Builds a downloadable JackAILocal customer bundle from a manifest.""" import json, zipfile, sys, pathlib, hashlib def sha256(p): h=hashlib.sha256(); h.update(pathlib.Path(p).read_bytes()); return h.hexdigest() def main(): if len(sys.argv) != 4: print("usage: build_package.py "); sys.exit(2) seed=pathlib.Path(sys.argv[1]); manifest=pathlib.Path(sys.argv[2]); out=pathlib.Path(sys.argv[3]) excluded_dirs={'.git','target','workspace','diagnostics','.jackailocal','.jackailocal-builder','__pycache__','license-keys'} excluded_files={'config/update-private-key.xml'} with zipfile.ZipFile(out, 'w', zipfile.ZIP_DEFLATED) as z: for p in seed.rglob('*'): rel=p.relative_to(seed).as_posix() if p.is_file() and not any(part in excluded_dirs for part in p.parts) and rel not in excluded_files and not p.name.endswith('.pyc'): z.write(p, p.relative_to(seed)) z.write(manifest, 'manifest/build-manifest.json') print(out, sha256(out)) if __name__ == '__main__': main()