From: Daan De Meyer Date: Tue, 14 Feb 2023 20:47:01 +0000 (+0100) Subject: Handle older versions of kernel-install X-Git-Tag: v15~325^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8180a9877f33cc33fd6131366f03e43f3d365f80;p=thirdparty%2Fmkosi.git Handle older versions of kernel-install Older versions of kernel-install unconditionally write the initrd to /boot//. Let's detect that and move it to the correct location. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 4939d70eb..12daa9af4 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3077,6 +3077,14 @@ def run_kernel_install(state: MkosiState, cached: bool) -> None: if state.config.cache_initrd and cached: return + # CentOS Stream 8 has an old version of kernel-install that unconditionally writes initrds to + # /boot//, so let's detect that and move them to the correct location. + + if (p := state.root / "etc/machine-id").exists(): + machine_id = p.read_text().strip() + else: + machine_id = None + with complete_step("Generating initramfs images…"): for kver, kimg in gen_kernel_images(state): cmd: list[PathString] = ["kernel-install", "add", kver, Path("/") / kimg] @@ -3086,6 +3094,12 @@ def run_kernel_install(state: MkosiState, cached: bool) -> None: run_workspace_command(state, cmd) + if machine_id and (p := state.root / "boot" / machine_id / kver / "initrd").exists(): + shutil.move(p, state.root / state.installer.initrd_path(kver)) + + if machine_id and (p := state.root / "boot" / machine_id).exists(): + shutil.rmtree(p) + def run_preset_all(state: MkosiState) -> None: if state.for_cache or state.do_run_build_script: