stages/ostree: add ref support

Add a new optional `ref` option. When set, a references for the
commit that was pulled with the value of `ref` will be created
in the system ostree repo. It will also be used when deploying
the commit and thus will be set as the origin for it. This is
necessary for updates to work.
This commit is contained in:
Christian Kellner 2020-03-25 19:40:46 +01:00 committed by David Rheinsberg
parent cc01eb3a0e
commit 3eea0668f9

View file

@ -42,6 +42,10 @@ STAGE_OPTS = """
"description": "Additional kernel command line options",
"type": "string"
},
"ref": {
"description": "OStree ref to create and use for deployment",
"type": "string"
},
"rootfs": {
"description": "Identifier to locate the root file system",
"type": "string"
@ -104,18 +108,23 @@ def main(tree, sources, options):
rootfs = options["rootfs"]
mounts = options.get("mounts", [])
kopts = options.get("kernel_opts", [])
print(f"Fetching ostree commit {commit}")
osbuild.sources.get("org.osbuild.ostree", [commit])
ref = options.get("ref", commit)
ostree("admin", "init-fs", "--modern", tree,
sysroot=tree)
ostree("pull-local",
f"{sources}/org.osbuild.ostree/repo",
commit,
print(f"Fetching ostree commit {commit}")
osbuild.sources.get("org.osbuild.ostree", [commit])
source_repo = f"{sources}/org.osbuild.ostree/repo"
ostree("pull-local", source_repo, commit,
repo=f"{tree}/ostree/repo")
if ref != commit:
ostree("refs", "--create", ref, commit,
repo=f"{tree}/ostree/repo")
ostree("admin", "os-init", osname, sysroot=tree)
kargs = []
@ -129,7 +138,7 @@ def main(tree, sources, options):
os.makedirs(path, exist_ok=True) # FIXME: SELinux
mounter.mount(path, path)
ostree("admin", "deploy", commit,
ostree("admin", "deploy", ref,
f"--karg=root={rootfs}",
*kargs,
sysroot=tree,