44 lines
2.0 KiB
Python
44 lines
2.0 KiB
Python
#!/usr/bin/python3
|
|
"""Own fresh disk; compose bootstrap with installed-VM harness, no shared edits."""
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def main():
|
|
p = argparse.ArgumentParser(description=__doc__)
|
|
p.add_argument('--output', type=Path, required=True)
|
|
p.add_argument('--rootfs', type=Path, required=True)
|
|
p.add_argument('--receipt', type=Path, required=True)
|
|
p.add_argument('--baseline-only', action='store_true')
|
|
a = p.parse_args()
|
|
a.output.mkdir(mode=0o755, exist_ok=False)
|
|
root = Path(__file__).resolve().parents[2]
|
|
harness = root/'scripts/tests/os_ota_installed_vm.py'
|
|
results = []
|
|
def step(name, *args):
|
|
argv = [sys.executable,'-B',str(harness),'--output',str(a.output/name),*map(str,args)]
|
|
with (a.output/(name+'.log')).open('x') as log:
|
|
r = subprocess.run(argv, stdout=log, stderr=subprocess.STDOUT)
|
|
results.append(dict(name=name, exit=r.returncode, argv=argv))
|
|
(a.output/'progress.json').write_text(json.dumps(results,indent=2))
|
|
if r.returncode:
|
|
raise RuntimeError('failed '+name)
|
|
step('disk','prepare','--rootfs',a.rootfs,'--receipt',a.receipt,'--kernel-release','6.12.73+deb13-amd64')
|
|
disk = a.output/'disk/installed.raw'
|
|
step('baseline','boot','--disk',disk,'--kernel',a.output/'disk/vmlinuz-6.12.73+deb13-amd64',
|
|
'--initrd',a.output/'disk/initrd.img-6.12.73+deb13-amd64','--source-root',root,
|
|
'--guest',root/'scripts/tests/os_updater_baseline_guest.py')
|
|
step('export','export','--disk',disk,'--kernel-release','6.12.107+deb13-amd64')
|
|
if not a.baseline_only:
|
|
step('activation','boot','--disk',disk,'--kernel',a.output/'export/vmlinuz-6.12.107+deb13-amd64',
|
|
'--initrd',a.output/'export/initrd.img-6.12.107+deb13-amd64','--source-root',root,
|
|
'--guest',root/'scripts/tests/os_updater_activation_guest.py')
|
|
(a.output/'result.json').write_text(json.dumps(dict(baseline_only=a.baseline_only, results=results),indent=2))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|