stages: add org.osbuild.buildstamp
Add a stage to create a buildstamp file, which is required by anaconda to properly function, since it configures varies aspects of the installation target (product, build arch, ...).
This commit is contained in:
parent
19b330eade
commit
d61ea55f20
1 changed files with 86 additions and 0 deletions
86
stages/org.osbuild.buildstamp
Executable file
86
stages/org.osbuild.buildstamp
Executable file
|
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/python3
|
||||
"""
|
||||
Create a /.buildstamp file describing the system
|
||||
|
||||
This will create a './buildstamp' with the specified parameters.
|
||||
"""
|
||||
|
||||
import configparser
|
||||
import datetime
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": true,
|
||||
"required": ["arch", "product", "version", "final"],
|
||||
"properties": {
|
||||
"arch": {
|
||||
"description": "Build architecture.",
|
||||
"type": "string"
|
||||
},
|
||||
"product": {
|
||||
"description": "The product name.",
|
||||
"type": "string"
|
||||
},
|
||||
"version": {
|
||||
"description": "The version .",
|
||||
"type": "string"
|
||||
},
|
||||
"final": {
|
||||
"description": "The product.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"variant": {
|
||||
"description": "The variant of the product.",
|
||||
"type": "string"
|
||||
},
|
||||
"bugurl": {
|
||||
"description": "The bugurl of the product.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
buildarch = options["arch"]
|
||||
product = options["product"]
|
||||
version = options["version"]
|
||||
isfinal = options["final"]
|
||||
variant = options.get("variant")
|
||||
bugurl = options.get("bugurl")
|
||||
|
||||
now = datetime.datetime.now()
|
||||
datestr = now.strftime("%Y%m%d%H%M")
|
||||
uid = f"{datestr}.{buildarch}"
|
||||
|
||||
stamp = configparser.ConfigParser()
|
||||
stamp['Main'] = {
|
||||
"Product": product,
|
||||
"Version": version,
|
||||
"IsFinal": isfinal,
|
||||
"UUID": uid,
|
||||
}
|
||||
|
||||
if bugurl:
|
||||
stamp.set("Main", "BugURL", bugurl)
|
||||
|
||||
if variant:
|
||||
stamp.set("Main", "Variant", variant)
|
||||
|
||||
stamp["Compose"] = {
|
||||
"osbuild": "devel",
|
||||
}
|
||||
|
||||
with open(f"{tree}/.buildstamp", "w") as f:
|
||||
stamp.write(f)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
Loading…
Add table
Add a link
Reference in a new issue