[PATCH 04/20] grub: do not create grub.cfg if EFI_BOOTLOADER is set to not equal grub-efi

Anton Midyukov antohami at altlinux.org
Sun Jan 5 16:00:50 MSK 2020


---
 .../grub/scripts.d/20-propagator-ramdisk      |  2 ++
 .../grub/scripts.d/20-propagator-rescue-hash  |  2 ++
 features.in/grub/stage1/scripts.d/01-grub     | 20 ++++++++++++-------
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/features.in/grub/scripts.d/20-propagator-ramdisk b/features.in/grub/scripts.d/20-propagator-ramdisk
index a01b8f3127..059c60ef76 100755
--- a/features.in/grub/scripts.d/20-propagator-ramdisk
+++ b/features.in/grub/scripts.d/20-propagator-ramdisk
@@ -5,6 +5,8 @@
 
 cd "$WORKDIR"
 
+[ -d boot/grub ] || exit 0
+
 cfgs="$(find boot/grub -name '*.cfg')"
 [ -n "$cfgs" ] || {
 	echo "${0##*/}: did not find any config under boot/grub " >&2
diff --git a/features.in/grub/scripts.d/20-propagator-rescue-hash b/features.in/grub/scripts.d/20-propagator-rescue-hash
index 7a13499693..92c5972a65 100755
--- a/features.in/grub/scripts.d/20-propagator-rescue-hash
+++ b/features.in/grub/scripts.d/20-propagator-rescue-hash
@@ -5,6 +5,8 @@
 
 cd "$WORKDIR"
 
+[ -d boot/grub ] || exit 0
+
 grep -qs "@rescue_hash@" boot/grub/*.cfg || exit 0
 
 find -maxdepth 1 -type f -name rescue \
diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub
index 4d2a7ac007..4c7d5e23ee 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -4,16 +4,22 @@
 
 CFG="grub.cfg"
 
+if [ -n "$GLOBAL_EFI_BOOTLOADER" -a ! "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
+	rm -fr "$WORKDIR/boot"
+	exit 0
+fi
+
+if [ -z "$GLOBAL_EFI_BOOTLOADER" ]; then
+	case "$GLOBAL_BOOTLOADER" in
+		ieee1275boot|grubaa64boot|grubx86boot) ;;
+		*) rm -fr "$WORKDIR/boot"
+		   exit 0;;
+	esac
+fi
+
 mkdir -p "$WORKDIR/boot/grub"
 cd "$WORKDIR/boot/grub"
 
-# validate just in case (see also stage1 Makefile)
-case "$GLOBAL_BOOTLOADER" in
-	isolinux|syslinux|ieee1275boot|grubaa64boot|grubx86boot) ;;
-	*) echo "error: weird GLOBAL_BOOTLOADER: \`$GLOBAL_BOOTLOADER'" >&2;
-	   exit 1;;
-esac
-
 # copy extra files, if any
 GRUB_FILES="$(cat .in/grub.list)"
 if [ -n "${GRUB_FILES% }" ]; then
-- 
2.24.1


--------------57A0C61BE7D9EDE338E3E6C8
Content-Type: text/x-patch;
 name="0005-grub-generate-configs-boot-grub-grub.cfg-and-EFI-BOO.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0005-grub-generate-configs-boot-grub-grub.cfg-and-EFI-BOO.pa";
 filename*1="tch"



More information about the devel-distro mailing list