Fix autoinstalls to work around a modern d-i bug mitchb precise-dev precise-prod 0.0.60
authorMitchell E Berger <mitchb@mit.edu>
Wed, 1 Jan 2020 09:07:38 +0000 (04:07 -0500)
committerMitchell E Berger <mitchb@mit.edu>
Wed, 1 Jan 2020 09:07:38 +0000 (04:07 -0500)
Modern d-i (at least Debian Buster, and probably others) reads
/proc/consoles and adds entries to /etc/inittab to spawn a d-i
on each of them.  With debconf/priority>=high (i.e. without
the menu showing, and with d-i autodriving through the items),
if there are multiple consoles, this results in the d-i's racing
to use /var/lib/dpkg/status to record what happens as they
run the postinst of each udeb, and as a result, menu items
fail and the autoinstall fails.  See Debian Bug #944125.

We only set console=hvc0, but for reasons unknown, tty0 also
appears in /proc/consoles despite not being in /proc/cmdline,
and we don't seem to have control over that.  The script that
reads /proc/consoles is /sbin/reopen-console, which also
happens to be the main rc script on sysinit in /etc/inittab.
That script (through a chain of other scripts) is also what
runs preseed/early_command if it's set.

Normally, preseed/early_command cannot run until way too late
to address this, because you don't have the preseed until several
tasks into the install by which point it will have failed.
However, if you get the quoting right, you can set it as a
boot argument and it will run before any of the menu items,
and in fact, before d-i has started.

Because /sbin/reopen-console ultimately is what runs
preseed/early_command, when the command runs, it is too late
to use sed to edit reopen-console, and you can't kill it
because it runs the rest of the process.  At the point where
preseed/early_command runs, reopen-console has already found
the consoles and added d-i jobs for each of them to /etc/inittab.
However, it doesn't send the HUP to init until just after the
scripts including preseed/early_command are run.

Yank the tty0 job out from inittab just in the nick of time.
This should be safe for old distros because we have always
forced the desired console to hvc0; while the problem that
necessitates this kludge didn't exist in the past, removing
any inittab job for tty0 shouldn't have any noticeable effect
on them.

debian/changelog
invirt-database

index ff5d141..7d0c89b 100644 (file)
@@ -1,3 +1,49 @@
+invirt-xen-config (0.0.60) unstable; urgency=low
+
+  * Fix autoinstalls to work around a modern d-i bug
+
+    Modern d-i (at least Debian Buster, and probably others) reads
+    /proc/consoles and adds entries to /etc/inittab to spawn a d-i
+    on each of them.  With debconf/priority>=high (i.e. without
+    the menu showing, and with d-i autodriving through the items),
+    if there are multiple consoles, this results in the d-i's racing
+    to use /var/lib/dpkg/status to record what happens as they
+    run the postinst of each udeb, and as a result, menu items
+    fail and the autoinstall fails.  See Debian Bug #944125.
+
+    We only set console=hvc0, but for reasons unknown, tty0 also
+    appears in /proc/consoles despite not being in /proc/cmdline,
+    and we don't seem to have control over that.  The script that
+    reads /proc/consoles is /sbin/reopen-console, which also
+    happens to be the main rc script on sysinit in /etc/inittab.
+    That script (through a chain of other scripts) is also what
+    runs preseed/early_command if it's set.
+
+    Normally, preseed/early_command cannot run until way too late
+    to address this, because you don't have the preseed until several
+    tasks into the install by which point it will have failed.
+    However, if you get the quoting right, you can set it as a
+    boot argument and it will run before any of the menu items,
+    and in fact, before d-i has started.
+
+    Because /sbin/reopen-console ultimately is what runs
+    preseed/early_command, when the command runs, it is too late
+    to use sed to edit reopen-console, and you can't kill it
+    because it runs the rest of the process.  At the point where
+    preseed/early_command runs, reopen-console has already found
+    the consoles and added d-i jobs for each of them to /etc/inittab.
+    However, it doesn't send the HUP to init until just after the
+    scripts including preseed/early_command are run.
+
+    Yank the tty0 job out from inittab just in the nick of time.
+    This should be safe for old distros because we have always
+    forced the desired console to hvc0; while the problem that
+    necessitates this kludge didn't exist in the past, removing
+    any inittab job for tty0 shouldn't have any noticeable effect
+    on them.
+
+ -- Mitchell Berger <mitchb@mit.edu>  Wed, 01 Jan 2020 03:43:00 -0500
+
 invirt-xen-config (0.0.59) unstable; urgency=low
 
   * Fix the fact that we can't bump RAM quotas above 2048M
index adee177..98ede48 100644 (file)
@@ -72,6 +72,7 @@ if 'installer_options' in locals(): #Installer
             # For debugging, add "DEBCONF_DEBUG=5" to the arguments.
             extras = ["auto=true",
                       "debconf/priority=critical",
+                      'preseed/early_command="grep -v tty0 /etc/inittab >/etc/inittab.new; mv -f /etc/inittab.new /etc/inittab"',
                       "debian-installer/locale=en_US.UTF-8",
                       "debian-installer/exit/always_halt=true",
                       "url="+install['preseed'],