public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: kdevops@lists.linux.dev, ross@kallisti.us
Cc: mcgrof@kernel.org
Subject: [PATCH kdevops 3/4] guestfs: fix trixie bringup
Date: Thu, 10 Oct 2024 18:01:10 -0700	[thread overview]
Message-ID: <20241011010111.3543993-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20241011010111.3543993-1-mcgrof@kernel.org>

We have a series of fixups needed to the default generic debian 13
trixie image:

 - kdevops has support for default heuristic when debian is detected
   on the host, and if your host has an /etc/apt/sources.list with
   a hop 1 to the servers, we infer that you are using a local mirror
   for debian. *If* the host and guest match distributions or at
   least we feel confident in the upgrade process (upgrading buster
   to trixie on the guest) then we by default enable leveraging the
   host's sources.list file onto the guest so the guest can also
   save bandwidth. This works nicely. However trixie uses an
   /etc/nsswitch.conf like this:

      files myhostname resolve [!UNAVAIL=return] dns

  This will prevent using dns from finding the 1 hop server on
  /etc/apt/sources.list. To fix this enable dns to be used for
  host son trixie.

 - cloud-init is not used by us and so we should just stop
   it, otherwise we may timeout on some random clout init
   guess work.

 - setup locales for LANG=en_US.UTF-8, we can later add variability
   if folks want it

 - restart ssh as in practice I've seen issues on bringup and timeouts

 - Be sure to remove the distro's /etc/apt/sources.list.d/debian.sources
   if CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST is enabled
   (as explained above).

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 scripts/bringup_guestfs.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/scripts/bringup_guestfs.sh b/scripts/bringup_guestfs.sh
index d09ae64dcaea..16bfa7a6c805 100755
--- a/scripts/bringup_guestfs.sh
+++ b/scripts/bringup_guestfs.sh
@@ -233,6 +233,31 @@ firstboot-command systemctl stop ssh
 firstboot-command DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true dpkg-reconfigure -p low --force openssh-server
 firstboot-command systemctl start ssh
 _EOT
+	# CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST will not work
+	# if etc/nsswitch.conf has a line like this:
+	#
+	# hosts:          files myhostname resolve [!UNAVAIL=return] dns
+	#
+	# We need DNS to be used so virb0 will be used for a DNS request
+	if [[ "$CONFIG_GUESTFS_DEBIAN_TRIXIE" == "y" ]]; then
+		cat <<_EOT >>$cmdfile
+edit /etc/nsswitch.conf:'s/^hosts:.*UNAVAIL=return.*dns/hosts: files myhostname resolve dns/'
+uninstall cloud-init
+write /etc/default/locale:LANG=en_US.UTF-8
+append-line /etc/default/locale:LANGUAGE=en_US:en
+write /etc/locale.gen:en_US.UTF-8 UTF-8
+firstboot-command locale-gen en_US.UTF-8
+firstboot-command update-locale LANG=en_US.UTF-8
+firstboot-command DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true dpkg-reconfigure -p low --force locales
+firstboot-command systemctl stop ssh
+firstboot-command systemctl start ssh
+_EOT
+		if [[ "$CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST" == "y" ]]; then
+		cat <<_EOT >>$cmdfile
+delete /etc/apt/sources.list.d/debian.sources
+_EOT
+		fi
+	fi
 }
 
 USE_SUDO=""
-- 
2.43.0


  parent reply	other threads:[~2024-10-11  1:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11  1:01 [PATCH kdevops 0/4] kdevops: make trixie default Luis Chamberlain
2024-10-11  1:01 ` [PATCH kdevops 1/4] guestfs: make trixie generic image the default Luis Chamberlain
2024-10-11  1:01 ` [PATCH kdevops 2/4] guestfs: fix uefi boot for debian trixie Luis Chamberlain
2024-10-11  1:01 ` Luis Chamberlain [this message]
2024-10-11  1:01 ` [PATCH kdevops 4/4] guestfs: make debian trixie default Luis Chamberlain
2024-10-11 19:00 ` [PATCH kdevops 0/4] kdevops: make " Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241011010111.3543993-4-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=kdevops@lists.linux.dev \
    --cc=ross@kallisti.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox