Blame SOURCES/0149-Add-GRUB_DISABLE_UUID.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Peter Jones <pjones@redhat.com>
4fe85b
Date: Thu, 4 Sep 2014 16:49:25 -0400
4fe85b
Subject: [PATCH] Add GRUB_DISABLE_UUID.
4fe85b
4fe85b
This will cause "search --fs-uuid --set=root ..." not to be generated by
4fe85b
grub2-mkconfig, and instead simply attempt to use the grub device name
4fe85b
as it understands it.
4fe85b
4fe85b
Good luck.
4fe85b
4fe85b
Resolves: rhbz#1027833
4fe85b
Signed-off-by: Peter Jones <pjones@redhat.com>
4fe85b
---
4fe85b
 docs/grub.texi            |  7 +++++++
4fe85b
 util/grub-mkconfig.in     | 12 ++++++++++--
4fe85b
 util/grub-mkconfig_lib.in |  4 ++--
4fe85b
 3 files changed, 19 insertions(+), 4 deletions(-)
4fe85b
4fe85b
diff --git a/docs/grub.texi b/docs/grub.texi
4fe85b
index 46b9e7f8e31..6b112c18804 100644
4fe85b
--- a/docs/grub.texi
4fe85b
+++ b/docs/grub.texi
4fe85b
@@ -1409,6 +1409,13 @@ disable the use of UUIDs, set this option to @samp{true}.
4fe85b
 If this option is set to @samp{true}, disable the generation of recovery
4fe85b
 mode menu entries.
4fe85b
 
4fe85b
+@item GRUB_DISABLE_UUID
4fe85b
+Normally, @command{grub-mkconfig} will generate menu entries that use
4fe85b
+universally-unique identifiers (UUIDs) to identify various filesystems to
4fe85b
+search for files.  This is usually more reliable, but in some cases it may
4fe85b
+not be appropriate.  To disable this use of UUIDs, set this option to
4fe85b
+@samp{true}.
4fe85b
+
4fe85b
 @item GRUB_VIDEO_BACKEND
4fe85b
 If graphical video support is required, either because the @samp{gfxterm}
4fe85b
 graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set,
4fe85b
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
4fe85b
index beb22deee79..bc26e7c109e 100644
4fe85b
--- a/util/grub-mkconfig.in
4fe85b
+++ b/util/grub-mkconfig.in
4fe85b
@@ -130,11 +130,11 @@ fi
4fe85b
 
4fe85b
 # Device containing our userland.  Typically used for root= parameter.
4fe85b
 GRUB_DEVICE="`${grub_probe} --target=device /`"
4fe85b
-GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
4fe85b
+GRUB_DEVICE_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
4fe85b
 
4fe85b
 # Device containing our /boot partition.  Usually the same as GRUB_DEVICE.
4fe85b
 GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
4fe85b
-GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
4fe85b
+GRUB_DEVICE_BOOT_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
4fe85b
 
4fe85b
 # Filesystem for the device containing our userland.  Used for stuff like
4fe85b
 # choosing Hurd filesystem module.
4fe85b
@@ -148,6 +148,13 @@ if test -f ${sysconfdir}/default/grub ; then
4fe85b
   . ${sysconfdir}/default/grub
4fe85b
 fi
4fe85b
 
4fe85b
+if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_UUID" ]; then
4fe85b
+  GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED"
4fe85b
+fi
4fe85b
+if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_BOOT_UUID" ]; then
4fe85b
+  GRUB_DEVICE_BOOT_UUID="$GRUB_DEVICE_BOOT_UUID_GENERATED"
4fe85b
+fi
4fe85b
+
4fe85b
 # XXX: should this be deprecated at some point?
4fe85b
 if [ "x${GRUB_TERMINAL}" != "x" ] ; then
4fe85b
   GRUB_TERMINAL_INPUT="${GRUB_TERMINAL}"
4fe85b
@@ -213,6 +220,7 @@ export GRUB_DEFAULT \
4fe85b
   GRUB_SERIAL_COMMAND \
4fe85b
   GRUB_DISABLE_LINUX_UUID \
4fe85b
   GRUB_DISABLE_RECOVERY \
4fe85b
+  GRUB_DISABLE_UUID \
4fe85b
   GRUB_VIDEO_BACKEND \
4fe85b
   GRUB_GFXMODE \
4fe85b
   GRUB_BACKGROUND \
4fe85b
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
4fe85b
index 7ac0bbed0d3..5c9ed84a5e7 100644
4fe85b
--- a/util/grub-mkconfig_lib.in
4fe85b
+++ b/util/grub-mkconfig_lib.in
4fe85b
@@ -156,7 +156,7 @@ prepare_grub_to_access_device ()
4fe85b
   if [ "x$fs_hint" != x ]; then
4fe85b
     echo "set root='$fs_hint'"
4fe85b
   fi
4fe85b
-  if fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then
4fe85b
+  if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then
4fe85b
     hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints=
4fe85b
     echo "if [ x\$feature_platform_search_hint = xy ]; then"
4fe85b
     echo "  search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}"
4fe85b
@@ -173,7 +173,7 @@ grub_get_device_id ()
4fe85b
   IFS='
4fe85b
 '
4fe85b
   device="$1"
4fe85b
-  if fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then
4fe85b
+  if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then
4fe85b
     echo "$fs_uuid";
4fe85b
   else
4fe85b
     echo $device |sed 's, ,_,g'