zbyszek / rpms / grub2

Forked from rpms/grub2 5 years ago
Clone
bd638f8
From 7d96844d560e9a4ce14f785abbb4b9d25ee49987 Mon Sep 17 00:00:00 2001
bd638f8
From: Peter Jones <pjones@redhat.com>
bd638f8
Date: Tue, 25 Oct 2016 13:26:38 -0400
bd638f8
Subject: [PATCH 2/2] Make grub2-mkconfig able to output BLS based config file
bd638f8
bd638f8
Signed-off-by: Peter Jones <pjones@redhat.com>
bd638f8
---
bd638f8
 util/grub-mkconfig.in     |  3 ++-
bd638f8
 util/grub-mkconfig_lib.in | 24 +++++++++++++++---------
bd638f8
 util/grub.d/10_linux.in   | 20 ++++++++++++++++++++
bd638f8
 3 files changed, 37 insertions(+), 10 deletions(-)
bd638f8
bd638f8
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
bd638f8
index e32de5e..0e0475d 100644
bd638f8
--- a/util/grub-mkconfig.in
bd638f8
+++ b/util/grub-mkconfig.in
bd638f8
@@ -239,7 +239,8 @@ export GRUB_DEFAULT \
bd638f8
   GRUB_BADRAM \
bd638f8
   GRUB_OS_PROBER_SKIP_LIST \
bd638f8
   GRUB_DISABLE_SUBMENU \
bd638f8
-  GRUB_DEFAULT_DTB
bd638f8
+  GRUB_DEFAULT_DTB \
bd638f8
+  GRUB_ENABLE_BLSCFG
bd638f8
 
bd638f8
 if test "x${grub_cfg}" != "x"; then
bd638f8
   rm -f "${grub_cfg}.new"
bd638f8
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
bd638f8
index 9c410ea..54b3576 100644
bd638f8
--- a/util/grub-mkconfig_lib.in
bd638f8
+++ b/util/grub-mkconfig_lib.in
bd638f8
@@ -123,10 +123,16 @@ EOF
bd638f8
 
bd638f8
 prepare_grub_to_access_device ()
bd638f8
 {
bd638f8
+  local device=$1 && shift
bd638f8
+  if [ "$#" -gt 0 ]; then
bd638f8
+    local variable=$1 && shift
bd638f8
+  else
bd638f8
+    local variable=root
bd638f8
+  fi
bd638f8
   old_ifs="$IFS"
bd638f8
   IFS='
bd638f8
 '
bd638f8
-  partmap="`"${grub_probe}" --device $@ --target=partmap`"
bd638f8
+  partmap="`"${grub_probe}" --device ${device} --target=partmap`"
bd638f8
   for module in ${partmap} ; do
bd638f8
     case "${module}" in
bd638f8
       netbsd | openbsd)
bd638f8
@@ -137,34 +143,34 @@ prepare_grub_to_access_device ()
bd638f8
   done
bd638f8
 
bd638f8
   # Abstraction modules aren't auto-loaded.
bd638f8
-  abstraction="`"${grub_probe}" --device $@ --target=abstraction`"
bd638f8
+  abstraction="`"${grub_probe}" --device ${device} --target=abstraction`"
bd638f8
   for module in ${abstraction} ; do
bd638f8
     echo "insmod ${module}"
bd638f8
   done
bd638f8
 
bd638f8
-  fs="`"${grub_probe}" --device $@ --target=fs`"
bd638f8
+  fs="`"${grub_probe}" --device ${device} --target=fs`"
bd638f8
   for module in ${fs} ; do
bd638f8
     echo "insmod ${module}"
bd638f8
   done
bd638f8
 
bd638f8
   if [ x$GRUB_ENABLE_CRYPTODISK = xy ]; then
bd638f8
-      for uuid in `"${grub_probe}" --device $@ --target=cryptodisk_uuid`; do
bd638f8
+      for uuid in `"${grub_probe}" --device ${device} --target=cryptodisk_uuid`; do
bd638f8
 	  echo "cryptomount -u $uuid"
bd638f8
       done
bd638f8
   fi
bd638f8
 
bd638f8
   # If there's a filesystem UUID that GRUB is capable of identifying, use it;
bd638f8
   # otherwise set root as per value in device.map.
bd638f8
-  fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`"
bd638f8
+  fs_hint="`"${grub_probe}" --device ${device} --target=compatibility_hint`"
bd638f8
   if [ "x$fs_hint" != x ]; then
bd638f8
     echo "set root='$fs_hint'"
bd638f8
   fi
bd638f8
-  if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then
bd638f8
-    hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints=
bd638f8
+  if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then
bd638f8
+    hints="`"${grub_probe}" --device ${device} --target=hints_string 2> /dev/null`" || hints=
bd638f8
     echo "if [ x\$feature_platform_search_hint = xy ]; then"
bd638f8
-    echo "  search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}"
bd638f8
+    echo "  search --no-floppy --fs-uuid --set=${variable} ${hints} ${fs_uuid}"
bd638f8
     echo "else"
bd638f8
-    echo "  search --no-floppy --fs-uuid --set=root ${fs_uuid}"
bd638f8
+    echo "  search --no-floppy --fs-uuid --set=${variable} ${fs_uuid}"
bd638f8
     echo "fi"
bd638f8
   fi
bd638f8
   IFS="$old_ifs"
bd638f8
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
bd638f8
index 0c5b227..8d31b1d 100644
bd638f8
--- a/util/grub.d/10_linux.in
bd638f8
+++ b/util/grub.d/10_linux.in
bd638f8
@@ -105,6 +105,26 @@ linux_entry ()
bd638f8
   if [ -z "$boot_device_id" ]; then
bd638f8
       boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
bd638f8
   fi
bd638f8
+
bd638f8
+  if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then
bd638f8
+    if [ x$dirname = x/ ]; then
bd638f8
+      if [ -z "${prepare_root_cache}" ]; then
bd638f8
+        prepare_grub_to_access_device ${GRUB_DEVICE}
bd638f8
+      fi
bd638f8
+    else
bd638f8
+      if [ -z "${prepare_boot_cache}" ]; then
bd638f8
+        prepare_grub_to_access_device ${GRUB_DEVICE_BOOT}
bd638f8
+      fi
bd638f8
+    fi
bd638f8
+
bd638f8
+    bootefi_device="`${grub_probe} --target=device /boot/efi/`"
bd638f8
+    prepare_grub_to_access_device ${bootefi_device} boot
bd638f8
+
bd638f8
+    echo bls_import
bd638f8
+
bd638f8
+    exit 0
bd638f8
+  fi
bd638f8
+
bd638f8
   if [ x$type != xsimple ] ; then
bd638f8
       case $type in
bd638f8
 	  recovery)
bd638f8
-- 
bd638f8
2.9.3
bd638f8