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

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