Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-boot/grub/files/, sys-boot/grub/
Date: Fri, 01 Jan 2016 00:49:23
Message-Id: 1451609259.d05d046b70a1f469c42ad26ce35140d6a4bbd800.robbat2@gentoo
1 commit: d05d046b70a1f469c42ad26ce35140d6a4bbd800
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jan 1 00:47:39 2016 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Fri Jan 1 00:47:39 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d05d046b
7
8 sys-boot/grub: backport LVM fix & configurable kernel globs
9
10 - Backport upstream LVM RAID1 fix
11 - GRUB_LINUX_KERNEL_GLOBS to tweak globs for finding kernels
12
13 Package-Manager: portage-2.2.24
14
15 .../grub/files/grub-2.02_beta2-KERNEL_GLOBS.patch | 67 +++++
16 .../grub/files/grub-2.02_beta2-lvm2-raid1.patch | 68 +++++
17 sys-boot/grub/grub-2.02_beta2-r9.ebuild | 324 +++++++++++++++++++++
18 3 files changed, 459 insertions(+)
19
20 diff --git a/sys-boot/grub/files/grub-2.02_beta2-KERNEL_GLOBS.patch b/sys-boot/grub/files/grub-2.02_beta2-KERNEL_GLOBS.patch
21 new file mode 100644
22 index 0000000..c66ee68
23 --- /dev/null
24 +++ b/sys-boot/grub/files/grub-2.02_beta2-KERNEL_GLOBS.patch
25 @@ -0,0 +1,67 @@
26 +From 43e3295aaad5278a1e53c5282e2660b72cd76d28 Mon Sep 17 00:00:00 2001
27 +From: "Robin H. Johnson" <robbat2@g.o>
28 +Date: Tue, 29 Dec 2015 15:29:14 -0800
29 +Subject: [PATCH] GRUB_LINUX_KERNEL_GLOBS: configurable kernel selection
30 +
31 +* util/grub.d/10_linux.in: Implement GRUB_LINUX_KERNEL_GLOBS
32 +* docs/grub.texi: Document GRUB_LINUX_KERNEL_GLOBS
33 +
34 +Signed-off-by: Robin H. Johnson <robbat2@g.o>
35 +---
36 + docs/grub.texi | 5 +++++
37 + util/grub.d/10_linux.in | 21 +++++++++++----------
38 + 2 files changed, 16 insertions(+), 10 deletions(-)
39 +
40 +diff --git a/docs/grub.texi b/docs/grub.texi
41 +index 9a25a0b..d1129ec 100644
42 +--- a/docs/grub.texi
43 ++++ b/docs/grub.texi
44 +@@ -1490,6 +1490,11 @@ This option may be set to a list of GRUB module names separated by spaces.
45 + Each module will be loaded as early as possible, at the start of
46 + @file{grub.cfg}.
47 +
48 ++@item GRUB_LINUX_KERNEL_GLOBS
49 ++This option may be set to override the list of path globs used to find Linux
50 ++kernels. The defaults vary by architecture, and generally include both
51 ++@file{/boot} and @file{/}.
52 ++
53 + @end table
54 +
55 + The following options are still accepted for compatibility with existing
56 +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
57 +index 859b608..e5ac11d 100644
58 +--- a/util/grub.d/10_linux.in
59 ++++ b/util/grub.d/10_linux.in
60 +@@ -145,18 +145,19 @@ EOF
61 + }
62 +
63 + machine=`uname -m`
64 +-case "x$machine" in
65 ++globs="$GRUB_LINUX_KERNEL_GLOBS"
66 ++[ -z "$globs" ] && case "x$machine" in
67 + xi?86 | xx86_64)
68 +- list=
69 +- for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
70 +- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
71 +- done ;;
72 +- *)
73 +- list=
74 +- for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
75 +- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
76 +- done ;;
77 ++ globs="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*"
78 ++ ;;
79 ++ *)
80 ++ globs="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-*"
81 ++ ;;
82 + esac
83 ++list=
84 ++for i in ${globs} ; do
85 ++ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
86 ++done
87 +
88 + case "$machine" in
89 + i?86) GENKERNEL_ARCH="x86" ;;
90 +--
91 +2.3.0
92 +
93
94 diff --git a/sys-boot/grub/files/grub-2.02_beta2-lvm2-raid1.patch b/sys-boot/grub/files/grub-2.02_beta2-lvm2-raid1.patch
95 new file mode 100644
96 index 0000000..76c72a6
97 --- /dev/null
98 +++ b/sys-boot/grub/files/grub-2.02_beta2-lvm2-raid1.patch
99 @@ -0,0 +1,68 @@
100 +From: Andrei Borzenkov <arvidjaar@×××××.com>
101 +Date: Thu, 19 Mar 2015 18:30:27 +0000 (+0300)
102 +Subject: core: add LVM RAID1 support
103 +X-Git-Url: http://git.savannah.gnu.org/gitweb/?p=grub.git;a=commitdiff_plain;h=527eeeeee6c8d3d8e3bb1fac408d47bb1dcbec95;hp=7c9309e50a124817e67de38b30c6291acecad560
104 +
105 +core: add LVM RAID1 support
106 +
107 +Closes 44534.
108 +---
109 +
110 +diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
111 +index 1e7f197..9b97004 100644
112 +--- a/grub-core/disk/lvm.c
113 ++++ b/grub-core/disk/lvm.c
114 +@@ -577,13 +577,17 @@ grub_lvm_detect (grub_disk_t disk,
115 + if (is_pvmove)
116 + seg->node_count = 1;
117 + }
118 +- else if (grub_memcmp (p, "raid", sizeof ("raid") - 1)
119 +- == 0 && (p[sizeof ("raid") - 1] >= '4'
120 +- && p[sizeof ("raid") - 1] <= '6')
121 ++ else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) == 0
122 ++ && ((p[sizeof ("raid") - 1] >= '4'
123 ++ && p[sizeof ("raid") - 1] <= '6')
124 ++ || p[sizeof ("raid") - 1] == '1')
125 + && p[sizeof ("raidX") - 1] == '"')
126 + {
127 + switch (p[sizeof ("raid") - 1])
128 + {
129 ++ case '1':
130 ++ seg->type = GRUB_DISKFILTER_MIRROR;
131 ++ break;
132 + case '4':
133 + seg->type = GRUB_DISKFILTER_RAID4;
134 + seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC;
135 +@@ -608,16 +612,18 @@ grub_lvm_detect (grub_disk_t disk,
136 + goto lvs_segment_fail;
137 + }
138 +
139 +- seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
140 +- if (p == NULL)
141 ++ if (seg->type != GRUB_DISKFILTER_MIRROR)
142 + {
143 ++ seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
144 ++ if (p == NULL)
145 ++ {
146 + #ifdef GRUB_UTIL
147 +- grub_util_info ("unknown stripe_size\n");
148 ++ grub_util_info ("unknown stripe_size\n");
149 + #endif
150 +- goto lvs_segment_fail;
151 ++ goto lvs_segment_fail;
152 ++ }
153 + }
154 +
155 +-
156 + seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
157 + * seg->node_count);
158 +
159 +@@ -625,7 +631,7 @@ grub_lvm_detect (grub_disk_t disk,
160 + if (p == NULL)
161 + {
162 + #ifdef GRUB_UTIL
163 +- grub_util_info ("unknown mirrors\n");
164 ++ grub_util_info ("unknown raids\n");
165 + #endif
166 + goto lvs_segment_fail2;
167 + }
168
169 diff --git a/sys-boot/grub/grub-2.02_beta2-r9.ebuild b/sys-boot/grub/grub-2.02_beta2-r9.ebuild
170 new file mode 100644
171 index 0000000..4c43465
172 --- /dev/null
173 +++ b/sys-boot/grub/grub-2.02_beta2-r9.ebuild
174 @@ -0,0 +1,324 @@
175 +# Copyright 1999-2015 Gentoo Foundation
176 +# Distributed under the terms of the GNU General Public License v2
177 +# $Id$
178 +
179 +EAPI=5
180 +
181 +AUTOTOOLS_AUTORECONF=1
182 +GRUB_AUTOGEN=1
183 +
184 +if [[ -n ${GRUB_AUTOGEN} ]]; then
185 + PYTHON_COMPAT=( python{2_7,3_3,3_4} )
186 + inherit python-any-r1
187 +fi
188 +
189 +inherit autotools-utils bash-completion-r1 eutils flag-o-matic mount-boot multibuild pax-utils toolchain-funcs versionator
190 +
191 +if [[ ${PV} != 9999 ]]; then
192 + if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then
193 + # The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860
194 + MY_P=${P/_/'~'}
195 + SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz
196 + https://dev.gentoo.org/~floppym/dist/${P}-gentoo-r3.tar.xz"
197 + S=${WORKDIR}/${MY_P}
198 + else
199 + SRC_URI="mirror://gnu/${PN}/${P}.tar.xz
200 + https://dev.gentoo.org/~floppym/dist/${P}.tar.xz"
201 + S=${WORKDIR}/${P%_*}
202 + fi
203 + KEYWORDS="~amd64 ~x86"
204 +else
205 + inherit git-r3
206 + EGIT_REPO_URI="git://git.sv.gnu.org/grub.git
207 + http://git.savannah.gnu.org/r/grub.git"
208 +fi
209 +
210 +DEJAVU=dejavu-sans-ttf-2.34
211 +UNIFONT=unifont-7.0.06
212 +SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz )
213 + themes? ( mirror://sourceforge/dejavu/${DEJAVU}.zip )"
214 +
215 +DESCRIPTION="GNU GRUB boot loader"
216 +HOMEPAGE="https://www.gnu.org/software/grub/"
217 +
218 +# Includes licenses for dejavu and unifont
219 +LICENSE="GPL-3 fonts? ( GPL-2-with-font-exception ) themes? ( BitstreamVera )"
220 +SLOT="2"
221 +IUSE="debug device-mapper doc efiemu +fonts mount +multislot nls static sdl test +themes truetype libzfs"
222 +
223 +GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot qemu qemu-mips pc uboot xen )
224 +IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}"
225 +
226 +REQUIRED_USE="
227 + grub_platforms_coreboot? ( fonts )
228 + grub_platforms_qemu? ( fonts )
229 + grub_platforms_ieee1275? ( fonts )
230 + grub_platforms_loongson? ( fonts )
231 +"
232 +
233 +# os-prober: Used on runtime to detect other OSes
234 +# xorriso (dev-libs/libisoburn): Used on runtime for mkrescue
235 +RDEPEND="
236 + app-arch/xz-utils
237 + >=sys-libs/ncurses-5.2-r5:0=
238 + debug? (
239 + sdl? ( media-libs/libsdl )
240 + )
241 + device-mapper? ( >=sys-fs/lvm2-2.02.45 )
242 + libzfs? ( sys-fs/zfs )
243 + mount? ( sys-fs/fuse )
244 + truetype? ( media-libs/freetype:2= )
245 + ppc? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils )
246 + ppc64? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils )
247 +"
248 +DEPEND="${RDEPEND}
249 + ${PYTHON_DEPS}
250 + app-misc/pax-utils
251 + sys-devel/flex
252 + sys-devel/bison
253 + sys-apps/help2man
254 + sys-apps/texinfo
255 + fonts? ( media-libs/freetype:2 )
256 + grub_platforms_xen? ( app-emulation/xen-tools:= )
257 + static? (
258 + app-arch/xz-utils[static-libs(+)]
259 + truetype? (
260 + app-arch/bzip2[static-libs(+)]
261 + media-libs/freetype[static-libs(+)]
262 + sys-libs/zlib[static-libs(+)]
263 + )
264 + )
265 + test? (
266 + dev-libs/libisoburn
267 + app-emulation/qemu
268 + )
269 + themes? (
270 + app-arch/unzip
271 + media-libs/freetype:2
272 + )
273 +"
274 +RDEPEND+="
275 + kernel_linux? (
276 + grub_platforms_efi-32? ( sys-boot/efibootmgr )
277 + grub_platforms_efi-64? ( sys-boot/efibootmgr )
278 + )
279 + !multislot? ( !sys-boot/grub:0 )
280 + nls? ( sys-devel/gettext )
281 +"
282 +
283 +DEPEND+=" !!=media-libs/freetype-2.5.4"
284 +
285 +STRIP_MASK="*/grub/*/*.{mod,img}"
286 +RESTRICT="test"
287 +
288 +QA_EXECSTACK="
289 + usr/bin/grub*-emu*
290 + usr/lib*/grub/*/*.mod
291 + usr/lib*/grub/*/*.module
292 + usr/lib*/grub/*/kernel.exec
293 + usr/lib*/grub/*/kernel.img
294 +"
295 +
296 +QA_WX_LOAD="
297 + usr/lib*/grub/*/kernel.exec
298 + usr/lib*/grub/*/kernel.img
299 + usr/lib*/grub/*/*.image
300 +"
301 +
302 +QA_PRESTRIPPED="
303 + usr/lib.*/grub/.*/kernel.img
304 +"
305 +
306 +src_unpack() {
307 + if [[ ${PV} == 9999 ]]; then
308 + git-r3_src_unpack
309 + fi
310 + default_src_unpack
311 +}
312 +
313 +src_prepare() {
314 + EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch
315 +
316 + epatch "${FILESDIR}"/CVE-2015-8370.patch
317 + epatch "${FILESDIR}"/${P}-lvm2-raid1.patch
318 + epatch "${FILESDIR}"/${P}-KERNEL_GLOBS.patch
319 +
320 + sed -i -e /autoreconf/d autogen.sh || die
321 +
322 + if use multislot; then
323 + # fix texinfo file name, bug 416035
324 + sed -i -e 's/^\* GRUB:/* GRUB2:/' -e 's/(grub)/(grub2)/' docs/grub.texi || die
325 + fi
326 +
327 + epatch_user
328 +
329 + if [[ -n ${GRUB_AUTOGEN} ]]; then
330 + python_setup
331 + bash autogen.sh || die
332 + fi
333 +
334 + if [[ -n ${AUTOTOOLS_AUTORECONF} ]]; then
335 + autopoint() { return 0; }
336 + eautoreconf
337 + fi
338 +}
339 +
340 +setup_fonts() {
341 + ln -s "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die
342 + if use themes; then
343 + ln -s "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die
344 + fi
345 +}
346 +
347 +grub_configure() {
348 + local platform
349 +
350 + case ${MULTIBUILD_VARIANT} in
351 + efi-32)
352 + platform=efi
353 + if [[ ${CTARGET:-${CHOST}} == x86_64* ]]; then
354 + local CTARGET=${CTARGET:-i386}
355 + fi ;;
356 + efi-64)
357 + platform=efi
358 + if [[ ${CTARGET:-${CHOST}} == i?86* ]]; then
359 + local CTARGET=${CTARGET:-x86_64}
360 + local TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}"
361 + local TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}"
362 + export TARGET_CFLAGS TARGET_CPPFLAGS
363 + fi ;;
364 + guessed) ;;
365 + *) platform=${MULTIBUILD_VARIANT} ;;
366 + esac
367 +
368 + local myeconfargs=(
369 + --disable-werror
370 + --program-prefix=
371 + --libdir="${EPREFIX}"/usr/lib
372 + --htmldir="${EPREFIX}"/usr/share/doc/${PF}/html
373 + $(use_enable debug mm-debug)
374 + $(use_enable debug grub-emu-usb)
375 + $(use_enable device-mapper)
376 + $(use_enable mount grub-mount)
377 + $(use_enable nls)
378 + $(use_enable themes grub-themes)
379 + $(use_enable truetype grub-mkfont)
380 + $(use_enable libzfs)
381 + $(use sdl && use_enable debug grub-emu-sdl)
382 + ${platform:+--with-platform=}${platform}
383 +
384 + # Let configure detect this where supported
385 + $(usex efiemu '' '--disable-efiemu')
386 + )
387 +
388 + if use multislot; then
389 + myeconfargs+=( --program-transform-name="s,grub,grub2," )
390 + fi
391 +
392 + mkdir -p "${BUILD_DIR}" || die
393 + run_in_build_dir setup_fonts
394 +
395 + autotools-utils_src_configure
396 +}
397 +
398 +src_configure() {
399 + # Bug 508758.
400 + replace-flags -O3 -O2
401 +
402 + # We don't want to leak flags onto boot code.
403 + export HOST_CCASFLAGS=${CCASFLAGS}
404 + export HOST_CFLAGS=${CFLAGS}
405 + export HOST_CPPFLAGS=${CPPFLAGS}
406 + export HOST_LDFLAGS=${LDFLAGS}
407 + unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS
408 +
409 + use static && HOST_LDFLAGS+=" -static"
410 +
411 + tc-ld-disable-gold #439082 #466536 #526348
412 + export TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LDFLAGS}"
413 + unset LDFLAGS
414 +
415 + tc-export CC NM OBJCOPY RANLIB STRIP
416 + tc-export BUILD_CC # Bug 485592
417 +
418 + # Portage will take care of cleaning up GRUB_PLATFORMS
419 + MULTIBUILD_VARIANTS=( ${GRUB_PLATFORMS:-guessed} )
420 + multibuild_parallel_foreach_variant grub_configure
421 +}
422 +
423 +src_compile() {
424 + # Sandbox bug 404013.
425 + use libzfs && addpredict /etc/dfs:/dev/zfs
426 +
427 + multibuild_foreach_variant autotools-utils_src_compile
428 +
429 + use doc && multibuild_for_best_variant \
430 + autotools-utils_src_compile -C docs html
431 +}
432 +
433 +src_test() {
434 + # The qemu dependency is a bit complex.
435 + # You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform.
436 + multibuild_foreach_variant autotools-utils_src_test
437 +}
438 +
439 +src_install() {
440 + multibuild_foreach_variant autotools-utils_src_install \
441 + bashcompletiondir="$(get_bashcompdir)"
442 +
443 + local grub=grub
444 + if use multislot; then
445 + grub=grub2
446 + mv "${ED%/}"/usr/share/info/grub{,2}.info || die
447 + mv "${ED%/}"/$(get_bashcompdir)/grub{,2} || die
448 + fi
449 +
450 + bashcomp_alias ${grub} ${grub}-{install,set-default,mkrescue,reboot,script-check,editenv,sparc64-setup,mkfont,mkpasswd-pbkdf2,mkimage,bios-setup,mkconfig,probe}
451 +
452 + use doc && multibuild_for_best_variant run_in_build_dir \
453 + emake -C docs DESTDIR="${D}" install-html
454 +
455 + insinto /etc/default
456 + newins "${FILESDIR}"/grub.default-3 grub
457 +}
458 +
459 +pkg_postinst() {
460 + mount-boot_mount_boot_partition
461 +
462 + if [[ -e "${ROOT%/}/boot/grub2/grub.cfg" ]]; then
463 + ewarn "The grub directory has changed from /boot/grub2 to /boot/grub."
464 + ewarn "Please run grub2-install and grub2-mkconfig -o /boot/grub/grub.cfg."
465 +
466 + if [[ ! -e "${ROOT%/}/boot/grub/grub.cfg" ]]; then
467 + mkdir -p "${ROOT%/}/boot/grub"
468 + ln -s ../grub2/grub.cfg "${ROOT%/}/boot/grub/grub.cfg"
469 + fi
470 + fi
471 +
472 + mount-boot_pkg_postinst
473 +
474 + elog "For information on how to configure GRUB2 please refer to the guide:"
475 + elog " https://wiki.gentoo.org/wiki/GRUB2_Quick_Start"
476 +
477 + if has_version 'sys-boot/grub:0'; then
478 + elog "A migration guide for GRUB Legacy users is available:"
479 + elog " https://wiki.gentoo.org/wiki/GRUB2_Migration"
480 + fi
481 +
482 + if [[ -z ${REPLACING_VERSIONS} ]]; then
483 + elog
484 + elog "You may consider installing the following optional packages:"
485 + optfeature "Detect other operating systems (grub-mkconfig)" sys-boot/os-prober
486 + optfeature "Create rescue media (grub-mkrescue)" dev-libs/libisoburn
487 + optfeature "Enable RAID device detection" sys-fs/mdadm
488 + else
489 + local v
490 + for v in ${REPLACING_VERSIONS}; do
491 + if ! version_is_at_least 2.02_beta2-r8 ${v}; then
492 + ewarn "Please re-run grub2-install to address a security flaw when using"
493 + ewarn "username/password authentication in grub."
494 + ewarn "See bug 568326 for more information."
495 + fi
496 + done
497 + fi
498 +}