Skip to content

Commit

Permalink
ecleankernel/layout: clean-up rEFInd icon files
Browse files Browse the repository at this point in the history
Closes: #49
Signed-off-by: Andrew Ammerlaan <[email protected]>
  • Loading branch information
Nowa-Ammerlaan committed Apr 23, 2024
1 parent 2ebf702 commit 65ca12e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
30 changes: 16 additions & 14 deletions ecleankernel/layout/blspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ def find_kernels(self,
# collect from Type 2 ESP/EFI/Linux
if self.ukidir.is_dir():
for file in os.listdir(self.ukidir):
if not file.endswith(".efi"):
basename = file.removesuffix('.efi')
if file == basename:
# Not an UKI
continue

ver = file.removeprefix(f"{self.kernel_id}-"
).removeprefix("gentoo-")
if file == ver:
ver = basename.removeprefix(f"{self.kernel_id}-"
).removeprefix("gentoo-")
if basename == ver:
# Not our UKI
continue
ver = ver.removesuffix(".efi")

kernels[(ver, "uki")] = self.append_kernel_files(
KernelFileType.KERNEL,
Expand All @@ -151,16 +151,18 @@ 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))
uki_map = {
f"config-{ver}": KernelFileType.CONFIG,
f"System.map-{ver}": KernelFileType.SYSTEM_MAP,
f"{basename}.png": KernelFileType.MISC,
}

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))
for fn, ftype in uki_map.items():
if ftype in exclusions:
continue
elif os.path.isfile(self.ukidir / fn):
kernels[(ver, "uki")].all_files.append(GenericFile(
self.ukidir / fn, ftype))

# merge unassociated modules into kernel groups
for mkv, fobjs in module_dict.items():
Expand Down
6 changes: 6 additions & 0 deletions ecleankernel/layout/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class StdLayout(ModuleDirLayout):
'.lz',
'.xz',

# refind
'.png',

# efistub
'.efi',
]
Expand Down Expand Up @@ -105,6 +108,9 @@ def find_std_files() -> typing.Iterator:
except UnrecognizedKernelError:
# fall back to filename
for ftype, prefix in self.prefixes:
# kernel refind icon has same name as kernel +'.png'
if fn.endswith('.png'):
ftype = KernelFileType.MISC
if ftype not in exclusions:
if fn.startswith(prefix):
other_files.append(
Expand Down

0 comments on commit 65ca12e

Please sign in to comment.