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