Subject: Bug#667610: Please allow for bypassing the autoconfiguration of grub2

From: Wouter Verhelst <[email-masked]>
Date: Thu, 5 Apr 2012 11:55:44 +0200

Package: grub2
Severity: wishlist

Hi,

I'm currently working on a script for a customer to generate a
customized image for them to use on their embedded devices. The output
of this script will be a CompactFlash device, ready to be put in their
device (an Atom-based board). This script must run fully noninteractive,
so has DEBCONF_FRONTEND=noninteractive.

One of the things the script must do is install a boot loader, in casu
grub2. However, this fails because grub2 assumes that it must at all
times be installed to a boot record if it's installed somewhere, and
will fail to install properly if that isn't true. Now while it can be
useful to have a bootloader be automatically configured upon
installation, it's fairly annoying if I have to resort to ugly tricks to
make the postinst script believe it doesn't have to do anything.
Instead, I'd prefer it if it were possible to just tell it to not do
anything, so that I can do this myself.

A proposed patch (not tested, but gets the idea across):

diff -ruN grub2-1.99.orig/debian/postinst.in grub2-1.99/debian/postinst.in
--- grub2-1.99.orig/debian/postinst.in	2012-04-05 11:33:26.638928567 +0200
+++ grub2-1.99/debian/postinst.in	2012-04-05 11:45:43.746939629 +0200
@@ -291,6 +291,11 @@
   configure)
     . /usr/share/debconf/confmodule
 
+    db_get grub2/configure_grub || true
+    if [ "$RET" = "false" ]; then
+      exit 0
+    fi
+
     if dpkg --compare-versions "$2" lt-nl 1.99-1; then
       # Force dpkg to replace this directory with a symlink.
       if [ ! -L /usr/share/doc/@PACKAGE@ ] && [ -d /usr/share/doc/@PACKAGE@ ]; then
diff -ruN grub2-1.99.orig/debian/templates.in grub2-1.99/debian/templates.in
--- grub2-1.99.orig/debian/templates.in	2012-04-05 11:47:12.058940963 +0200
+++ grub2-1.99/debian/templates.in	2012-04-05 11:46:53.330940571 +0200
@@ -43,3 +43,11 @@
  .
  If you do not understand this message, or if there are no custom
  boot menu entries, you can ignore this message.
+
+Template: grub2/configure_grub
+Type: boolean
+Default: true
+Description: not shown
+ This template is not shown. However, you can preseed it to false to
+ skip the autoconfiguration of grub2, in case you want to bypass it or
+ replace it with a local scheme.

Since we only db_get the value and don't db_input it, it's never shown
to a user, and the default value shouldn't result in any changes. As
such, this should be non-intrusive for the common case, while allowing
people to bypass the autoconfiguration entirely if they don't need it,
as in my case.

Thanks,

-- 
The volume of a pizza of thickness a and radius z can be described by
the following formula:

pi zz a

---

From: Colin Watson <[email-masked]>
Date: Thu, 5 Apr 2012 12:05:34 +0100

On Thu, Apr 05, 2012 at 11:55:44AM +0200, Wouter Verhelst wrote:
> will fail to install properly if that isn't true.

Why not install grub-pc-bin (etc.) instead?  I am very strongly averse
to further complicating the postinst, which is already nightmarishly
complicated; I designed the -bin packages to support this kind of thing.

Cheers,

-- 
Colin Watson                                       [[email-masked]]