From: DaanDeMeyer Date: Thu, 25 Dec 2025 20:40:06 +0000 (+0100) Subject: kmod: Use same ko glob everywhere X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0fec89a676cd271ccbeaba035d923b573895a6a;p=thirdparty%2Fmkosi.git kmod: Use same ko glob everywhere --- diff --git a/mkosi/kmod.py b/mkosi/kmod.py index 875fc03d0..590f96cc3 100644 --- a/mkosi/kmod.py +++ b/mkosi/kmod.py @@ -24,6 +24,12 @@ def loaded_modules() -> list[str]: ] +def all_modules(modulesd: Path) -> Iterator[Path]: + # The glob may match additional paths. + # Narrow this down to *.ko, *.ko.gz, *.ko.xz, *.ko.zst. + return (m for m in modulesd.rglob("*.ko*") if m.name.endswith((".ko", ".ko.gz", ".ko.xz", ".ko.zst"))) + + def globs_match_filename(name: str, globs: Sequence[str], *, match_default: bool = False) -> bool: # Check whether the path matches any of the globs @@ -81,11 +87,7 @@ def filter_kernel_modules( modulesd = Path("usr/lib/modules") / kver with chdir(root): - # The glob may match additional paths. - # Narrow this down to *.ko, *.ko.gz, *.ko.xz, *.ko.zst. - modules = { - m for m in modulesd.rglob("*.ko*") if m.name.endswith((".ko", ".ko.gz", ".ko.xz", ".ko.zst")) - } + modules = set(all_modules(modulesd)) n_modules = len(modules) @@ -279,8 +281,7 @@ def resolve_module_dependencies( builtin = set() with chdir(context.root): - allmodules = set(modulesd.rglob("*.ko*")) - nametofile = {module_path_to_name(m): m for m in allmodules} + nametofile = {module_path_to_name(m): m for m in all_modules(modulesd)} todo = [*builtin, *modules] mods = set() @@ -343,7 +344,7 @@ def gen_required_kernel_modules( "No modules excluded and no firmware installed, using kernel modules generation fast path" ) with chdir(context.root): - modules = set(modulesd.rglob("*.ko*")) + modules = set(all_modules(modulesd)) firmware = set() # Include or exclude firmware explicitly configured @@ -466,7 +467,7 @@ def process_kernel_modules( with complete_step("Applying kernel module filters"): with chdir(context.root): - modules = sorted(modulesd.rglob("*.ko*"), reverse=True) + modules = sorted(all_modules(modulesd), reverse=True) firmware = sorted(firmwared.rglob("*"), reverse=True) for m in modules: