From: Daan De Meyer Date: Tue, 18 Mar 2025 14:54:27 +0000 (+0100) Subject: Fix KernelModulesExclude= settings X-Git-Tag: v26~313^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7bbe77991af2c22e65baf70d502ac74d8d3c811;p=thirdparty%2Fmkosi.git Fix KernelModulesExclude= settings With eecf8b3b5c43e4832a11c8718ae43e559a755829, exclude settings have started taking priority over include or the new glob settings whereas they should not. Fix the logic so the globs and include patterns always take priority over the exclude patterns. --- diff --git a/mkosi/kmod.py b/mkosi/kmod.py index 88240a099..a66f98f2e 100644 --- a/mkosi/kmod.py +++ b/mkosi/kmod.py @@ -107,7 +107,7 @@ def filter_kernel_modules( rel = os.fspath(Path(*m.parts[5:])) if (patterns and regex.search(rel)) or globs_match_module(normalize_module_name(rel), globs): - keep.add(m) + keep.add(rel) if exclude: assert all(p.startswith("re:") for p in exclude) @@ -115,16 +115,19 @@ def filter_kernel_modules( regex = re.compile("|".join(patterns)) remove = set() - for m in keep: + for m in modules: rel = os.fspath(Path(*m.parts[5:])) - if regex.search(rel): + if rel not in keep and regex.search(rel): remove.add(m) - keep -= remove + modules -= remove + else: + # If no exclude patterns are specified, only keep the specified kernel modules. + modules = {modulesd / m for m in keep} - logging.debug(f"Including {len(keep)}/{n_modules} kernel modules.") + logging.debug(f"Including {len(modules)}/{n_modules} kernel modules.") - return sorted(keep) + return sorted(modules) def filter_firmware(