[OSSTEST,31/49] overlay-initrd-buster/sbin/reopen-console: Fix #932416
diff mbox series

Message ID 20200529111945.21394-32-ian.jackson@eu.citrix.com
State New
Headers show
  • Switch to Debian buster (= Debian stable)
Related show

Commit Message

Ian Jackson May 29, 2020, 11:19 a.m. UTC
This bug affects us.  Cherry pick the changes to the relevant file
from the commit in the upstream debian-installer repo:


Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
 overlay-initrd-buster/sbin/reopen-console | 36 +++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff mbox series

diff --git a/overlay-initrd-buster/sbin/reopen-console b/overlay-initrd-buster/sbin/reopen-console
index dd354deb..13b15a33 100755
--- a/overlay-initrd-buster/sbin/reopen-console
+++ b/overlay-initrd-buster/sbin/reopen-console
@@ -16,6 +16,17 @@  NL="
+# If we're running with preseeding, we have a problem with running d-i
+# on multiple consoles. We'll end up running each of those d-i
+# instances in parallel with all kinds of hilarious undefined
+# behaviour as they trip over each other! If we detect that we're
+# preseeding (via any of the possible preseed methods), DO NOT run d-i
+# multiple times. Instead, fall back to the older, more simple
+# behaviour and run it once. If the user wants to see or interact with
+# their preseed on a specific console, they get to tell us which one
+# they want to use.
 log() {
 	# In very early startup we don't have syslog. Log to file that
 	# we can flush out later so we can at least see what happened
@@ -32,6 +43,20 @@  flush_logger () {
 	rm $LOG_FILE
+# If we have a preseed.cfg in the initramfs
+if [ -e /preseed.cfg ]; then
+    log "Found /preseed.cfg; falling back to simple mode for preseeding"
+# Have we been told to do preseeding stuff on the boot command line?
+for WORD in auto url; do
+    if (grep -qw "$WORD" /proc/cmdline); then
+	log "Found \"$WORD\" in the command line; falling back to simple mode for preseeding"
+    fi
 # Retrieve all enabled consoles from kernel; ignore those
@@ -44,7 +69,7 @@  do
 	status=$(echo "$kernelconsoles" | grep $cons | sed -n -r -e 's/(^.*) *.*\((.*)\).*$/\2/p' )
 	if [ -e "/dev/$cons" ] && [ $(echo "$status" | grep -o 'E') ]; then
-		log "   Adding $cons to consoles list"
+		log "   Adding $cons to possible consoles list"
 	# 'C' console is 'most prefered'.
 	if [ $(echo "$status" | grep -o 'C') ]; then
@@ -64,6 +89,13 @@  if [ -z "$preferred" ]; then
 	log "Found no preferred console. Picking $preferred"
+# If we're preseeding, do simple stuff here (see above). We just
+# want one console. Let's pick the preferred one ONLY
+if [ $PRESEEDING = 1 ]; then
+    log "Running with preseeding. Picking preferred $preferred ONLY"
+    consoles=$preferred
 for cons in $consoles
 	echo "/dev/$cons " >> /var/run/console-devices
@@ -88,7 +120,7 @@  LOGGER_UP=1
 # Finally restart init to run debian-installer on discovered consoles
-log "Restarting init to start d-i on the consoles we found"
+log "Restarting init to start d-i on the console(s) we found"
 kill -HUP 1
 exit 0