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