summaryrefslogtreecommitdiffstats
path: root/debian/legacy/upgrade-from-grub-legacy
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 10:54:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 10:54:18 +0000
commit8e67fbf68ffeb9eb5f026dd482d73b021660bf9b (patch)
treebb573facd5d02096f9956b2617a722b88acaa8af /debian/legacy/upgrade-from-grub-legacy
parentAdding upstream version 2.06. (diff)
downloadgrub2-8e67fbf68ffeb9eb5f026dd482d73b021660bf9b.tar.xz
grub2-8e67fbf68ffeb9eb5f026dd482d73b021660bf9b.zip
Adding debian version 2.06-3~deb11u6.debian/2.06-3_deb11u6debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/legacy/upgrade-from-grub-legacy')
-rwxr-xr-xdebian/legacy/upgrade-from-grub-legacy44
1 files changed, 44 insertions, 0 deletions
diff --git a/debian/legacy/upgrade-from-grub-legacy b/debian/legacy/upgrade-from-grub-legacy
new file mode 100755
index 0000000..9ed829d
--- /dev/null
+++ b/debian/legacy/upgrade-from-grub-legacy
@@ -0,0 +1,44 @@
+#!/bin/bash -e
+
+if test ! -f /boot/grub/core.img ; then
+ echo -e "\ncore.img doesn't exist, trying to create it.\n" >&2
+ grub-install --no-floppy --grub-setup=/bin/true "(hd0)" > /dev/null
+fi
+
+echo RESET grub-pc/install_devices | debconf-communicate >/dev/null
+
+# Pretend we're upgrading grub-pc. This will make our postinst DTRT.
+DPKG_MAINTSCRIPT_NAME=postinst \
+ DPKG_MAINTSCRIPT_PACKAGE=grub-pc \
+ UPGRADE_FROM_GRUB_LEGACY=1 \
+ /var/lib/dpkg/info/grub-pc.postinst configure dummy-version
+
+if test ! -f /boot/grub/grub.cfg ; then
+ echo -e "\nCalling update-grub to generate grub.cfg\n" >&2
+ update-grub || cat << EOF
+Failed to generate /boot/grub/grub.cfg but GRUB2 has been already installed to
+your MBR.
+THIS MEANS YOU HAVE CURRENTLY AN UNBOOTABLE SYSTEM.
+Either fix the error from update-grub and run $0 again
+or install old grub again and run grub-install from it to have again
+grub-legacy in your MBR.
+EOF
+fi
+
+# These never contain any valuable information, and they aren't useful for
+# boot anymore, since we just overwrote MBR/PBR.
+rm -f /boot/grub/{{xfs,reiserfs,e2fs,fat,jfs,minix}_stage1_5,stage{1,2}}
+# Remove marker file used to indicate that grub-install was run rather than
+# this script. Since stage2 has been removed, we don't need this any more.
+rm -f /boot/grub/grub2-installed
+
+cat << EOF
+
+GRUB Legacy has been removed, but its configuration files have been preserved,
+since this script cannot determine if they contain valuable information. If
+you would like to remove the configuration files as well, use the following
+command:
+
+ rm -f /boot/grub/menu.lst*
+
+EOF