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