From: Daan De Meyer Date: Fri, 15 Jul 2022 21:32:16 +0000 (+0200) Subject: Move debian/ubuntu kernel-install workaround to a kernel-install script X-Git-Tag: v14~105^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1060%2Fhead;p=thirdparty%2Fmkosi.git Move debian/ubuntu kernel-install workaround to a kernel-install script Instead of manually running dpkg-reconfigure dracut in mkosi. Let's drop in a kernel install script that runs dpkg-reconfigure dracut. We can install this script as part of the install function and get rid of a distribution specific check. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index b18bd9cde..cb12a8e81 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -2811,6 +2811,9 @@ def install_debian_or_ubuntu(args: MkosiArgs, root: Path, *, do_run_build_script if "bios" in args.boot_protocols or ("linux" in args.boot_protocols and "uefi" not in args.boot_protocols): root.joinpath("boot", args.machine_id).mkdir(mode=0o700) + write_resource(root / "etc/kernel/install.d/50-mkosi-dpkg-reconfigure-dracut.install", + "mkosi.resources", "dpkg-reconfigure-dracut.install", executable=True) + @complete_step("Installing Debian…") def install_debian(args: MkosiArgs, root: Path, do_run_build_script: bool) -> None: @@ -7213,12 +7216,6 @@ def run_kernel_install(args: MkosiArgs, root: Path, do_run_build_script: bool, f return with complete_step("Generating initramfs images…"): - # Running kernel-install on Debian/Ubuntu doesn't regenerate the initramfs. Instead, we can trigger - # regeneration of the initramfs via "dpkg-reconfigure dracut". kernel-install can then be called to put - # the generated initrds in the right place. - if args.distribution in (Distribution.debian, Distribution.ubuntu): - run_workspace_command(args, root, ["dpkg-reconfigure", "dracut"]) - for kver, kimg in gen_kernel_images(args, root): run_workspace_command(args, root, ["kernel-install", "add", kver, Path("/") / kimg], env=args.environment) diff --git a/mkosi/resources/dpkg-reconfigure-dracut.install b/mkosi/resources/dpkg-reconfigure-dracut.install new file mode 100644 index 000000000..8b7f81705 --- /dev/null +++ b/mkosi/resources/dpkg-reconfigure-dracut.install @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +COMMAND="${1:?}" + +case "$COMMAND" in + add) + if [ "$#" -ge 5 ]; then + # An explicit initrd path was passed so no need to regenerate the default initrd. + exit 0 + fi + + # Running kernel-install on Debian/Ubuntu doesn't regenerate the initramfs. Instead, we can trigger + # regeneration of the initramfs via "dpkg-reconfigure dracut". + dpkg-reconfigure dracut + ;; + *) + exit 0 + ;; +esac