From f1ab67e17b68033a624c03112ad0f88dce37b868 Mon Sep 17 00:00:00 2001 From: Andrew Ammerlaan Date: Sat, 5 Oct 2024 12:36:02 +0200 Subject: [PATCH] layout/blspec.py: consider bls named after ID from os-release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OpenRC machines are not guaranteed to have the machine-id Closes: https://github.com/projg2/eclean-kernel/issues/55 Signed-off-by: Andrew Ammerlaan Closes: https://github.com/projg2/eclean-kernel/pull/56 Signed-off-by: Michał Górny --- ecleankernel/layout/blspec.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ecleankernel/layout/blspec.py b/ecleankernel/layout/blspec.py index 4e2e841..405f861 100644 --- a/ecleankernel/layout/blspec.py +++ b/ecleankernel/layout/blspec.py @@ -41,8 +41,9 @@ def __init__(self, root: Path ) -> None: super().__init__(root) - # TODO: according to bootctl(1), we should fall back to IMAGE_ID= - # and then ID= from os-release + + self.distro_id = distro.id() or "linux" + for path in ("etc/kernel/entry-token", "etc/machine-id"): try: with open(root / path) as f: @@ -51,7 +52,7 @@ def __init__(self, except FileNotFoundError: pass else: - raise LayoutNotFound("/etc/machine-id not found") + self.kernel_id = self.distro_id for d in self.potential_dirs: # Present if type 1 @@ -137,10 +138,9 @@ def find_kernels(self, # Not an UKI continue - distro_id = distro.id() or "linux" - ver = basename.removeprefix(f"{self.kernel_id}-" - ).removeprefix(f"{distro_id}-") + ).removeprefix(f"{self.distro_id}-" + ) if basename == ver: # Not our UKI continue