]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Fix sdmagic check on CentOS
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 24 Jun 2024 11:37:29 +0000 (13:37 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 24 Jun 2024 11:37:29 +0000 (13:37 +0200)
systemd-stub on CentOS has misaligned PE sections causing us to read
a bunch of null bytes from the sdmagic section. Let's treat this case
as not finding a stub version to fix the CI builds.

mkosi/__init__.py

index 8545ed095109c7983405b015c6ad6ed95d89aa5a..3d1b6f7e2de2348cbda20468619b3d00fb308ded 100644 (file)
@@ -2234,7 +2234,14 @@ def systemd_stub_version(context: Context, stub: Path) -> Optional[GenericVersio
     except KeyError:
         return None
 
-    sdmagic_text = sdmagic.read_text()
+    sdmagic_text = sdmagic.read_text().strip("\x00")
+
+    # Older versions of the stub have misaligned sections which results in an empty sdmagic text. Let's check for that
+    # explicitly and treat it as no version.
+    # TODO: Drop this logic once every distribution we support ships systemd-stub v254 or newer.
+    if not sdmagic_text:
+        return None
+
     if not (version := re.match(r"#### LoaderInfo: systemd-stub (?P<version>[.~^a-zA-Z0-9-+]+) ####", sdmagic_text)):
         die(f"Unable to determine systemd-stub version, found {sdmagic_text!r}")