Skip to content

Commit

Permalink
kickstart: add support for "zerombr","clearpart"
Browse files Browse the repository at this point in the history
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. Similarly `disklabel` also needs to exclude
` ` or one could write:
```
{"disklabel": "foo --unknown-option-that-confuses-kickstart"}
```
  • Loading branch information
mvo5 committed Nov 3, 2023
1 parent 73dc9fe commit f423a61
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion stages/org.osbuild.kickstart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from typing import Dict, List

import osbuild.api

SCHEMA = """
SCHEMA = r"""
"additionalProperties": false,
"required": ["path"],
"properties": {
Expand Down Expand Up @@ -131,6 +131,45 @@ 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",
"pattern": "^[A-Za-z0-9_-]+$"
},
"linux": {
"description": "Erases all Linux partitions",
"type": "boolean"
}
}
}
}
"""
Expand Down Expand Up @@ -233,6 +272,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 is not None:
cmd = "clearpart"
all = clearpart.get("all", False)
if all:
cmd += " --all"
drives = clearpart.get("drives", [])
if drives:
cmd += f" --drives={','.join(drives)}"
list = clearpart.get("list", [])
if list:
cmd += f" --list={','.join(list)}"
disklabel = clearpart.get("disklabel", "")
if disklabel:
cmd += f" --disklabel={disklabel}"
linux = clearpart.get("linux", False)
if linux:
cmd += f" --linux"
config += [cmd]

target = os.path.join(tree, path)
base = os.path.dirname(target)
Expand Down

0 comments on commit f423a61

Please sign in to comment.