From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ROrgf-0000aZ-50 for mharc-grub-devel@gnu.org; Fri, 11 Nov 2011 09:02:33 -0500 Received: from eggs.gnu.org ([140.186.70.92]:49984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROrgW-0000Z9-Ui for grub-devel@gnu.org; Fri, 11 Nov 2011 09:02:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROrgV-0002Hx-5P for grub-devel@gnu.org; Fri, 11 Nov 2011 09:02:24 -0500 Received: from e24smtp02.br.ibm.com ([32.104.18.86]:52272) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROrgU-0002Gy-Mu for grub-devel@gnu.org; Fri, 11 Nov 2011 09:02:23 -0500 Received: from /spool/local by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Nov 2011 12:02:16 -0200 Received: from mailhub3.br.ibm.com ([9.18.232.110]) by e24smtp02.br.ibm.com ([10.172.0.142]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 11 Nov 2011 12:02:14 -0200 Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.8.31.93]) by mailhub3.br.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pABE2YUN803026 for ; Fri, 11 Nov 2011 12:02:36 -0200 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pABE2915003898 for ; Fri, 11 Nov 2011 12:02:09 -0200 Received: from maverick.localdomain ([9.18.198.159]) by d24av02.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pABE29Mb003872 for ; Fri, 11 Nov 2011 12:02:09 -0200 Message-ID: <4EBD2AE0.7020200@linux.vnet.ibm.com> Date: Fri, 11 Nov 2011 12:02:08 -0200 From: Paulo de Rezende Pinatti User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: [PATCH] Enable install of grub2 in PReP partition Content-Type: multipart/mixed; boundary="------------000504030801070504090305" x-cbid: 11111114-2194-0000-0000-0000001C60D7 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.104.18.86 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2011 14:02:30 -0000 This is a multi-part message in MIME format. --------------000504030801070504090305 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, This patch will enable the install and run of Grub 2 in the PReP partition for PowerPC machines. This procedure will only be used if a install_device argument is used with grub-install, otherwise it will be installed by the old way. Best Regards -- Paulo de Rezende Pinatti Staff Software Engineer, LTC Brazil --------------000504030801070504090305 Content-Type: text/plain; name="grub-install-prep.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="grub-install-prep.patch" === modified file 'util/grub-install.in' --- util/grub-install.in 2011-11-05 11:15:07 +0000 +++ util/grub-install.in 2011-11-11 00:06:00 +0000 @@ -273,8 +273,7 @@ exit 1 fi -if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] \ - || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then +if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${platform}" = "ieee1275" ]); then install_device= fi @@ -643,6 +642,28 @@ # Point boot-device at the new grub install boot_device="$ofpath:$partno,"`"$grub_mkrelpath" "${grubdir}/core.${imgext}" | sed 's,/,\\\\,g'` + + # If a install device is defined, copy the core.elf to PReP partition. + if [ "${target_cpu}" = "powerpc" ] && [ -n "${install_device}" ]; then + if [ "$(${grub_probe} -m ${device_map} -d ${install_device} -t msdos_parttype)" != "41" ]; then + echo "The chosen partition is not a PReP partition." + exit 1 + fi + + if [ "$(file -s ${install_device} -b | awk '{ print $1 }')" = ELF ] || [ $(cmp /dev/zero ${install_device} &>/dev/null) ]; then + # Change boot device to the harddisk root + boot_device="$ofpath" + dd if=${grubdir}/core.${imgext} of=${install_device} 2>/dev/null || { + echo "Failed to copy Grub to the PReP partition." + exit 1 + } + else + echo "The PReP partition is not empty. If you are sure you want to use it, run dd to clear it:" + echo " dd if=/dev/zero of=${install_device}" + exit 1 + fi + fi + "$nvsetenv" boot-device "$boot_device" || { echo "$nvsetenv failed." echo "You will have to set boot-device manually. At the Open Firmware prompt, type:" === modified file 'util/grub-probe.c' --- util/grub-probe.c 2011-11-08 11:38:30 +0000 +++ util/grub-probe.c 2011-11-11 00:02:52 +0000 @@ -55,7 +55,8 @@ PRINT_DEVICE, PRINT_PARTMAP, PRINT_ABSTRACTION, - PRINT_CRYPTODISK_UUID + PRINT_CRYPTODISK_UUID, + PRINT_MSDOS_PARTTYPE }; int print = PRINT_FS; @@ -231,6 +232,20 @@ goto end; } + if (print == PRINT_MSDOS_PARTTYPE) + { + if (dev->disk->partition == NULL) + { + grub_util_info ("no partition map found for %s", dev->disk->name); + } + + if (strcmp(dev->disk->partition->partmap->name, "msdos") == 0) + printf ("%02x", dev->disk->partition->msdostype); + + printf ("\n"); + goto end; + } + fs = grub_fs_probe (dev); if (! fs) grub_util_error ("%s", grub_errmsg); @@ -296,7 +311,7 @@ \n\ -d, --device given argument is a system device, not a path\n\ -m, --device-map=FILE use FILE as the device map [default=%s]\n\ - -t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid)\n\ + -t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|cryptodisk_uuid|msdos_parttype)\n\ print filesystem module, GRUB drive, system device, partition map module, abstraction module or CRYPTO UUID [default=fs]\n\ -h, --help display this message and exit\n\ -V, --version print version information and exit\n\ @@ -357,6 +372,8 @@ print = PRINT_ABSTRACTION; else if (!strcmp (optarg, "cryptodisk_uuid")) print = PRINT_CRYPTODISK_UUID; + else if (!strcmp (optarg, "msdos_parttype")) + print = PRINT_MSDOS_PARTTYPE; else usage (1); break; --------------000504030801070504090305--