From: Daan De Meyer Date: Mon, 24 Jun 2024 11:37:29 +0000 (+0200) Subject: Fix sdmagic check on CentOS X-Git-Tag: v24~86^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=692ac170be0d73c3a293271ee4137f4d43c6958f;p=thirdparty%2Fmkosi.git Fix sdmagic check on CentOS 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 8545ed095..3d1b6f7e2 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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[.~^a-zA-Z0-9-+]+) ####", sdmagic_text)): die(f"Unable to determine systemd-stub version, found {sdmagic_text!r}")