Wait for B2 Core readiness and reconcile exact failed foundation002
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Deterministic data-only receipt for the exact B2 foundation002 incident."""
|
||||
import argparse
|
||||
import gzip
|
||||
import hashlib
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
import tarfile
|
||||
|
||||
loader = importlib.machinery.SourceFileLoader('b2_reconciliation_builder_runner', str(Path(__file__).with_name('nodedc-deploy')))
|
||||
spec = importlib.util.spec_from_loader(loader.name, loader)
|
||||
R = importlib.util.module_from_spec(spec)
|
||||
loader.exec_module(R)
|
||||
|
||||
|
||||
def build(destination):
|
||||
data = {
|
||||
'manifest.env': ('id=' + R.DEVICE_B2_RECON_ID + '\ncomponent=device-b2-foundation-reconciliation\ntype=app-overlay\n').encode(),
|
||||
'files.txt': (R.DEVICE_B2_RECON_ENTRY + '\n').encode(),
|
||||
'payload/' + R.DEVICE_B2_RECON_ENTRY: (json.dumps(R.device_b2_reconciliation_descriptor(), indent=2) + '\n').encode(),
|
||||
}
|
||||
destination = Path(destination)
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
with destination.open('xb') as output:
|
||||
with gzip.GzipFile(filename='', mode='wb', fileobj=output, mtime=0) as gz:
|
||||
with tarfile.open(fileobj=gz, mode='w', format=tarfile.PAX_FORMAT) as archive:
|
||||
for name, value in sorted(data.items()):
|
||||
member = tarfile.TarInfo(name)
|
||||
member.size = len(value)
|
||||
member.mode = 0o644
|
||||
member.mtime = 0
|
||||
archive.addfile(member, io.BytesIO(value))
|
||||
return {'id': R.DEVICE_B2_RECON_ID, 'component': 'device-b2-foundation-reconciliation',
|
||||
'artifact': str(destination), 'sha256': hashlib.sha256(destination.read_bytes()).hexdigest(),
|
||||
'entries': [R.DEVICE_B2_RECON_ENTRY], 'services': [], 'build': [], 'runtimeMutation': False}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--output', required=True)
|
||||
print(json.dumps(build(parser.parse_args().output), indent=2))
|
||||
Reference in New Issue
Block a user