Skip to content

Commit

Permalink
blspec.py: cleanup matching config,System.map if exists
Browse files Browse the repository at this point in the history
Installed by debian's installkernel (USE=-systemd)

Signed-off-by: Andrew Ammerlaan <[email protected]>
  • Loading branch information
Nowa-Ammerlaan committed Apr 8, 2024
1 parent 9b47e19 commit 34cfd7f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ecleankernel/layout/blspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand All @@ -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"):
Expand All @@ -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()):
Expand Down

0 comments on commit 34cfd7f

Please sign in to comment.