stages: add mkfs.xfs stage
This commit is contained in:
parent
f93dd9c397
commit
819a094bc1
1 changed files with 65 additions and 0 deletions
65
stages/org.osbuild.mkfs.xfs
Executable file
65
stages/org.osbuild.mkfs.xfs
Executable file
|
|
@ -0,0 +1,65 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
"""
|
||||||
|
Construct an XFS file-system via mkfs.xfs(8)
|
||||||
|
|
||||||
|
Construct a XFS file-system with the given options at the device
|
||||||
|
specified via `device`.
|
||||||
|
|
||||||
|
Buildhost commands used: `mkfs.xfs`.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
import osbuild.api
|
||||||
|
|
||||||
|
|
||||||
|
SCHEMA_2 = r"""
|
||||||
|
"devices": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": true,
|
||||||
|
"required": ["device"],
|
||||||
|
"properties": {
|
||||||
|
"device": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": ["uuid"],
|
||||||
|
"properties": {
|
||||||
|
"uuid": {
|
||||||
|
"description": "UUID for the file system",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"label": {
|
||||||
|
"description": "Label for the file system",
|
||||||
|
"type": "string",
|
||||||
|
"maxLength": 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def main(devices, options):
|
||||||
|
device = devices["device"]["path"]
|
||||||
|
|
||||||
|
uuid = options["uuid"]
|
||||||
|
label = options.get("label")
|
||||||
|
opts = []
|
||||||
|
|
||||||
|
if label:
|
||||||
|
opts = ["-L", label]
|
||||||
|
|
||||||
|
subprocess.run(["mkfs.xfs", "-m", f"uuid={uuid}"] + opts + [device],
|
||||||
|
encoding='utf-8', check=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
args = osbuild.api.arguments()
|
||||||
|
ret = main(args["devices"], args["options"])
|
||||||
|
sys.exit(ret)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue