Re: [PATCH 3/8] guestfs: Fix dracut-config-rescue removal for Debian systems

Chuck Lever <[email protected]> Sat, 18 Oct 2025 14:16:03 -0400
Newsgroups dev.linux.lists.kdevops
Organization kernel.org
Message-ID <[email protected]>
On 10/17/25 10:31 PM, Luis Chamberlain wrote:
> The virt-builder template was trying to uninstall dracut-config-rescue
> package unconditionally, but this package only exists on Fedora/RHEL
> systems. Debian uses initramfs-tools instead of dracut.
> 
> This was causing base image customization to fail with:
>   E: Unable to locate package dracut-config-rescue
>   virt-customize: error: apt-get remove 'dracut-config-rescue': command
>   exited with an error
> 
> Conditionalize the dracut cleanup section to only run on non-Debian
> systems. This allows Debian Trixie base images to be created successfully
> while preserving the cleanup behavior for Fedora/RHEL/openSUSE systems
> that use dracut.
> 
> Generated-by: Claude AI
> Signed-off-by: Luis Chamberlain <[email protected]>
> ---
>  playbooks/roles/base_image/templates/virt-builder.j2 | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/playbooks/roles/base_image/templates/virt-builder.j2 b/playbooks/roles/base_image/templates/virt-builder.j2
> index b5de57d4..5e3e4cd8 100644
> --- a/playbooks/roles/base_image/templates/virt-builder.j2
> +++ b/playbooks/roles/base_image/templates/virt-builder.j2
> @@ -14,10 +14,12 @@ copy-in {{ guestfs_distro_source_and_dest_file }}:{{ target_dir }}
>  
>  install sudo,qemu-guest-agent,python3,bash,policycoreutils-python-utils
>  
> +{% if not (distro_debian_based is defined and distro_debian_based) %}

Claude copied a bug I introduced. You want this:

{% if guestfs_debian is defined and guestfs_debian %}

instead, but it will work only after applying "base_image: Replace
distro checks" which is in the cel-fixes branch. I can merge that
right now.

With that change, for the series:

Reviewed-by: Chuck Lever <[email protected]>


>  # get rid of any rescue initramfs images, and prevent new ones from being generated
>  uninstall dracut-config-rescue
>  delete /boot/*rescue*
>  delete /boot/loader/entries/*rescue*
> +{% endif %}
>  
>  run-command useradd {{ kdevops_uid }} -s /bin/bash -m kdevops
>  append-line /etc/sudoers.d/kdevops:kdevops   ALL=(ALL)       NOPASSWD: ALL


-- 
Chuck Lever