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

Luis Chamberlain <[email protected]> Fri, 17 Oct 2025 19:31:48 -0700
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
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) %}
 # 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
-- 
2.51.0