#!/usr/bin/env python3 import hashlib, pathlib, subprocess root = pathlib.Path('/mnt/storage/src/mosaic-stack-rocko-138-r3b') out = pathlib.Path(__file__).resolve().parent tracked = subprocess.check_output(['git','diff','HEAD','--name-only'],cwd=root,text=True).splitlines() new = subprocess.check_output(['git','ls-files','--others','--exclude-standard','--','packages/project','packages/bus','packages/harness','packages/business'],cwd=root,text=True).splitlines() paths = sorted(set(tracked + new)) patch = subprocess.check_output(['git','diff','HEAD','--binary','--no-ext-diff'],cwd=root) for path in sorted(new): result = subprocess.run(['git','diff','--no-index','--binary','--','/dev/null',path],cwd=root,stdout=subprocess.PIPE) assert result.returncode == 1 patch += result.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 paths',len(paths)) print('candidate SHA',hashlib.sha256((out/'candidate-manifest.sha256').read_bytes()).hexdigest())