From 5cfbc5a395e75496427ba3ad2000446f31d58672 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 11 Jul 2023 10:14:10 +0200 Subject: [PATCH] Add org.osbuild.experimental.ostree.config stage with composefs option This adds a new stage that allows you to set the experimental new `ex-integrity.composefs` option. If set to true, it means that when deploying from this repository a composefs image will be created. A value of `maybe` is also supported, which means composefs will only be created if support is built into ostree. Support for this was added in ostree 2023.4, earlier versions ignore this key. This stage uses the new prefix org.osbuild.experimental. This way users will not accidentally enable an experimental option, and allows us (and ostree) some leeway in making changes over time to this feature. --- stages/org.osbuild.experimental.ostree.config | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 stages/org.osbuild.experimental.ostree.config diff --git a/stages/org.osbuild.experimental.ostree.config b/stages/org.osbuild.experimental.ostree.config new file mode 100755 index 00000000..5b8bec63 --- /dev/null +++ b/stages/org.osbuild.experimental.ostree.config @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +""" +Change OSTree configuration experimental options + +NOTE: This stage is experimental and subject to changes + +Change the configuration for an OSTree repository. +Currently only the following values are supported: + - `integrity.composefs` + +See `ostree.repo-config(5)` for more information. +""" + +import os +import sys + +import osbuild.api +from osbuild.util import ostree + +SCHEMA = """ +"additionalProperties": false, +"required": ["repo"], +"properties": { + "repo": { + "description": "Location of the OSTree repo.", + "type": "string" + }, + "config": { + "type": "object", + "additionalProperties": false, + "description": "OSTree configuration groups", + "properties": { + "integrity": { + "type": "object", + "additionalProperties": false, + "description": "Options concerning the sysroot", + "properties": { + "composefs": { + "description": "Enable composefs image generation on deploy.", + "type": "string", + "enum": ["true", "false", "maybe"] + } + } + } + } + } +} +""" + + +def main(tree, options): + repo = os.path.join(tree, options["repo"].lstrip("/")) + integrity_options = options["config"].get("integrity", {}) + + composefs = integrity_options.get("composefs") + if composefs is not None: + ostree.cli("config", "set", "ex-integrity.composefs", composefs, repo=repo) + + +if __name__ == '__main__': + stage_args = osbuild.api.arguments() + r = main(stage_args["tree"], + stage_args["options"]) + sys.exit(r)