Skip to content

Commit

Permalink
ecleankernel/layout: clean-up rEFInd icon files
Browse files Browse the repository at this point in the history
Closes: projg2#49
Signed-off-by: Andrew Ammerlaan <[email protected]>
  • Loading branch information
Nowa-Ammerlaan committed May 8, 2024
1 parent 1e94922 commit a7122fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ecleankernel/layout/blspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ def find_kernels(self,
# collect from ESP/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 @@ -149,6 +149,12 @@ def find_kernels(self,
ver, module_dict,
exclusions)

uki_icon = self.ukidir / f"{basename}.png"
if (KernelFileType.MISC not in exclusions and
os.path.isfile(uki_icon)):
kernels[(ver, "uki")].all_files.append(GenericFile(
uki_icon, KernelFileType.MISC))

# 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
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 a7122fd

Please sign in to comment.