stages: add org.osbuild.ostree.config
Change OSTree configuration for a repository via `ostree config`.
This commit is contained in:
parent
ee124df336
commit
d793ffd805
1 changed files with 72 additions and 0 deletions
72
stages/org.osbuild.ostree.config
Executable file
72
stages/org.osbuild.ostree.config
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/python3
|
||||
"""
|
||||
Change OSTree configuration
|
||||
|
||||
Change the configuration for an OSTree repository.
|
||||
Currently only the following values are supported:
|
||||
- `sysroot.readonly`
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
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": {
|
||||
"sysroot": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Options concerning the sysroot",
|
||||
"properties": {
|
||||
"readonly": {
|
||||
"description": "Read only sysroot and boot",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def ostree(*args, _input=None, **kwargs):
|
||||
args = list(args) + [f'--{k}={v}' for k, v in kwargs.items()]
|
||||
print("ostree " + " ".join(args), file=sys.stderr)
|
||||
subprocess.run(["ostree"] + args,
|
||||
encoding="utf-8",
|
||||
stdout=sys.stderr,
|
||||
input=_input,
|
||||
check=True)
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
repo = os.path.join(tree, options["repo"].lstrip("/"))
|
||||
config = options["config"]
|
||||
|
||||
for group, items in config.items():
|
||||
for key, value in items.items():
|
||||
name = f"{group}.{key}"
|
||||
ostree("config", "set", name, str(value),
|
||||
repo=repo)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
stage_args = osbuild.api.arguments()
|
||||
r = main(stage_args["tree"],
|
||||
stage_args["options"])
|
||||
sys.exit(r)
|
||||
Loading…
Add table
Add a link
Reference in a new issue