Bug#770412: grub-xen: fails to install in a chroot

Ian Campbell ijc at hellion.org.uk
Sat Nov 22 10:40:05 UTC 2014


On Fri, 2014-11-21 at 20:34 +0000, Ian Campbell wrote:
> Anyway, I'll investigate ischroot or running-in-container which the grub
> postinst seem to use already (not sure what it does, might be suitable).

Neither of those seemed quite right, so here is what I came up with.
Passes a local piuparts run and installation in a Xen guest.

Colin, does this seem sane? It has the affect that grub-* will no longer
fail to install if grub-install fails for some reason -- that could be
seen as either a good or bad thing I suspect...

8<----------

>From a8eb7d27c945df31eaca58ba02948d0f1964b0e9 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc at debian.org>
Date: Sat, 22 Nov 2014 10:03:48 +0000
Subject: [PATCH] Log a failure in postinst when grub-install fails instead of
 failing entirely

This allows installation of the package when e.g. dev is not mounted etc.

The change covers all invocations of grub-install which do not already have
special handling of some sort.
---
 debian/changelog   |  7 +++++++
 debian/postinst.in | 20 ++++++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 40db9e9..90a9412 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+grub2 (2.02~beta2-17) UNRELEASED; urgency=medium
+
+  * Log failure when grub-install fails in postinst, rather than failing the
+    entire postinst. (Closes: #770412)
+
+ -- Ian Campbell <ijc at debian.org>  Sat, 22 Nov 2014 07:45:46 +0000
+
 grub2 (2.02~beta2-16) unstable; urgency=medium
 
   [ Ian Campbell ]
diff --git a/debian/postinst.in b/debian/postinst.in
index 30e6947..056e27d 100644
--- a/debian/postinst.in
+++ b/debian/postinst.in
@@ -299,6 +299,14 @@ running_in_container()
   type running-in-container >/dev/null 2>&1 && running-in-container >/dev/null
 }
 
+run_grub_install()
+{
+    if ! grub-install $@ ; then
+        echo "Failed: grub-install $@" >&2
+        echo "WARNING: Bootloader is not properly installed, system may not be bootable" >&2
+    fi
+}
+
 case "$1" in
   configure)
     . /usr/share/debconf/confmodule
@@ -696,7 +704,7 @@ case "$1" in
             grub-efi-arm)   target=arm-efi ;;
             grub-efi-arm64) target=arm64-efi ;;
           esac
-          grub-install --target="$target"
+          run_grub_install --target="$target"
         fi
 
         # /boot/grub/ has more chances of being accessible by GRUB
@@ -714,22 +722,22 @@ case "$1" in
             # Output may be empty; if so, just update the core image but
             # don't install it to any PReP partition.
             prep_bootdev="$(/usr/lib/grub/powerpc-ieee1275/prep-bootdev)"
-            grub-install --target=powerpc-ieee1275 $prep_bootdev
+            run_grub_install --target=powerpc-ieee1275 $prep_bootdev
           ;;
         esac
       ;;
 
       grub-yeeloong)
-        grub-install --target=mipsel-loongson
+        run_grub_install --target=mipsel-loongson
       ;;
 
       grub-xen)
         # Install for x86_64 regardless of arch, since a 32-bit userspace can still boot with a 64-bit kernel.
-	mkdir -p /boot/xen
-        grub-install --target=x86_64-xen
+        mkdir -p /boot/xen
+        run_grub_install --target=x86_64-xen
         case $(dpkg --print-architecture) in
           i386)
-            grub-install --target=i386-xen
+            run_grub_install --target=i386-xen
           ;;
         esac
       ;;
-- 
2.1.3



More information about the Pkg-grub-devel mailing list