if DROPIN.exists(): tar_make(DROPIN,c/'dropins.tar')
git_capture(MAIN,c/'git-main'); git_capture(MONTAJ,c/'git-montaj')
m={'tag':tag,'service':svc(),'hashes':hashes(),'runtime':runtime()}
m['archives']={x.name:sha(x) for x in c.glob('*.tar')}
(c/'manifest.json').write_text(json.dumps(m,indent=2))
print('CHECKPOINT_CREATE=PASS'); print('SERVICE_BASELINE='+m['service'])
print('CHECKPOINT_MB='+str(round(sum(x.stat().st_size for x in c.rglob('*') if x.is_file())/1048576,1)))
def verify(tag):
c=cp(tag); m=json.loads((c/'manifest.json').read_text()); ok=True
for n,v in m['archives'].items(): ok &= (c/n).exists() and sha(c/n)==v
for n,v in m['hashes'].items():
cur=hashes()[n]; ok &= cur==v
ok &= git_verify(MAIN,c/'git-main') and git_verify(MONTAJ,c/'git-montaj')
def stable_runtime(x):
x=dict(x)
lines=[]
for line in x.get('hermes','').splitlines():
if 'Update available:' in line:
continue
if ' · upstream ' in line and ' · local ' in line:
left, tail = line.split(' · upstream ',1)
_, local = tail.split(' · local ',1)
line = left + ' · local ' + local
lines.append(line)
x['hermes']='\n'.join(lines)
return x
r=runtime(); ok &= stable_runtime(r)==stable_runtime(m['runtime']); ok &= svc()==m['service']
print('VERIFY='+('PASS' if ok else 'FAIL')); return ok
def restore(tag):
c=cp(tag); m=json.loads((c/'manifest.json').read_text())
for n,v in m['archives'].items():
if not (c/n).exists() or sha(c/n)!=v: raise SystemExit('CORRUPT_CHECKPOINT')
git_restore(MAIN,c/'git-main'); git_restore(MONTAJ,c/'git-montaj')