From 395abc5bda9903f9bbe0ecd1df63a59bdb6b0071 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 20 Feb 2012 14:52:24 +0100 Subject: [PATCH 1/1] Maintainer scripts: test for presence of grub.cfg, don't execute update-grub otherwise Let's do the same as memtest86+-4.20 does: test for presence of /boot/grub/grub.cfg, if the file exists (and running some other checks) we can execute update-grub, otherwise don't care.... This is supposed to address the annoying: | /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?). issue which is showing up in minimal chroots on package removal. Closes: #660588 --- debian/postinst | 50 +++++++++++++++++++++++++++++++------------------- debian/postrm | 2 +- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/debian/postinst b/debian/postinst index 131e59f..d5f9b75 100644 --- a/debian/postinst +++ b/debian/postinst @@ -3,27 +3,39 @@ set -e +update_grub_wrapper() { + # default, unless configured otherwise: + ISO_LOCATION=/boot/grml + + if [ -r /etc/default/grml-rescueboot ] ; then + . /etc/default/grml-rescueboot + fi + + if ! ls "${ISO_LOCATION}"/*iso >/dev/null 2>&1 ; then + echo "INFO: No *.iso files found inside ${ISO_LOCATION}." + echo "INFO: Please create ${ISO_LOCATION} and place rescue ISO(s) there." + echo "INFO: Finally invoke update-grub and enjoy your rescue system." + return 0 + fi + + if ! which update-grub >/dev/null 2>&1; then + echo "WARN: ISOs found inside ${ISO_LOCATION} but update-grub not present (huh?)" + return 0 + fi + + if ! [ -e /boot/grub/grub.cfg ] ; then + echo "WARN: ISOs found inside ${ISO_LOCATION} but /boot/grub/grub.cfg does not exist." + echo "WARN: Ignoring request to run update-grub to avoid possible boot loader problems." + return 0 + fi + + echo "INFO: ISOs found inside ${ISO_LOCATION}, invoking update-grub:" + update-grub +} + case "$1" in configure) - # default, unless configured otherwise: - ISO_LOCATION=/boot/grml - - if [ -r /etc/default/grml-rescueboot ] ; then - . /etc/default/grml-rescueboot - fi - - if ! ls "${ISO_LOCATION}"/*iso >/dev/null 2>&1 ; then - echo "INFO: No *.iso files found inside ${ISO_LOCATION}." - echo "INFO: Please create ${ISO_LOCATION} and place rescue ISO(s) there." - echo "INFO: Finally invoke update-grub and enjoy your rescue system." - else - if ! which update-grub >/dev/null 2>&1; then - echo "WARN: ISOs found inside ${ISO_LOCATION} but update-grub not present (huh?)" - else - echo "INFO: ISOs found inside ${ISO_LOCATION}, invoking update-grub:" - update-grub - fi - fi + update_grub_wrapper ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/debian/postrm b/debian/postrm index 2154b59..dc1ef1d 100644 --- a/debian/postrm +++ b/debian/postrm @@ -5,7 +5,7 @@ set -e case "$1" in purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - if which update-grub >/dev/null 2>&1; then + if test -e /boot/grub/grub.cfg && which update-grub >/dev/null 2>&1; then echo "Updating grub.cfg to make sure there are no non-existing entries being left." update-grub fi -- 2.1.4