[PATCH 2/8] guestfs: Don't delete APT sources copied from host

Luis Chamberlain <[email protected]> Fri, 17 Oct 2025 19:31:47 -0700
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
The virt-builder template was deleting the APT sources file after copying
it from the host and using it for package installation. This left the guest
with NO package sources configured, causing firstboot "apt update" commands
to fail.

The delete logic appeared to assume the guest would fall back to default
Debian repos, but there was no fallback mechanism. If the user explicitly
enables CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST, they want their
guest to use their local mirror configuration.

Remove the delete command so the copied sources file persists in the guest.
This allows firstboot apt commands to succeed and enables the guest to use
the same mirror as the host.

Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <[email protected]>
---
 playbooks/roles/base_image/templates/virt-builder.j2 | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/playbooks/roles/base_image/templates/virt-builder.j2 b/playbooks/roles/base_image/templates/virt-builder.j2
index 608dc31f..b5de57d4 100644
--- a/playbooks/roles/base_image/templates/virt-builder.j2
+++ b/playbooks/roles/base_image/templates/virt-builder.j2
@@ -77,9 +77,5 @@ firstboot-command update-locale LANG=en_US.UTF-8
 firstboot-command systemctl stop ssh
 firstboot-command systemctl start ssh
 
-{% if guestfs_copy_sources_from_host_to_guest %}
-delete /etc/apt/sources.list.d/debian.sources
-{% endif %}
-
 {% endif %}
 {% endif %}
-- 
2.51.0