Blame SOURCES/0149-Add-GRUB_DISABLE_UUID.patch

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