grub2/grub-2.00~beta4-add-support-for-PowerMac-HFS-partitions.patch

95 lines
4.4 KiB
Diff
Raw Normal View History

2012-04-26 14:19:48 +00:00
From f2dc76d4d82ac9bbe5ccb4e8ccc49c14e8574c20 Mon Sep 17 00:00:00 2001
From: Fedora Ninjas <pjones@fedoraproject.org>
Date: Wed, 25 Apr 2012 13:09:15 +0200
Subject: [PATCH 2/2] add support for PowerMac HFS partitions
Signed-off-by: Fedora PPC secondary arch maintainer <karsten@fedoraproject.org>
---
util/grub-install.in | 67 ++++++++++++++++++++++++++++++++------------------
1 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/util/grub-install.in b/util/grub-install.in
index 26be9d9..f1f9bae 100644
--- a/util/grub-install.in
+++ b/util/grub-install.in
@@ -757,33 +757,52 @@ elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-ieee1275" ]
# If a install device is defined, copy the core.elf to PReP partition.
else
- if [ "$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t msdos_parttype)" != "41" ]; then
- gettext "The chosen partition is not a PReP partition." 1>&2
- echo 1>&2
- exit 1
- fi
-
+ if [ "$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t msdos_parttype)" = "41" ]; then
2012-05-10 20:25:33 +00:00
if [ "$(file -s "${install_device}" -b | awk '{ print $1 }')" = ELF ] || (cmp -s -n $(blockdev --getsize64 ${install_device}) /dev/zero "${install_device}"); then
2012-04-26 14:19:48 +00:00
- # Change boot device to the harddisk root
- boot_device="$ofpath"
- dd if="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" of="${install_device}" status=noxfer || {
- gettext "Failed to copy Grub to the PReP partition." 1>&2
- echo 1>&2
- exit 1
- }
+ # Change boot device to the harddisk root
+ boot_device="$ofpath"
+ dd if="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" of="${install_device}" status=noxfer || {
+ gettext "Failed to copy Grub to the PReP partition." 1>&2
+ echo 1>&2
+ exit 1
+ }
else
- gettext "The PReP partition is not empty. If you are sure you want to use it, run dd to clear it:" 1>&2
- echo 1>&2
- echo " dd if=/dev/zero of=${install_device}"
- exit 1
+ gettext "The PReP partition is not empty. If you are sure you want to use it, run dd to clear it:" 1>&2
+ echo 1>&2
+ echo " dd if=/dev/zero of=${install_device}"
+ exit 1
fi
- dev="`echo "${install_device}" | sed -e 's/\/dev\///' -e 's/[0-9]\+//'`"
- boot_device="`$ofpathname "$dev"`" || {
- # TRANSLATORS: "device tree path" is the name of the device
- # for IEEE1275
- gettext_printf "Couldn't find IEEE1275 device tree path for %s.\nYou will have to set \`boot-device' variable manually.\n" "$dev" 1>&2
- exit 1
- }
+ dev="`echo "${install_device}" | sed -e 's/\/dev\///' -e 's/[0-9]\+//'`"
+ boot_device="`$ofpathname "$dev"`" || {
+ # TRANSLATORS: "device tree path" is the name of the device
+ # for IEEE1275
+ gettext_printf "Couldn't find IEEE1275 device tree path for %s.\nYou will have to set \`boot-device' variable manually.\n" "$dev" 1>&2
+ exit 1
+ }
+ else
+ hmount ${install_device} >/dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ humount "${install_device}"
+ # Change boot device to the harddisk root
+ boot_device="$ofpath"
+ hmount "${install_device}"
+ hcopy "${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}" ":" || {
+ gettext "Failed to copy Grub to the HFS partition." 1>&2
+ gettext "Maybe the HFS partition is not empty. If you are sure you want to use it, run hformat to clear it:" 1>&2
+ echo 1>&2
+ echo " hformat ${install_device}"
+ exit 1
+ }
+ humount "${install_device}"
+ # We're on PowerMac, it's either /dev/sdaX or /dev/hdaX:
+ dev="`echo "${install_device}" | sed -e 's/\/dev\/.da//'`"
+ boot_device="hd:${dev},core.${imgext}"
+ else
+ gettext "The chosen partition is neither a PReP nor a HFS partition." 1>&2
+ echo 1>&2
+ exit 1
+ fi
+ fi
fi
"$nvsetenv" boot-device "$boot_device" || {
--
1.7.6.5