Skip to content

Commit 05f3986

Browse files
committed
Don't discard ordering of include/exclude entries in KernelModules=
Since eecf8b3 `KernelModules=` supports both inclusion and exclusion of kmods. When resolving kmod presets like "default" and "host" (and perhaps others in the future) it's important to retain the ordering of entries, so that the user can add a preset and then subtract only specific modules from the working set. `filter_kernel_modules` relies on this ordering to do its job.
1 parent 4bdb47b commit 05f3986

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

mkosi/__init__.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,19 +1491,21 @@ def build_microcode_initrd(context: Context) -> list[Path]:
14911491
return [microcode]
14921492

14931493

1494-
def finalize_kernel_modules_include(context: Context, *, include: Sequence[str], host: bool) -> set[str]:
1495-
final = {i for i in include if i not in ("default", "host")}
1496-
if "default" in include:
1497-
with chdir(context.resources / "mkosi-initrd"):
1498-
# TODO: figure out a way to propagate all relevant settings, not just arch
1499-
_, _, [initrd] = parse_config(
1500-
["--architecture", str(context.config.architecture)],
1501-
resources=context.resources,
1502-
)
1503-
final.update(initrd.kernel_modules_include)
1504-
if host or "host" in include:
1505-
final.update(loaded_modules())
1506-
1494+
def finalize_kernel_modules_include(context: Context, *, include: Sequence[str], host: bool) -> list[str]:
1495+
final = []
1496+
for patt in include:
1497+
if "default" in patt:
1498+
with chdir(context.resources / "mkosi-initrd"):
1499+
# TODO: figure out a way to propagate all relevant settings, not just arch
1500+
_, _, [initrd] = parse_config(
1501+
["--architecture", str(context.config.architecture)],
1502+
resources=context.resources,
1503+
)
1504+
final.extend(initrd.kernel_modules_include)
1505+
elif host or "host" in patt:
1506+
final.extend(loaded_modules())
1507+
else:
1508+
final.append(patt)
15071509
return final
15081510

15091511

0 commit comments

Comments
 (0)