]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Make grub EFI logic architecture independent
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 14 Jan 2025 09:18:48 +0000 (10:18 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 14 Jan 2025 12:20:23 +0000 (13:20 +0100)
Fixes #3352

mkosi/bootloader.py
mkosi/config.py

index 9e9ea3d6ba2a6348c16ffdac4874dc2fa093fad5..d2a4c9022786d3de48622c101a252dfde67eb97a 100644 (file)
@@ -72,8 +72,11 @@ def want_grub_efi(context: Context) -> bool:
     if context.config.bootloader != Bootloader.grub:
         return False
 
+    if not (arch := context.config.architecture.to_grub()):
+        return False
+
     if context.config.shim_bootloader != ShimBootloader.signed:
-        have = find_grub_directory(context, target="x86_64-efi") is not None
+        have = find_grub_directory(context, target=f"{arch}-efi") is not None
         if not have and context.config.bootable == ConfigFeature.enabled:
             die("An EFI bootable image with grub was requested but grub for EFI is not installed")
 
@@ -339,7 +342,13 @@ def install_grub(context: Context) -> None:
             else:
                 sbat = None
 
-            grub_mkimage(context, target="x86_64-efi", output=output, modules=("chain",), sbat=sbat)
+            grub_mkimage(
+                context,
+                target=f"{context.config.architecture.to_grub()}-efi",
+                output=output,
+                modules=("chain",),
+                sbat=sbat,
+            )
             if context.config.secure_boot:
                 sign_efi_binary(context, output, output)
 
index 9c7e866ce36a1c167ec5a15918e1a402d9874152..8ef2c15fbe070fb4a6a9b3a1fc9de5b653a1c0b5 100644 (file)
@@ -422,6 +422,14 @@ class Architecture(StrEnum):
             Architecture.loongarch64: "loongarch64",
         }.get(self)  # fmt: skip
 
+    def to_grub(self) -> Optional[str]:
+        return {
+            Architecture.x86_64: "x86_64",
+            Architecture.x86:    "i386",
+            Architecture.arm64:  "arm64",
+            Architecture.arm:    "arm",
+        }.get(self)  # fmt: skip
+
     def to_qemu(self) -> str:
         a = {
             Architecture.alpha:       "alpha",