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.
This commit is contained in:
Alexander Larsson 2023-07-11 10:14:10 +02:00 committed by Simon de Vlieger
parent 9d7bbd674f
commit 5cfbc5a395

View file

@ -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)