stages: ensure dirs for dracut-conf stage are available

If the dracut config stage runs early the directory for the
dracut config may not be available yet. So just create it.
This commit is contained in:
Michael Vogt 2025-02-20 21:04:47 +01:00 committed by Achilleas Koutsou
parent 0849f4842c
commit 530ce4f80c
2 changed files with 19 additions and 0 deletions

View file

@ -1,4 +1,5 @@
#!/usr/bin/python3
import os
import sys
import osbuild.api
@ -32,6 +33,7 @@ def main(tree, options):
filename = options["filename"]
config_files_dir = f"{tree}/usr/lib/dracut/dracut.conf.d"
os.makedirs(config_files_dir, exist_ok=True)
SUPPORTED_OPTIONS = {
# simple string options

View file

@ -0,0 +1,17 @@
#!/usr/bin/python3
STAGE_NAME = "org.osbuild.dracut.conf"
def test_dracut_conf_smoke(tmp_path, stage_module):
options = {
"filename": "qemu.conf",
"config": {
"add_drivers": ["virtio_blk"],
}
}
tree = tmp_path / "tree"
stage_module.main(tree, options)
expected_dracut_conf = tree / "usr/lib/dracut/dracut.conf.d/qemu.conf"
assert 'add_drivers+=" virtio_blk "\n' == expected_dracut_conf.read_text()