From f0f4751ca48a9f29f6cbcef3ace1129a43f6ad42 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 17 Feb 2021 22:23:45 +0100 Subject: [PATCH] stages: add org.osbuild.discinfo Add a new simple stage to create a .discinfo file, used by the anaconda installer. --- stages/org.osbuild.discinfo | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 stages/org.osbuild.discinfo diff --git a/stages/org.osbuild.discinfo b/stages/org.osbuild.discinfo new file mode 100755 index 00000000..3fc86607 --- /dev/null +++ b/stages/org.osbuild.discinfo @@ -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)