#!/usr/bin/env python3 import hashlib,pathlib,subprocess root=pathlib.Path('/mnt/storage/src/mosaic-stack-rocko-49');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/bus/src','packages/bus/tests','packages/tasks/tests'],cwd=root,text=True).splitlines() paths=sorted(set(tracked+new)) assert all(p.startswith(('packages/bus/','packages/tasks/','scripts/land-work/')) for p in paths) patch=subprocess.check_output(['git','diff','--binary','--no-ext-diff'],cwd=root) for path in sorted(new): r=subprocess.run(['git','diff','--no-index','--binary','--','/dev/null',path],cwd=root,stdout=subprocess.PIPE) assert r.returncode==1 patch+=r.stdout (out/'build.patch').write_bytes(patch) (out/'candidate-manifest.sha256').write_text(''.join(hashlib.sha256((root/p).read_bytes()).hexdigest()+' '+p+'\n' for p in paths)) (out/'base.txt').write_bytes(subprocess.check_output(['git','rev-parse','HEAD'],cwd=root)) print('candidate files',len(paths),'manifest sha',hashlib.sha256((out/'candidate-manifest.sha256').read_bytes()).hexdigest())