stages: add org.osbuild.discinfo

Add a new simple stage to create a .discinfo file, used by the
anaconda installer.
This commit is contained in:
Christian Kellner 2021-02-17 22:23:45 +01:00 committed by Tom Gundersen
parent 6e74c7f52c
commit f0f4751ca4

49
stages/org.osbuild.discinfo Executable file
View file

@ -0,0 +1,49 @@
#!/usr/bin/python3
"""
Create a `.discinfo` file describing disk
This will create a `.discinfo` file with the specified parameters.
"""
import os
import time
import sys
import osbuild.api
SCHEMA = """
"additionalProperties": true,
"required": ["basearch", "release"],
"properties": {
"basearch": {
"description": "Build architecture.",
"type": "string"
},
"release": {
"description": "The product name.",
"type": "string"
}
}
"""
def main(tree, options):
basearch = options["basearch"]
release = options["release"]
# Based on `pylorax/discinfo.py`
timestamp = time.time()
with open(os.path.join(tree, ".discinfo"), "w") as f:
f.write(f"{timestamp}\n")
f.write(f"{release}\n")
f.write(f"{basearch}\n")
return 0
if __name__ == '__main__':
args = osbuild.api.arguments()
r = main(args["tree"], args["options"])
sys.exit(r)