Blame SOURCES/0149-Add-GRUB_DISABLE_UUID.patch

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