From 09e50e3a50a91f56ef59960e968095c4b39e7bbf Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 15 Jul 2022 23:32:16 +0200 Subject: [PATCH] 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. --- mkosi/__init__.py | 9 +++----- .../resources/dpkg-reconfigure-dracut.install | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 mkosi/resources/dpkg-reconfigure-dracut.install 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 -- 2.47.2