diff options
author | Mike Gilbert <floppym@gentoo.org> | 2014-09-09 21:59:41 +0000 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2014-09-09 21:59:41 +0000 |
commit | 032d3032315c14d9d4776c1bd91152e3c898a8f6 (patch) | |
tree | 7672f09c729134fc87638e43c4cacbdadee3213a /sys-boot | |
parent | Version bump for bug 522060 (diff) | |
download | gentoo-2-032d3032315c14d9d4776c1bd91152e3c898a8f6.tar.gz gentoo-2-032d3032315c14d9d4776c1bd91152e3c898a8f6.tar.bz2 gentoo-2-032d3032315c14d9d4776c1bd91152e3c898a8f6.zip |
Backport several patches to resolve issues with grub-probe and grub-mkconfig. Bug 522428, thanks to Coacher.
(Portage version: 2.2.12/cvs/Linux x86_64, signed Manifest commit with key 0BBEEA1FEA4843A4)
Diffstat (limited to 'sys-boot')
7 files changed, 814 insertions, 1 deletions
diff --git a/sys-boot/grub/ChangeLog b/sys-boot/grub/ChangeLog index 85044f05866e..a1381cb9e2ab 100644 --- a/sys-boot/grub/ChangeLog +++ b/sys-boot/grub/ChangeLog @@ -1,6 +1,18 @@ # ChangeLog for sys-boot/grub # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/ChangeLog,v 1.314 2014/09/09 19:55:09 floppym Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/ChangeLog,v 1.315 2014/09/09 21:59:41 floppym Exp $ + +*grub-2.02_beta2-r1 (09 Sep 2014) + + 09 Sep 2014; Mike Gilbert <floppym@gentoo.org> +files/2.02_beta2/0001-Makefile + .util.def-Link-grub-ofpathname-with-zfs-libs.patch, +files/2.02_beta2/0002-gru + b-install-support-for-partitioned-partx-loop-devi.patch, + +files/2.02_beta2/0003-Fix-grub-probe-0-option.patch, +files/2.02_beta2/0004-F + ix-partmap-cryptodisk-and-abstraction-handling-in-g.patch, + +files/2.02_beta2/0005-Fix-typo-gettext_print-instead-of-gettext_printf.patch, + +grub-2.02_beta2-r1.ebuild: + Backport several patches to resolve issues with grub-probe and grub-mkconfig. + Bug 522428, thanks to Coacher. 09 Sep 2014; Mike Gilbert <floppym@gentoo.org> +files/grub-2.02_beta2-libzfs.patch, grub-2.02_beta2.ebuild: diff --git a/sys-boot/grub/files/2.02_beta2/0001-Makefile.util.def-Link-grub-ofpathname-with-zfs-libs.patch b/sys-boot/grub/files/2.02_beta2/0001-Makefile.util.def-Link-grub-ofpathname-with-zfs-libs.patch new file mode 100644 index 000000000000..0537fc872ab8 --- /dev/null +++ b/sys-boot/grub/files/2.02_beta2/0001-Makefile.util.def-Link-grub-ofpathname-with-zfs-libs.patch @@ -0,0 +1,28 @@ +From fd5146df14bdcb3fcae4ba8c72d816124a4598af Mon Sep 17 00:00:00 2001 +From: Mike Gilbert <floppym@gentoo.org> +Date: Sat, 18 Jan 2014 19:41:15 +0100 +Subject: [PATCH 1/5] * Makefile.util.def: Link grub-ofpathname with zfs + libs. + +Conflicts: + ChangeLog +--- + Makefile.util.def | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.util.def b/Makefile.util.def +index 985e76c..9bfe47e 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -384,7 +384,7 @@ program = { + ldadd = libgrubgcry.a; + ldadd = libgrubkern.a; + ldadd = grub-core/gnulib/libgnu.a; +- ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBGEOM)'; ++ ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + }; + + program = { +-- +2.1.0 + diff --git a/sys-boot/grub/files/2.02_beta2/0002-grub-install-support-for-partitioned-partx-loop-devi.patch b/sys-boot/grub/files/2.02_beta2/0002-grub-install-support-for-partitioned-partx-loop-devi.patch new file mode 100644 index 000000000000..f36e4d6526f9 --- /dev/null +++ b/sys-boot/grub/files/2.02_beta2/0002-grub-install-support-for-partitioned-partx-loop-devi.patch @@ -0,0 +1,42 @@ +From e407b6f1e9bf71877104eee2ed513b4065667f60 Mon Sep 17 00:00:00 2001 +From: Mike Gilbert <floppym@gentoo.org> +Date: Sun, 26 Jan 2014 02:56:04 +0100 +Subject: [PATCH 2/5] grub-install: support for partitioned partx loop + devices. + + * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect + /dev/loopX as being the parent of /dev/loopXpY. + +Conflicts: + ChangeLog +--- + grub-core/osdep/linux/getroot.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c +index 772de0a..19581d3 100644 +--- a/grub-core/osdep/linux/getroot.c ++++ b/grub-core/osdep/linux/getroot.c +@@ -883,6 +883,19 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, + *pp = '\0'; + return path; + } ++ ++ /* If this is a loop device */ ++ if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9') ++ { ++ char *pp = p + 4; ++ while (*pp >= '0' && *pp <= '9') ++ pp++; ++ if (*pp == 'p') ++ *is_part = 1; ++ /* /dev/loop[0-9]+p[0-9]* */ ++ *pp = '\0'; ++ return path; ++ } + } + + return path; +-- +2.1.0 + diff --git a/sys-boot/grub/files/2.02_beta2/0003-Fix-grub-probe-0-option.patch b/sys-boot/grub/files/2.02_beta2/0003-Fix-grub-probe-0-option.patch new file mode 100644 index 000000000000..ebf8eb922dec --- /dev/null +++ b/sys-boot/grub/files/2.02_beta2/0003-Fix-grub-probe-0-option.patch @@ -0,0 +1,43 @@ +From ed2d3ef84e798d42ec361d109485ec20eafe9831 Mon Sep 17 00:00:00 2001 +From: Colin Watson <cjwatson@ubuntu.com> +Date: Mon, 31 Mar 2014 13:51:17 +0100 +Subject: [PATCH 3/5] Fix grub-probe -0 option + +* util/grub-probe,c (options): Make -0 work again (broken by +conversion to argp). +(main): Simplify logic. + +Conflicts: + ChangeLog +--- + util/grub-probe.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/util/grub-probe.c b/util/grub-probe.c +index 1f3b59f..80509be 100644 +--- a/util/grub-probe.c ++++ b/util/grub-probe.c +@@ -711,6 +711,7 @@ static struct argp_option options[] = { + N_("use FILE as the device map [default=%s]"), 0}, + {"target", 't', N_("TARGET"), 0, 0, 0}, + {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, ++ {0, '0', 0, 0, N_("separate items in output using ASCII NUL characters"), 0}, + { 0, 0, 0, 0, 0, 0 } + }; + +@@ -884,11 +885,7 @@ main (int argc, char *argv[]) + else + probe (arguments.devices[0], NULL, delim); + +- if (!arguments.zero_delim && (print == PRINT_BIOS_HINT +- || print == PRINT_IEEE1275_HINT +- || print == PRINT_BAREMETAL_HINT +- || print == PRINT_EFI_HINT +- || print == PRINT_ARC_HINT)) ++ if (delim == ' ') + putchar ('\n'); + + /* Free resources. */ +-- +2.1.0 + diff --git a/sys-boot/grub/files/2.02_beta2/0004-Fix-partmap-cryptodisk-and-abstraction-handling-in-g.patch b/sys-boot/grub/files/2.02_beta2/0004-Fix-partmap-cryptodisk-and-abstraction-handling-in-g.patch new file mode 100644 index 000000000000..f047126cfc6c --- /dev/null +++ b/sys-boot/grub/files/2.02_beta2/0004-Fix-partmap-cryptodisk-and-abstraction-handling-in-g.patch @@ -0,0 +1,333 @@ +From 04461ee8175e18ea784301fd416b6e0dc574a288 Mon Sep 17 00:00:00 2001 +From: Colin Watson <cjwatson@ubuntu.com> +Date: Mon, 31 Mar 2014 14:48:33 +0100 +Subject: [PATCH 4/5] Fix partmap, cryptodisk, and abstraction handling in + grub-mkconfig. + +Commit 588744d0dc655177d5883bdcb8f72ff5160109ed caused grub-mkconfig +no longer to be forgiving of trailing spaces on grub-probe output +lines, which among other things means that util/grub.d/10_linux.in +no longer detects LVM. To fix this, make grub-probe's output +delimiting more consistent. As a bonus, this improves the coverage +of the -0 option. + +Fixes Debian bug #735935. + +* grub-core/disk/cryptodisk.c +(grub_util_cryptodisk_get_abstraction): Add a user-data argument. +* grub-core/disk/diskfilter.c (grub_diskfilter_get_partmap): +Likewise. +* include/grub/cryptodisk.h (grub_util_cryptodisk_get_abstraction): +Update prototype. +* include/grub/diskfilter.h (grub_diskfilter_get_partmap): Likewise. +* util/grub-install.c (push_partmap_module, push_cryptodisk_module, +probe_mods): Adjust for extra user-data arguments. +* util/grub-probe.c (do_print, probe_partmap, probe_cryptodisk_uuid, +probe_abstraction): Use configured delimiter. Update callers. + +Conflicts: + ChangeLog +--- + grub-core/disk/cryptodisk.c | 19 ++++++++++--------- + grub-core/disk/diskfilter.c | 5 +++-- + include/grub/cryptodisk.h | 3 ++- + include/grub/diskfilter.h | 3 ++- + util/grub-install.c | 14 ++++++++++---- + util/grub-probe.c | 46 ++++++++++++++++++++++----------------------- + 6 files changed, 49 insertions(+), 41 deletions(-) + +diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c +index 75c6e1f..f0e3a90 100644 +--- a/grub-core/disk/cryptodisk.c ++++ b/grub-core/disk/cryptodisk.c +@@ -762,25 +762,26 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name, + + void + grub_util_cryptodisk_get_abstraction (grub_disk_t disk, +- void (*cb) (const char *val)) ++ void (*cb) (const char *val, void *data), ++ void *data) + { + grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data; + +- cb ("cryptodisk"); +- cb (dev->modname); ++ cb ("cryptodisk", data); ++ cb (dev->modname, data); + + if (dev->cipher) +- cb (dev->cipher->cipher->modname); ++ cb (dev->cipher->cipher->modname, data); + if (dev->secondary_cipher) +- cb (dev->secondary_cipher->cipher->modname); ++ cb (dev->secondary_cipher->cipher->modname, data); + if (dev->essiv_cipher) +- cb (dev->essiv_cipher->cipher->modname); ++ cb (dev->essiv_cipher->cipher->modname, data); + if (dev->hash) +- cb (dev->hash->modname); ++ cb (dev->hash->modname, data); + if (dev->essiv_hash) +- cb (dev->essiv_hash->modname); ++ cb (dev->essiv_hash->modname, data); + if (dev->iv_hash) +- cb (dev->iv_hash->modname); ++ cb (dev->iv_hash->modname, data); + } + + const char * +diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c +index 28b70c6..e8a3bcb 100644 +--- a/grub-core/disk/diskfilter.c ++++ b/grub-core/disk/diskfilter.c +@@ -354,7 +354,8 @@ grub_diskfilter_memberlist (grub_disk_t disk) + + void + grub_diskfilter_get_partmap (grub_disk_t disk, +- void (*cb) (const char *pm)) ++ void (*cb) (const char *pm, void *data), ++ void *data) + { + struct grub_diskfilter_lv *lv = disk->data; + struct grub_diskfilter_pv *pv; +@@ -376,7 +377,7 @@ grub_diskfilter_get_partmap (grub_disk_t disk, + continue; + } + for (s = 0; pv->partmaps[s]; s++) +- cb (pv->partmaps[s]); ++ cb (pv->partmaps[s], data); + } + } + +diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h +index 66f3e1e..f2ad2a7 100644 +--- a/include/grub/cryptodisk.h ++++ b/include/grub/cryptodisk.h +@@ -145,7 +145,8 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name, + grub_disk_t source, const char *cheat); + void + grub_util_cryptodisk_get_abstraction (grub_disk_t disk, +- void (*cb) (const char *val)); ++ void (*cb) (const char *val, void *data), ++ void *data); + + char * + grub_util_get_geli_uuid (const char *dev); +diff --git a/include/grub/diskfilter.h b/include/grub/diskfilter.h +index 042fe04..1aedcd3 100644 +--- a/include/grub/diskfilter.h ++++ b/include/grub/diskfilter.h +@@ -202,7 +202,8 @@ grub_diskfilter_get_pv_from_disk (grub_disk_t disk, + struct grub_diskfilter_vg **vg); + void + grub_diskfilter_get_partmap (grub_disk_t disk, +- void (*cb) (const char *val)); ++ void (*cb) (const char *val, void *data), ++ void *data); + #endif + + #endif /* ! GRUB_RAID_H */ +diff --git a/util/grub-install.c b/util/grub-install.c +index 8cfe0ea..663166f 100644 +--- a/util/grub-install.c ++++ b/util/grub-install.c +@@ -381,7 +381,7 @@ probe_raid_level (grub_disk_t disk) + } + + static void +-push_partmap_module (const char *map) ++push_partmap_module (const char *map, void *data __attribute__ ((unused))) + { + char buf[50]; + +@@ -396,6 +396,12 @@ push_partmap_module (const char *map) + } + + static void ++push_cryptodisk_module (const char *mod, void *data __attribute__ ((unused))) ++{ ++ grub_install_push_module (mod); ++} ++ ++static void + probe_mods (grub_disk_t disk) + { + grub_partition_t part; +@@ -406,11 +412,11 @@ probe_mods (grub_disk_t disk) + grub_util_info ("no partition map found for %s", disk->name); + + for (part = disk->partition; part; part = part->parent) +- push_partmap_module (part->partmap->name); ++ push_partmap_module (part->partmap->name, NULL); + + if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID) + { +- grub_diskfilter_get_partmap (disk, push_partmap_module); ++ grub_diskfilter_get_partmap (disk, push_partmap_module, NULL); + have_abstractions = 1; + } + +@@ -426,7 +432,7 @@ probe_mods (grub_disk_t disk) + if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) + { + grub_util_cryptodisk_get_abstraction (disk, +- grub_install_push_module); ++ push_cryptodisk_module, NULL); + have_abstractions = 1; + have_cryptodisk = 1; + } +diff --git a/util/grub-probe.c b/util/grub-probe.c +index 80509be..ecb7b6b 100644 +--- a/util/grub-probe.c ++++ b/util/grub-probe.c +@@ -130,13 +130,14 @@ get_targets_string (void) + } + + static void +-do_print (const char *x) ++do_print (const char *x, void *data) + { +- grub_printf ("%s ", x); ++ char delim = *(const char *) data; ++ grub_printf ("%s%c", x, delim); + } + + static void +-probe_partmap (grub_disk_t disk) ++probe_partmap (grub_disk_t disk, char delim) + { + grub_partition_t part; + grub_disk_memberlist_t list = NULL, tmp; +@@ -147,10 +148,10 @@ probe_partmap (grub_disk_t disk) + } + + for (part = disk->partition; part; part = part->parent) +- printf ("%s ", part->partmap->name); ++ printf ("%s%c", part->partmap->name, delim); + + if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID) +- grub_diskfilter_get_partmap (disk, do_print); ++ grub_diskfilter_get_partmap (disk, do_print, &delim); + + /* In case of LVM/RAID, check the member devices as well. */ + if (disk->dev->memberlist) +@@ -159,7 +160,7 @@ probe_partmap (grub_disk_t disk) + } + while (list) + { +- probe_partmap (list->disk); ++ probe_partmap (list->disk, delim); + tmp = list->next; + free (list); + list = tmp; +@@ -167,7 +168,7 @@ probe_partmap (grub_disk_t disk) + } + + static void +-probe_cryptodisk_uuid (grub_disk_t disk) ++probe_cryptodisk_uuid (grub_disk_t disk, char delim) + { + grub_disk_memberlist_t list = NULL, tmp; + +@@ -178,7 +179,7 @@ probe_cryptodisk_uuid (grub_disk_t disk) + } + while (list) + { +- probe_cryptodisk_uuid (list->disk); ++ probe_cryptodisk_uuid (list->disk, delim); + tmp = list->next; + free (list); + list = tmp; +@@ -186,7 +187,7 @@ probe_cryptodisk_uuid (grub_disk_t disk) + if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) + { + const char *uu = grub_util_cryptodisk_get_uuid (disk); +- grub_printf ("%s ", uu); ++ grub_printf ("%s%c", uu, delim); + } + } + +@@ -210,7 +211,7 @@ probe_raid_level (grub_disk_t disk) + } + + static void +-probe_abstraction (grub_disk_t disk) ++probe_abstraction (grub_disk_t disk, char delim) + { + grub_disk_memberlist_t list = NULL, tmp; + int raid_level; +@@ -219,7 +220,7 @@ probe_abstraction (grub_disk_t disk) + list = disk->dev->memberlist (disk); + while (list) + { +- probe_abstraction (list->disk); ++ probe_abstraction (list->disk, delim); + + tmp = list->next; + free (list); +@@ -229,26 +230,26 @@ probe_abstraction (grub_disk_t disk) + if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID + && (grub_memcmp (disk->name, "lvm/", sizeof ("lvm/") - 1) == 0 || + grub_memcmp (disk->name, "lvmid/", sizeof ("lvmid/") - 1) == 0)) +- printf ("lvm "); ++ printf ("lvm%c", delim); + + if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID + && grub_memcmp (disk->name, "ldm/", sizeof ("ldm/") - 1) == 0) +- printf ("ldm "); ++ printf ("ldm%c", delim); + + if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) +- grub_util_cryptodisk_get_abstraction (disk, do_print); ++ grub_util_cryptodisk_get_abstraction (disk, do_print, &delim); + + raid_level = probe_raid_level (disk); + if (raid_level >= 0) + { +- printf ("diskfilter "); ++ printf ("diskfilter%c", delim); + if (disk->dev->raidname) +- printf ("%s ", disk->dev->raidname (disk)); ++ printf ("%s%c", disk->dev->raidname (disk), delim); + } + if (raid_level == 5) +- printf ("raid5rec "); ++ printf ("raid5rec%c", delim); + if (raid_level == 6) +- printf ("raid6rec "); ++ printf ("raid6rec%c", delim); + } + + static void +@@ -630,16 +631,14 @@ probe (const char *path, char **device_names, char delim) + + if (print == PRINT_ABSTRACTION) + { +- probe_abstraction (dev->disk); +- putchar (delim); ++ probe_abstraction (dev->disk, delim); + grub_device_close (dev); + continue; + } + + if (print == PRINT_CRYPTODISK_UUID) + { +- probe_cryptodisk_uuid (dev->disk); +- putchar (delim); ++ probe_cryptodisk_uuid (dev->disk, delim); + grub_device_close (dev); + continue; + } +@@ -647,8 +646,7 @@ probe (const char *path, char **device_names, char delim) + if (print == PRINT_PARTMAP) + { + /* Check if dev->disk itself is contained in a partmap. */ +- probe_partmap (dev->disk); +- putchar (delim); ++ probe_partmap (dev->disk, delim); + grub_device_close (dev); + continue; + } +-- +2.1.0 + diff --git a/sys-boot/grub/files/2.02_beta2/0005-Fix-typo-gettext_print-instead-of-gettext_printf.patch b/sys-boot/grub/files/2.02_beta2/0005-Fix-typo-gettext_print-instead-of-gettext_printf.patch new file mode 100644 index 000000000000..be2c09265b3f --- /dev/null +++ b/sys-boot/grub/files/2.02_beta2/0005-Fix-typo-gettext_print-instead-of-gettext_printf.patch @@ -0,0 +1,27 @@ +From 61dcf8704027844fbcad45ef13452e996ca02c41 Mon Sep 17 00:00:00 2001 +From: Andrey Borzenkov <arvidjaar@gmail.com> +Date: Thu, 14 Aug 2014 21:02:31 +0400 +Subject: [PATCH 5/5] Fix typo (gettext_print instead of gettext_printf) + +Conflicts: + ChangeLog +--- + util/grub-mkconfig.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index ca040dd..d1fae49 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -124,7 +124,7 @@ set $grub_probe dummy + if test -f "$1"; then + : + else +- gettext_print "%s: Not found.\n" "$1" 1>&2 ++ gettext_printf "%s: Not found.\n" "$1" 1>&2 + exit 1 + fi + +-- +2.1.0 + diff --git a/sys-boot/grub/grub-2.02_beta2-r1.ebuild b/sys-boot/grub/grub-2.02_beta2-r1.ebuild new file mode 100644 index 000000000000..9595dfde6fa1 --- /dev/null +++ b/sys-boot/grub/grub-2.02_beta2-r1.ebuild @@ -0,0 +1,328 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/grub-2.02_beta2-r1.ebuild,v 1.1 2014/09/09 21:59:41 floppym Exp $ + +EAPI=5 + +AUTOTOOLS_AUTORECONF=1 +GRUB_AUTOGEN=1 + +if [[ -n ${GRUB_AUTOGEN} ]]; then + PYTHON_COMPAT=( python{2_6,2_7,3_2,3_3,3_4} ) + inherit python-any-r1 +fi + +inherit autotools-utils bash-completion-r1 eutils flag-o-matic mount-boot multibuild pax-utils toolchain-funcs versionator + +if [[ ${PV} != 9999 ]]; then + if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then + # The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860 + MY_P=${P/_/'~'} + SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz" + S=${WORKDIR}/${MY_P} + else + SRC_URI="mirror://gnu/${PN}/${P}.tar.xz + mirror://gentoo/${P}.tar.xz + http://dev.gentoo.org/~floppym/dist/${P}.tar.xz" + S=${WORKDIR}/${P%_*} + fi + KEYWORDS="~amd64 ~x86" + PATCHES=() +else + inherit git-r3 + EGIT_REPO_URI="git://git.sv.gnu.org/grub.git + http://git.savannah.gnu.org/r/grub.git" +fi + +DEJAVU=dejavu-sans-ttf-2.34 +UNIFONT=unifont-7.0.01 +SRC_URI+=" truetype? ( + mirror://sourceforge/dejavu/${DEJAVU}.zip + mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz +)" + +DESCRIPTION="GNU GRUB boot loader" +HOMEPAGE="http://www.gnu.org/software/grub/" + +# Includes licenses for dejavu and unifont +LICENSE="GPL-3 truetype? ( BitstreamVera GPL-2-with-font-exception )" +SLOT="2" +IUSE="debug device-mapper doc efiemu mount +multislot nls static sdl test truetype libzfs" + +GRUB_ALL_PLATFORMS=( + # everywhere: + emu + # mips only: + qemu-mips yeeloong + # amd64, x86, ppc, ppc64: + ieee1275 + # amd64, x86: + coreboot multiboot efi-32 pc qemu xen + # amd64, ia64: + efi-64 +) +IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}" + +REQUIRED_USE="grub_platforms_qemu? ( truetype ) + grub_platforms_yeeloong? ( truetype )" + +# os-prober: Used on runtime to detect other OSes +# xorriso (dev-libs/libisoburn): Used on runtime for mkrescue +RDEPEND=" + app-arch/xz-utils + >=sys-libs/ncurses-5.2-r5 + debug? ( + sdl? ( media-libs/libsdl ) + ) + device-mapper? ( >=sys-fs/lvm2-2.02.45 ) + libzfs? ( sys-fs/zfs ) + mount? ( sys-fs/fuse ) + truetype? ( media-libs/freetype ) + ppc? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils ) + ppc64? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils ) +" +DEPEND="${RDEPEND} + ${PYTHON_DEPS} + app-misc/pax-utils + sys-devel/flex + sys-devel/bison + sys-apps/help2man + sys-apps/texinfo + grub_platforms_xen? ( app-emulation/xen-tools ) + static? ( + app-arch/xz-utils[static-libs(+)] + truetype? ( + app-arch/bzip2[static-libs(+)] + media-libs/freetype[static-libs(+)] + sys-libs/zlib[static-libs(+)] + ) + ) + test? ( + dev-libs/libisoburn + app-emulation/qemu + ) + truetype? ( app-arch/unzip ) +" +RDEPEND+=" + kernel_linux? ( + grub_platforms_efi-32? ( sys-boot/efibootmgr ) + grub_platforms_efi-64? ( sys-boot/efibootmgr ) + ) + !multislot? ( !sys-boot/grub:0 ) + nls? ( sys-devel/gettext ) +" + +STRIP_MASK="*/grub/*/*.{mod,img}" +RESTRICT="test" + +QA_EXECSTACK=" + usr/bin/grub*-emu* + usr/lib*/grub/*/*.mod + usr/lib*/grub/*/*.module + usr/lib*/grub/*/kernel.exec + usr/lib*/grub/*/kernel.img +" + +QA_WX_LOAD=" + usr/lib*/grub/*/kernel.exec + usr/lib*/grub/*/kernel.img + usr/lib*/grub/*/*.image +" + +QA_PRESTRIPPED=" + usr/lib.*/grub/.*/kernel.img +" + +pkg_pretend() { + if [[ ${MERGE_TYPE} != binary ]]; then + # Bug 439082 + if ! version_is_at_least 4.8 "$(gcc-version)" && + $(tc-getLD) --version | grep -q "GNU gold"; then + eerror "GRUB does not function correctly when built with the gold linker." + eerror "Please select the bfd linker with binutils-config." + die "GNU gold detected" + fi + fi +} + +src_unpack() { + if [[ ${PV} == 9999 ]]; then + git-r3_src_unpack + fi + default_src_unpack +} + +src_prepare() { + EPATCH_SOURCE="${FILESDIR}/${PV}" \ + EPATCH_SUFFIX="patch" \ + EPATCH_FORCE="yes" \ + epatch + + [[ ${PATCHES} ]] && epatch "${PATCHES[@]}" + + sed -i -e /autoreconf/d autogen.sh || die + + if use multislot; then + # fix texinfo file name, bug 416035 + sed -i -e 's/^\* GRUB:/* GRUB2:/' -e 's/(grub)/(grub2)/' docs/grub.texi || die + fi + + epatch_user + + if [[ -n ${GRUB_AUTOGEN} ]]; then + python_setup + bash autogen.sh || die + fi + + if [[ -n ${AUTOTOOLS_AUTORECONF} ]]; then + autopoint() { return 0; } + eautoreconf + fi +} + +setup_fonts() { + ln -s "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die + ln -s "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die +} + +grub_configure() { + local platform + + case ${MULTIBUILD_VARIANT} in + efi-32) + platform=efi + if [[ ${CTARGET:-${CHOST}} == x86_64* ]]; then + local CTARGET=${CTARGET:-i386} + fi ;; + efi-64) + platform=efi + if [[ ${CTARGET:-${CHOST}} == i?86* ]]; then + local CTARGET=${CTARGET:-x86_64} + local TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}" + local TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}" + export TARGET_CFLAGS TARGET_CPPFLAGS + fi ;; + guessed) ;; + *) platform=${MULTIBUILD_VARIANT} ;; + esac + + local myeconfargs=( + --disable-werror + --program-prefix= + --libdir="${EPREFIX}"/usr/lib + --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html + $(use_enable debug mm-debug) + $(use_enable debug grub-emu-usb) + $(use_enable device-mapper) + $(use_enable mount grub-mount) + $(use_enable nls) + $(use_enable truetype grub-mkfont) + $(use_enable libzfs) + $(use sdl && use_enable debug grub-emu-sdl) + ${platform:+--with-platform=}${platform} + + # Let configure detect this where supported + $(usex efiemu '' '--disable-efiemu') + ) + + if use multislot; then + myeconfargs+=( --program-transform-name="s,grub,grub2," ) + fi + + if use truetype; then + mkdir -p "${BUILD_DIR}" || die + run_in_build_dir setup_fonts + fi + + autotools-utils_src_configure +} + +src_configure() { + # Bug 508758. + replace-flags -O3 -O2 + + # We don't want to leak flags onto boot code. + export HOST_CCASFLAGS=${CCASFLAGS} + export HOST_CFLAGS=${CFLAGS} + export HOST_CPPFLAGS=${CPPFLAGS} + export HOST_LDFLAGS=${LDFLAGS} + unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS + + use static && HOST_LDFLAGS+=" -static" + + if version_is_at_least 4.8 "$(gcc-version)"; then + export TARGET_LDFLAGS+=" -fuse-ld=bfd" + fi + + tc-export CC NM OBJCOPY STRIP + export TARGET_CC=${TARGET_CC:-${CC}} + tc-export BUILD_CC # Bug 485592 + + # Portage will take care of cleaning up GRUB_PLATFORMS + MULTIBUILD_VARIANTS=( ${GRUB_PLATFORMS:-guessed} ) + multibuild_parallel_foreach_variant grub_configure +} + +src_compile() { + # Sandbox bug 404013. + use libzfs && addpredict /etc/dfs:/dev/zfs + + multibuild_foreach_variant autotools-utils_src_compile + + use doc && multibuild_for_best_variant \ + autotools-utils_src_compile -C docs html +} + +src_test() { + # The qemu dependency is a bit complex. + # You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform. + multibuild_foreach_variant autotools-utils_src_test +} + +src_install() { + multibuild_foreach_variant autotools-utils_src_install \ + bashcompletiondir="$(get_bashcompdir)" + + use doc && multibuild_for_best_variant run_in_build_dir \ + emake -C docs DESTDIR="${D}" install-html + + if use multislot; then + mv "${ED%/}"/usr/share/info/grub{,2}.info || die + fi + + insinto /etc/default + newins "${FILESDIR}"/grub.default-3 grub +} + +pkg_postinst() { + mount-boot_mount_boot_partition + + if [[ -e "${ROOT%/}/boot/grub2/grub.cfg" ]]; then + ewarn "The grub directory has changed from /boot/grub2 to /boot/grub." + ewarn "Please run grub2-install and grub2-mkconfig -o /boot/grub/grub.cfg." + + if [[ ! -e "${ROOT%/}/boot/grub/grub.cfg" ]]; then + mkdir -p "${ROOT%/}/boot/grub" + ln -s ../grub2/grub.cfg "${ROOT%/}/boot/grub/grub.cfg" + fi + fi + + mount-boot_pkg_postinst + + elog "For information on how to configure GRUB2 please refer to the guide:" + elog " http://wiki.gentoo.org/wiki/GRUB2_Quick_Start" + + if has_version 'sys-boot/grub:0'; then + elog "A migration guide for GRUB Legacy users is available:" + elog " http://www.gentoo.org/doc/en/grub2-migration.xml" + fi + + if [[ -z ${REPLACING_VERSIONS} ]]; then + if ! has_version sys-boot/os-prober; then + elog "Install sys-boot/os-prober to enable detection of other operating systems using grub2-mkconfig." + fi + if ! has_version dev-libs/libisoburn; then + elog "Install dev-libs/libisoburn to enable creation of rescue media using grub2-mkrescue." + fi + fi +} |