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

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