#!/usr/bin/env python3 import hashlib,pathlib,subprocess root=pathlib.Path('/mnt/storage/src/mosaic-stack-rocko-147-r1');out=pathlib.Path(__file__).resolve().parent tracked=subprocess.check_output(['git','diff','--name-only'],cwd=root,text=True).splitlines() new=subprocess.check_output(['git','ls-files','--others','--exclude-standard','--','packages/project','packages/cli/src/project.mjs','packages/cli/tests/project.test.mjs','packages/business/tests/project-repo.test.mjs'],cwd=root,text=True).splitlines() paths=sorted(set(tracked+new)) assert all(p.startswith(('packages/project/','packages/cli/','packages/business/','scripts/','docs/')) for p in paths) patch=subprocess.check_output(['git','diff','--binary','--no-ext-diff'],cwd=root) for path in sorted(new): p=subprocess.run(['git','diff','--no-index','--binary','--','/dev/null',path],cwd=root,stdout=subprocess.PIPE) assert p.returncode==1;patch+=p.stdout (out/'build.patch').write_bytes(patch) (out/'base.txt').write_bytes(subprocess.check_output(['git','rev-parse','HEAD'],cwd=root)) (out/'candidate-manifest.sha256').write_text(''.join(hashlib.sha256((root/p).read_bytes()).hexdigest()+' '+p+'\n' for p in paths)) print('candidate files',len(paths));print('candidate SHA',hashlib.sha256((out/'candidate-manifest.sha256').read_bytes()).hexdigest())