From 617c30409a5b463abcc64c6fac5528044bd8cdec 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 OpenRC machines are not guaranteed to have the machine-id Closes: https://github.com/projg2/eclean-kernel/issues/55 Signed-off-by: Andrew Ammerlaan --- ecleankernel/layout/blspec.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ecleankernel/layout/blspec.py b/ecleankernel/layout/blspec.py index 4e2e841..0a2aa64 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 + + 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 = distro_id for d in self.potential_dirs: # Present if type 1 @@ -137,8 +138,6 @@ 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}-") if basename == ver: