]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add fallback for older bootctl 2341/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 2 Feb 2024 08:51:45 +0000 (09:51 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 2 Feb 2024 09:35:44 +0000 (10:35 +0100)
mkosi/__init__.py
mkosi/config.py
mkosi/qemu.py

index 7cbc22d9ce45be27d5c91f915599cb49b53807aa..ac7f2e8ab5b89c5804a8ebae8f46088de7023653 100644 (file)
@@ -44,6 +44,7 @@ from mkosi.config import (
     format_tree,
     parse_config,
     summary,
+    systemd_tool_version,
     want_selinux_relabel,
     yes_no,
 )
@@ -2220,12 +2221,6 @@ def check_outputs(config: Config) -> None:
             die(f"Output path {f} exists already. (Consider invocation with --force.)")
 
 
-def systemd_tool_version(config: Config, tool: PathString) -> GenericVersion:
-    return GenericVersion(
-        run([tool, "--version"], stdout=subprocess.PIPE, sandbox=config.sandbox()).stdout.split()[2].strip("()")
-    )
-
-
 def check_tool(config: Config, *tools: PathString, reason: str, hint: Optional[str] = None) -> Path:
     tool = find_binary(*tools, root=config.tools())
     if not tool:
index 1cfbbdd45b019b8d229596a4d79252ecefa70d9d..555463861628519be45dd6af12f49abb9222407c 100644 (file)
@@ -3763,3 +3763,9 @@ def want_selinux_relabel(config: Config, root: Path, fatal: bool = True) -> Opti
     binpolicy = sorted(policies, key=lambda p: GenericVersion(p.name), reverse=True)[0]
 
     return policy, fc, binpolicy
+
+
+def systemd_tool_version(config: Config, tool: PathString) -> GenericVersion:
+    return GenericVersion(
+        run([tool, "--version"], stdout=subprocess.PIPE, sandbox=config.sandbox()).stdout.split()[2].strip("()")
+    )
index 61db95ed13b83509cf034c663e6d3cdacde7ea8e..11a50bf43bcb92df29e2f04ee28d7e9e7f9b8fca 100644 (file)
@@ -30,6 +30,7 @@ from mkosi.config import (
     QemuFirmware,
     QemuVsockCID,
     format_bytes,
+    systemd_tool_version,
     want_selinux_relabel,
 )
 from mkosi.log import die
@@ -139,8 +140,15 @@ class KernelType(StrEnum):
 
     @classmethod
     def identify(cls, config: Config, path: Path) -> "KernelType":
-        type = run(["bootctl", "kernel-identify", path],
-                   stdout=subprocess.PIPE, sandbox=config.sandbox(options=["--ro-bind", path, path])).stdout.strip()
+        if systemd_tool_version(config, "bootctl") < 253:
+            logging.warning("bootctl doesn't know kernel-identify verb, assuming 'unknown' kernel type")
+            return KernelType.unknown
+
+        type = run(
+            ["bootctl", "kernel-identify", path],
+            stdout=subprocess.PIPE,
+            sandbox=config.sandbox(options=["--ro-bind", path, path]),
+        ).stdout.strip()
 
         try:
             return cls(type)