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

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