]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
qemu/vmspawn: check for an uncompressed kernel too
authorLuca Boccassi <bluca@debian.org>
Sun, 16 Jun 2024 22:34:02 +0000 (23:34 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 17 Jun 2024 14:38:00 +0000 (15:38 +0100)
On some architecture/distributions (eg: ppc64el and riscv64 on Debian/Ubuntu)
the kernel is shipped uncompressed, as vmlinux. If vmlinuz cannot be found,
try looking for vmlinux.

mkosi/__init__.py

index c235b2d9fec38533f5832ddb8d468429740f950e..a91da37b081ac64d931504d6b2a928d13234630d 100644 (file)
@@ -1692,15 +1692,18 @@ def gzip_binary(context: Context) -> str:
 
 
 def fixup_vmlinuz_location(context: Context) -> None:
-    for d in context.root.glob("boot/vmlinuz-*"):
-        kver = d.name.removeprefix("vmlinuz-")
-        vmlinuz = context.root / "usr/lib/modules" / kver / "vmlinuz"
-        # Some distributions (OpenMandriva) symlink /usr/lib/modules/<kver>/vmlinuz to /boot/vmlinuz-<kver>, so get rid
-        # of the symlink and copy the actual vmlinuz to /usr/lib/modules/<kver>.
-        if vmlinuz.is_symlink() and vmlinuz.is_relative_to("/boot"):
-            vmlinuz.unlink()
-        if not vmlinuz.exists():
-            shutil.copy2(d, vmlinuz)
+    # Some architectures ship an uncompressed vmlinux (ppc64el, riscv64)
+    for type in ("vmlinuz", "vmlinux"):
+        for d in context.root.glob(f"boot/{type}-*"):
+            kver = d.name.removeprefix(f"{type}-")
+            vmlinuz = context.root / "usr/lib/modules" / kver / f"{type}"
+            # Some distributions (OpenMandriva) symlink /usr/lib/modules/<kver>/vmlinuz to /boot/vmlinuz-<kver>, so
+            # get rid of the symlink and copy the actual vmlinuz to /usr/lib/modules/<kver>.
+            if vmlinuz.is_symlink() and vmlinuz.is_relative_to("/boot"):
+                vmlinuz.unlink()
+            if not vmlinuz.exists():
+                # Rename vmlinux -> vmlinuz when copying
+                shutil.copy2(d, vmlinuz.with_name("vmlinuz"))
 
 
 def gen_kernel_images(context: Context) -> Iterator[tuple[str, Path]]:
@@ -1715,11 +1718,18 @@ def gen_kernel_images(context: Context) -> Iterator[tuple[str, Path]]:
         # Make sure we look for anything that remotely resembles vmlinuz, as
         # the arch specific install scripts in the kernel source tree sometimes
         # do weird stuff. But let's make sure we're not returning UKIs as the
-        # UKI on Fedora is named vmlinuz-virt.efi.
+        # UKI on Fedora is named vmlinuz-virt.efi. Also look for uncompressed
+        # images (vmlinux) as some architectures ship those. Prefer vmlinuz if
+        # both are present.
         for kimg in kver.glob("vmlinuz*"):
             if KernelType.identify(context.config, kimg) != KernelType.uki:
                 yield kver.name, kimg
                 break
+        else:
+            for kimg in kver.glob("vmlinux*"):
+                if KernelType.identify(context.config, kimg) != KernelType.uki:
+                    yield kver.name, kimg
+                    break
 
 
 def want_initrd(context: Context) -> bool: