Add standalone Container Runner ref and ISO publication

This commit is contained in:
Pavel Isaev 2026-11-10 01:17:23 +03:00
parent 16aaed726e
commit 52ef3980ae

View file

@ -0,0 +1,81 @@
#!/usr/bin/env python3
"""Publish a standalone Container Runner build (D-100): refs, signed summary, ISO.
This is intentionally separate from `publish-hardware.py`: the Container Runner
edition has no acceptance scenarios and no ISO catalog entry yet, but it must still
create signed OSTree refs and expose its installation medium. Existing channels
(`stable/core`, `stable/gnome`, `stable/kde`) and the ISO catalog are not modified.
"""
import argparse
import fcntl
import importlib.util
import json
import os
from pathlib import Path
import shutil
spec = importlib.util.spec_from_file_location('publisher', Path(__file__).with_name('publish-hardware.py'))
publisher = importlib.util.module_from_spec(spec)
spec.loader.exec_module(publisher)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('public', type=Path)
parser.add_argument('build', type=Path)
parser.add_argument('--version', required=True)
parser.add_argument('--iso', type=Path, required=True)
parser.add_argument('--gpg-home', type=Path, required=True)
parser.add_argument('--gpg-key', required=True)
args = parser.parse_args()
build_repo = args.build / 'repo'
image = publisher.ostree(build_repo, 'rev-parse', 'core')
core_layer = publisher.ostree(build_repo, 'rev-parse', 'layers/core')
purpose_layer = publisher.ostree(build_repo, 'rev-parse', 'layers/purpose/server/container-runner')
iso = args.iso
sha256 = publisher.digest(iso)
with (args.public / '.publish.lock').open('a') as lock:
fcntl.flock(lock, fcntl.LOCK_EX)
current = (args.public / 'current').resolve(strict=True)
images, layers = current / 'ostree/images', current / 'ostree/layers'
publisher.ostree(images, 'pull-local', '--depth=0', str(build_repo), image)
publisher.ostree(layers, 'pull-local', '--depth=0', str(build_repo), core_layer)
publisher.ostree(layers, 'pull-local', '--depth=0', str(build_repo), purpose_layer)
publisher.ostree(images, 'refs', '--force', '--create=stable/container', image)
publisher.ostree(layers, 'refs', '--force', '--create=stable/container', core_layer)
publisher.ostree(layers, 'refs', '--force', '--create=purpose/server/container-runner', purpose_layer)
for repo in (images, layers):
publisher.ostree(repo, 'prune', '--refs-only', '--depth=0')
commits = {publisher.ostree(repo, 'rev-parse', ref)
for ref in publisher.ostree(repo, 'refs').splitlines()}
for commit in commits:
publisher.ostree(repo, 'gpg-sign', '--delete', '--gpg-homedir=' + str(args.gpg_home), commit, args.gpg_key)
publisher.ostree(repo, 'gpg-sign', '--gpg-homedir=' + str(args.gpg_home), commit, args.gpg_key)
publisher.ostree(repo, 'summary', '--update', '--gpg-sign=' + args.gpg_key,
'--gpg-homedir=' + str(args.gpg_home))
name = 'archipelago-container-runner.iso'
destination = current / 'iso/container' / args.version
destination.mkdir(parents=True, exist_ok=True)
target = destination / name
shutil.copyfile(iso, target)
if publisher.digest(target) != sha256:
raise ValueError('Copied ISO checksum mismatch')
(destination / (name + '.sha256')).write_text(sha256 + ' ' + name + '\n')
alias = current / 'iso' / name
if alias.exists():
alias.unlink()
os.link(target, alias)
(current / 'iso' / (name + '.sha256')).write_text(sha256 + ' ' + name + '\n')
record = dict(apiVersion='archipelago.container-runner/v1', version=args.version,
image_commit=image, layer_commit=core_layer,
purpose_layer_commit=purpose_layer, sha256=sha256,
size_bytes=target.stat().st_size,
url='/archipelago/iso/container/' + args.version + '/' + name,
acceptance='not requested (D-100)')
(current / 'v1').mkdir(exist_ok=True)
(current / 'v1/container-runner.json').write_text(json.dumps(record, indent=2) + '\n')
print(json.dumps(record, indent=2))
if __name__ == '__main__':
main()