Blame SOURCES/0040-macos-just-build-chainloader-entries-don-t-try-any-x.patch

5593c8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5593c8
From: Peter Jones <pjones@redhat.com>
5593c8
Date: Wed, 24 May 2017 12:42:32 -0400
5593c8
Subject: [PATCH] macos: just build chainloader entries, don't try any xnu xnu.
5593c8
5593c8
Since our bugs tell us that the xnu boot entries really just don't work
5593c8
most of the time, and they create piles of extra boot entries, because
5593c8
they can't quite figure out 32-vs-64 and other stuff like that.
5593c8
5593c8
It's rediculous, and we should just boot their bootloader through the
5593c8
chainloader instead.
5593c8
5593c8
So this patch does that.
5593c8
5593c8
Resolves: rhbz#893179
5593c8
5593c8
Signed-off-by: Peter Jones <pjones@redhat.com>
5593c8
---
5593c8
 util/grub.d/30_os-prober.in | 78 +++++++++++----------------------------------
5593c8
 1 file changed, 18 insertions(+), 60 deletions(-)
5593c8
5593c8
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
fd0330
index 1b91c102f3..4b27bd2015 100644
5593c8
--- a/util/grub.d/30_os-prober.in
5593c8
+++ b/util/grub.d/30_os-prober.in
5593c8
@@ -42,68 +42,25 @@ if [ -z "${OSPROBED}" ] ; then
5593c8
 fi
5593c8
 
5593c8
 osx_entry() {
5593c8
-    if [ x$2 = x32 ]; then
5593c8
-        # TRANSLATORS: it refers to kernel architecture (32-bit)
5593c8
-	bitstr="$(gettext "(32-bit)")"
5593c8
-    else
5593c8
-        # TRANSLATORS: it refers to kernel architecture (64-bit)
5593c8
-	bitstr="$(gettext "(64-bit)")"
5593c8
-    fi
5593c8
     # TRANSLATORS: it refers on the OS residing on device %s
5593c8
     onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
5593c8
-        cat << EOF
5593c8
-menuentry '$(echo "${LONGNAME} $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")'  {
5593c8
+    hints=""
5593c8
+    for hint in `"${grub_probe}" --device ${device} --target=efi_hints 2> /dev/null` ; do
5593c8
+      hints="${hints} --hint=${hint}"
5593c8
+    done
5593c8
+    cat << EOF
5593c8
+menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")'  {
5593c8
 EOF
5593c8
 	save_default_entry | grub_add_tab
5593c8
 	prepare_grub_to_access_device ${DEVICE} | grub_add_tab
5593c8
 	cat << EOF
5593c8
+	set gfxpayload=keep
5593c8
         load_video
5593c8
-        set do_resume=0
5593c8
-        if [ /var/vm/sleepimage -nt10 / ]; then
5593c8
-           if xnu_resume /var/vm/sleepimage; then
5593c8
-             set do_resume=1
5593c8
-           fi
5593c8
-        fi
5593c8
-        if [ \$do_resume = 0 ]; then
5593c8
-           xnu_uuid ${OSXUUID} uuid
5593c8
-           if [ -f /Extra/DSDT.aml ]; then
5593c8
-              acpi -e /Extra/DSDT.aml
5593c8
-           fi
5593c8
-           if [ /kernelcache -nt /System/Library/Extensions ]; then
5593c8
-              $1 /kernelcache boot-uuid=\${uuid} rd=*uuid
5593c8
-           elif [ -f /System/Library/Kernels/kernel ]; then
5593c8
-              $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid
5593c8
-              xnu_kextdir /System/Library/Extensions
5593c8
-           else
5593c8
-              $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid
5593c8
-              if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
5593c8
-                xnu_mkext /System/Library/Extensions.mkext
5593c8
-              else
5593c8
-                xnu_kextdir /System/Library/Extensions
5593c8
-              fi
5593c8
-           fi
5593c8
-           if [ -f /Extra/Extensions.mkext ]; then
5593c8
-              xnu_mkext /Extra/Extensions.mkext
5593c8
-           fi
5593c8
-           if [ -d /Extra/Extensions ]; then
5593c8
-              xnu_kextdir /Extra/Extensions
5593c8
-           fi
5593c8
-           if [ -f /Extra/devprop.bin ]; then
5593c8
-              xnu_devprop_load /Extra/devprop.bin
5593c8
-           fi
5593c8
-           if [ -f /Extra/splash.jpg ]; then
5593c8
-              insmod jpeg
5593c8
-              xnu_splash /Extra/splash.jpg
5593c8
-           fi
5593c8
-           if [ -f /Extra/splash.png ]; then
5593c8
-              insmod png
5593c8
-              xnu_splash /Extra/splash.png
5593c8
-           fi
5593c8
-           if [ -f /Extra/splash.tga ]; then
5593c8
-              insmod tga
5593c8
-              xnu_splash /Extra/splash.tga
5593c8
-           fi
5593c8
-        fi
5593c8
+	insmod part_gpt
5593c8
+	insmod hfsplus
5593c8
+	search --no-floppy --fs-uuid --set=root ${hints} $(grub_get_device_id "${DEVICE}")
5593c8
+	chainloader (\$root)/System/Library/CoreServices/boot.efi
5593c8
+	boot
5593c8
 }
5593c8
 EOF
5593c8
 }
5593c8
@@ -292,11 +249,12 @@ EOF
5593c8
       echo "$title_correction_code"
5593c8
     ;;
5593c8
     macosx)
5593c8
-      if [ "${UUID}" ]; then
5593c8
-	OSXUUID="${UUID}"
5593c8
-	osx_entry xnu_kernel 32
5593c8
-	osx_entry xnu_kernel64 64
5593c8
-      fi
5593c8
+      for subdevice in ${DEVICE%[[:digit:]]*}* ; do
5593c8
+	parttype="`"${grub_probe}" --device ${device} --target=gpt_parttype "${subdevice}" 2> /dev/null`"
5593c8
+	if [[ "$parttype" = "426f6f74-0000-11aa-aa11-00306543ecac" ]]; then
5593c8
+	  DEVICE="${subdevice}" osx_entry
5593c8
+	fi
5593c8
+      done
5593c8
     ;;
5593c8
     hurd)
5593c8
       onstr="$(gettext_printf "(on %s)" "${DEVICE}")"