From a924f1a0824ae701a4fa0bbb957aef01d4025ed3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Nov 2023 16:32:19 +0100 Subject: [PATCH] kickstart: add support for "zerombr","clearpart" Add support for the kickstart options: - zerombr - clearpart Note that for clearpart the `drives` and `list` options have a regexp pattern to limit the valid inputs. In theory we could only exclude the `,` here as this is used in the kickstart config as the list delimiter. --- stages/org.osbuild.kickstart | 63 +++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/stages/org.osbuild.kickstart b/stages/org.osbuild.kickstart index e7a6adfe6c..10878b5800 100755 --- a/stages/org.osbuild.kickstart +++ b/stages/org.osbuild.kickstart @@ -16,7 +16,7 @@ from typing import Dict, List import osbuild.api -SCHEMA = """ +SCHEMA = r""" "additionalProperties": false, "required": ["path"], "properties": { @@ -131,6 +131,44 @@ SCHEMA = """ "timezone": { "type": "string", "description": "The timezone (e.g. UTC)" + }, + "zerombr": { + "type": "boolean", + "description": "Reinitialize Partition Tables" + }, + "clearpart": { + "description": "Removes partitions from the system, prior to creation of new partitions", + "type": "object", + "properties": { + "all": { + "description": "Erases all partitions from the system", + "type": "boolean" + }, + "drives": { + "description": "Specifies which drives to clear partitions from", + "type": "array", + "items": { + "type": "string", + "pattern": "^[A-Za-z0-9/:\\_|*-]+$" + } + }, + "list": { + "description": "Specifies which partitions to clear", + "type": "array", + "items": { + "type": "string", + "pattern": "^[A-Za-z0-9]+$" + } + }, + "disklabel": { + "description": "Create a set disk label when relabeling a disk", + "type": "string" + }, + "linux": { + "description": "Erases all Linux partitions", + "type": "boolean" + } + } } } """ @@ -233,6 +271,29 @@ def main(tree, options): tz = options.get("timezone") if tz: config += [f"timezone {tz}"] + zerombr = options.get("zerombr") + if zerombr: + config += ["zerombr"] + + clearpart = options.get("clearpart") + if clearpart: + cmd = "clearpart" + all = clearpart["all"] + if all: + cmd += " --all" + drives = clearpart["drives"] + if drives: + cmd += f" --drives={','.join(drives)}" + list = clearpart["list"] + if list: + cmd += f" --list={','.join(list)}" + disklabel = clearpart["disklabel"] + if disklabel: + cmd += f" --disklabel={disklabel}" + linux = clearpart["linux"] + if linux: + cmd += f" --linux={linux}" + config += [cmd] target = os.path.join(tree, path) base = os.path.dirname(target)