Skip to content

Commit

Permalink
dnf: allow whitelisting plugins through [Host] configuration
Browse files Browse the repository at this point in the history
See-Also: systemd#700 (comment)
Signed-off-by: Jake Helmert <[email protected]>
  • Loading branch information
pbjhelmert committed Jun 4, 2024
1 parent c575b47 commit 4042011
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## v23

- Added `DNFPlugins=` to allow configuring what DNF plugins are used
for builds using DNF.
- Added `CleanScripts=` to allow running custom cleanup code whenever
mkosi cleans up the output directory. This allows cleaning up extra
outputs produced by e.g. a build script that mkosi doesn't know about.
Expand Down
9 changes: 9 additions & 0 deletions mkosi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,7 @@ class Config:
machine: Optional[str]
forward_journal: Optional[Path]
vmm: Vmm
dnf_plugins: list[str]

# QEMU-specific options
qemu_gui: bool
Expand Down Expand Up @@ -2935,6 +2936,13 @@ def parse_ini(path: Path, only_sections: Collection[str] = ()) -> Iterator[tuple
parse=config_make_path_parser(required=False),
help="Set the path used to store forwarded machine journals",
),
ConfigSetting(
dest="dnf_plugins",
metavar="BOOL",
section="Host",
parse=config_make_list_parser(delimiter=" "),
help="Specify DNF plugins to enable during the build",
),
ConfigSetting(
dest="qemu_gui",
metavar="BOOL",
Expand Down Expand Up @@ -4088,6 +4096,7 @@ def bold(s: Any) -> str:
SSH Certificate: {none_to_none(config.ssh_certificate)}
Machine: {config.machine_or_name()}
Forward Journal: {none_to_none(config.forward_journal)}
DNF Plugins: {line_join_list(config.dnf_plugins)}
Virtual Machine Monitor: {config.vmm}
QEMU GUI: {yes_no(config.qemu_gui)}
Expand Down
6 changes: 6 additions & 0 deletions mkosi/installer/dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ def cmd(
"--enable-plugin=builddep" if dnf.endswith("dnf5") else "--enableplugin=builddep",
]

for plugin in context.config.dnf_plugins:
if dnf.endswith("dnf5"):
cmdline += [f"--enable-plugin={plugin}"]
else:
cmdline += [f"--enableplugin={plugin}"]

if ARG_DEBUG.get():
cmdline += ["--setopt=debuglevel=10"]

Expand Down
2 changes: 2 additions & 0 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def test_config() -> None:
"dep1"
],
"Distribution": "fedora",
"DnfPlugins": [],
"Environment": {
"BAR": "BAR",
"Qux": "Qux",
Expand Down Expand Up @@ -390,6 +391,7 @@ def test_config() -> None:
forward_journal=Path("/mkosi.journal"),
hostname=None,
vmm=Vmm.qemu,
dnf_plugins=[],
image="default",
image_id="myimage",
image_version="5",
Expand Down

0 comments on commit 4042011

Please sign in to comment.