From: Luca Boccassi Date: Sun, 16 Jun 2024 22:34:02 +0000 (+0100) Subject: qemu/vmspawn: check for an uncompressed kernel too X-Git-Tag: v24~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6972f9efba5c8472d990be3783b7e7dbf76e109e;p=thirdparty%2Fmkosi.git qemu/vmspawn: check for an uncompressed kernel too 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. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index c235b2d9f..a91da37b0 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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//vmlinuz to /boot/vmlinuz-, so get rid - # of the symlink and copy the actual vmlinuz to /usr/lib/modules/. - 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//vmlinuz to /boot/vmlinuz-, so + # get rid of the symlink and copy the actual vmlinuz to /usr/lib/modules/. + 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: