fix(transport): recover rover feedback and retained WireGuard routes
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
"""Package the feedback recovery fix over the exact qualified Node 98.
|
||||
|
||||
Only the rebuilt static Linux/amd64 Node executable (including its UI) and its
|
||||
source provenance change. Installer, OS dependencies and model payloads are
|
||||
preserved byte-for-byte. No board source or runtime is edited during install.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[3]
|
||||
NODE = REPO / 'apps/node-agent'
|
||||
sys.path.insert(0, str(REPO / 'scripts/packaging'))
|
||||
from debian import package # noqa: E402
|
||||
|
||||
BASE = '671d0d6324873ba6ec994624d8cdd63fffe7d4d741d18bbf3966418f012286d5'
|
||||
VERSION = '0.8.53-110'
|
||||
BINARY = 'usr/lib/mission-core-node/node-agent'
|
||||
PROVENANCE = 'usr/share/doc/mission-core-node/provenance.json'
|
||||
|
||||
|
||||
def sha(raw):
|
||||
return hashlib.sha256(raw).hexdigest()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--binary', type=Path, required=True)
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
if args.output.exists():
|
||||
raise FileExistsError("Published Node packages are immutable; select a new version")
|
||||
base = NODE / 'build/qualified-0.8.53-98/mission-core-node_0.8.53-98_amd64.deb'
|
||||
qualification = json.loads((base.parent / "qualification.json").read_text())
|
||||
assert qualification["state"] == "complete"
|
||||
assert qualification["artifacts"][base.name]["sha256"] == BASE
|
||||
raw = base.read_bytes()
|
||||
assert sha(raw) == BASE
|
||||
stream = io.BytesIO(raw)
|
||||
assert stream.read(8) == b'!<arch>\n'
|
||||
entries = {}
|
||||
while header := stream.read(60):
|
||||
size = int(header[48:58]); name = header[:16].decode().strip().rstrip('/')
|
||||
entries[name] = stream.read(size)
|
||||
if size % 2:
|
||||
stream.read(1)
|
||||
def files(name):
|
||||
with tarfile.open(fileobj=io.BytesIO(entries[name]), mode='r:gz') as archive:
|
||||
result = []
|
||||
for item in archive:
|
||||
if item.isdir():
|
||||
continue
|
||||
assert item.isfile() and item.uid == item.gid == 0
|
||||
result.append((item.name, archive.extractfile(item).read(), item.mode))
|
||||
return result
|
||||
controls, payload = files('control.tar.gz'), files('data.tar.gz')
|
||||
old = {name: data for name, data, _ in payload}
|
||||
assert BINARY in old and PROVENANCE in old
|
||||
binary = args.binary.read_bytes()
|
||||
assert binary[:6] == b'\x7fELF\x02\x01' and binary[18:20] == b'\x3e\x00'
|
||||
source_roots = [NODE/'internal', NODE/'cmd', NODE/'web', NODE/'ui/src',
|
||||
REPO/'packages/sensor-ui/src', REPO/'packages/spatial-ui/src',
|
||||
REPO/'plugins/xgrids-k1/frontend/src', REPO/'plugins/vesc/frontend/src']
|
||||
sources = [p for root in source_roots for p in root.rglob('*') if p.is_file()]
|
||||
sources += [NODE/'go.mod', NODE/'ui/package-lock.json', Path(__file__)]
|
||||
compiler = NODE/'build/_toolchain/go/bin/go'
|
||||
proof = {
|
||||
'schema': 'missioncore.node.packaging-revision/v1', 'version': VERSION,
|
||||
'qualified_base_sha256': BASE, 'qualified_base_provenance': json.loads(old[PROVENANCE]),
|
||||
'binary_sha256': sha(binary), 'binary_build_info': subprocess.check_output([str(compiler),'version','-m',str(args.binary)],text=True),
|
||||
'source_files': {str(p.relative_to(REPO)):sha(p.read_bytes()) for p in sorted(set(sources))},
|
||||
'scope': 'Preserve the expiring feedback recovery target across the first delayed echo after a short gap; preserve command guards, K1 dialogue, UI, installed dependencies and service lifecycle',
|
||||
}
|
||||
changes = {BINARY:binary,PROVENANCE:(json.dumps(proof,indent=2)+'\n').encode()}
|
||||
control = next(data for name,data,_ in controls if name == 'control')
|
||||
assert control.count(b'Version: 0.8.53-98\n') == 1
|
||||
controls = [(name,data.replace(b'Version: 0.8.53-98\n',f'Version: {VERSION}\n'.encode()) if name=='control' else data,mode) for name,data,mode in controls]
|
||||
payload = [(name,changes.get(name,data),mode) for name,data,mode in payload]
|
||||
result = package(controls,payload)
|
||||
args.output.parent.mkdir(parents=True,exist_ok=True)
|
||||
args.output.write_bytes(result)
|
||||
receipt = {'version':VERSION,'sha256':sha(result),'bytes':len(result),'base_sha256':BASE,
|
||||
'changed_payloads':{name:sha(value) for name,value in changes.items()},'installer_unchanged':True}
|
||||
(args.output.parent/'package-result.json').write_text(json.dumps(receipt,indent=2)+'\n')
|
||||
print(json.dumps(receipt))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user