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