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