stages: add support for kernel-options to bootc-install-to-fs

This commit adds support to use the `--kopt` arguments to
`bootc install to-filesystems`. It is not strictly needed right
now though.
This commit is contained in:
Michael Vogt 2024-03-12 12:14:44 +01:00
parent 626077ffc0
commit df224fb32b
2 changed files with 21 additions and 0 deletions

View file

@ -40,6 +40,13 @@ SCHEMA_2 = r"""
"type": "string"
}
},
"kernel-args": {
"description": "array of additional kernel arguments",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"devices": {
@ -70,6 +77,9 @@ def main(options, inputs, paths):
tmpf.write(key.encode("utf8") + b"\n")
tmpf.flush()
pargs.extend(["--root-ssh-authorized-keys", tmpf.name])
# customize kernel-args
for karg in options.get("kernel-args", []):
pargs.extend(["--karg", karg])
# add target and go
pargs.append(dst)
subprocess.run(pargs, check=True)

View file

@ -43,9 +43,20 @@ FAKE_INPUTS = {
@pytest.mark.parametrize("options,expected_args", [
({}, []),
# root-ssh
({"root-ssh-authorized-keys": []}, []),
({"root-ssh-authorized-keys": ["ssh-key"]}, ["--root-ssh-authorized-keys", "/tmp/fake-named-tmpfile-name"]),
({"root-ssh-authorized-keys": ["key1", "key2"]}, ["--root-ssh-authorized-keys", "/tmp/fake-named-tmpfile-name"]),
# kernel args
({"kernel-args": []}, []),
({"kernel-args": ["console=ttyS0"]}, ["--karg", "console=ttyS0"]),
({"kernel-args": ["arg1", "arg2"]}, ["--karg", "arg1", "--karg", "arg2"]),
# all
({"root-ssh-authorized-keys": ["key1", "key2"],
"kernel-args": ["arg1", "arg2"]},
["--root-ssh-authorized-keys", "/tmp/fake-named-tmpfile-name",
"--karg", "arg1", "--karg", "arg2"],
),
])
@patch("subprocess.run")
def test_bootc_install_to_fs(mock_run, mocked_named_tmp, mocked_temp_dir, stage_module, options, expected_args): # pylint: disable=unused-argument