From 34cfd7f82e5f4de8ddfd0a4e66489a34a8c9fadc Mon Sep 17 00:00:00 2001 From: Andrew Ammerlaan Date: Mon, 8 Apr 2024 20:30:31 +0200 Subject: [PATCH] blspec.py: cleanup matching config,System.map if exists Installed by debian's installkernel (USE=-systemd) Signed-off-by: Andrew Ammerlaan --- ecleankernel/layout/blspec.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ecleankernel/layout/blspec.py b/ecleankernel/layout/blspec.py index 69d4cde..deeb2b7 100644 --- a/ecleankernel/layout/blspec.py +++ b/ecleankernel/layout/blspec.py @@ -34,6 +34,8 @@ class BlSpecLayout(ModuleDirLayout): name_map = { 'initrd': KernelFileType.INITRAMFS, 'linux': KernelFileType.KERNEL, + 'config': KernelFileType.CONFIG, + 'System.map': KernelFileType.SYSTEM_MAP, } def __init__(self, @@ -106,7 +108,7 @@ def find_kernels(self, exclusions=exclusions, module_directory=self.root / 'lib/modules') - # collect from /boot + # collect from Type 1 ESP/ENTRY_TOKEN kernels: typing.Dict[typing.Tuple[str, str], Kernel] = {} if self.blsdir.is_dir(): for ver in os.listdir(self.blsdir): @@ -128,7 +130,7 @@ def find_kernels(self, kernels[(ver, "bls")].all_files.append( EmptyDirectory(dir_path)) - # collect from ESP/Linux + # collect from Type 2 ESP/EFI/Linux if self.ukidir.is_dir(): for file in os.listdir(self.ukidir): if not file.endswith(".efi"): @@ -149,6 +151,17 @@ def find_kernels(self, ver, module_dict, exclusions) + # Debian's installkernel also installs config and System.map + if os.path.isfile(self.ukidir / f"config-{ver}"): + kernels[(ver, "uki")].all_files.append(GenericFile( + self.ukidir / f"config-{ver}", + KernelFileType.CONFIG)) + + if os.path.isfile(self.ukidir / f"System.map-{ver}"): + kernels[(ver, "uki")].all_files.append(GenericFile( + self.ukidir / f"System.map-{ver}", + KernelFileType.SYSTEM_MAP)) + # merge unassociated modules into kernel groups for mkv, fobjs in module_dict.items(): if any(mkv == k.real_kv for k in kernels.values()):