Line 0
Link Here
|
|
|
1 |
# Copyright 1999-2016 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Id$ |
4 |
|
5 |
EAPI=6 |
6 |
|
7 |
if [[ ${PV} == 9999 ]]; then |
8 |
PYTHON_COMPAT=( python{2_7,3_3,3_4,3_5} ) |
9 |
inherit python-any-r1 |
10 |
fi |
11 |
|
12 |
inherit autotools bash-completion-r1 flag-o-matic multibuild pax-utils toolchain-funcs versionator |
13 |
|
14 |
if [[ ${PV} != 9999 ]]; then |
15 |
if [[ ${PV} == *_alpha* || ${PV} == *_beta* || ${PV} == *_rc* ]]; then |
16 |
# The quote style is to work with <=bash-4.2 and >=bash-4.3 #503860 |
17 |
MY_P=${P/_/'~'} |
18 |
SRC_URI="mirror://gnu-alpha/${PN}/${MY_P}.tar.xz" |
19 |
S=${WORKDIR}/${MY_P} |
20 |
else |
21 |
SRC_URI="mirror://gnu/${PN}/${P}.tar.xz |
22 |
mirror://gentoo/${P}.tar.xz |
23 |
https://dev.gentoo.org/~floppym/dist/${P}.tar.xz" |
24 |
S=${WORKDIR}/${P%_*} |
25 |
fi |
26 |
KEYWORDS="~amd64 ~x86" |
27 |
else |
28 |
inherit git-r3 |
29 |
EGIT_REPO_URI="git://git.sv.gnu.org/grub.git |
30 |
http://git.savannah.gnu.org/r/grub.git" |
31 |
fi |
32 |
|
33 |
PATCHES=( |
34 |
"${FILESDIR}"/gfxpayload.patch |
35 |
"${FILESDIR}"/grub-2.02_beta2-KERNEL_GLOBS.patch |
36 |
"${FILESDIR}"/2.02_beta3-10_linux-UUID.patch |
37 |
"${FILESDIR}"/2.02_beta3-sysmacros.patch |
38 |
"${FILESDIR}"/2.02_beta3-gcc6-ld-no-pie.patch |
39 |
) |
40 |
|
41 |
DEJAVU=dejavu-sans-ttf-2.35 |
42 |
UNIFONT=unifont-8.0.01 |
43 |
SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz ) |
44 |
themes? ( mirror://sourceforge/dejavu/${DEJAVU}.zip )" |
45 |
|
46 |
DESCRIPTION="GNU GRUB boot loader" |
47 |
HOMEPAGE="https://www.gnu.org/software/grub/" |
48 |
|
49 |
# Includes licenses for dejavu and unifont |
50 |
LICENSE="GPL-3 fonts? ( GPL-2-with-font-exception ) themes? ( BitstreamVera )" |
51 |
SLOT="2/${PVR}" |
52 |
IUSE="debug device-mapper doc efiemu +fonts mount +multislot nls static sdl test +themes truetype libzfs" |
53 |
|
54 |
GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot qemu qemu-mips pc uboot xen xen-32 ) |
55 |
IUSE+=" ${GRUB_ALL_PLATFORMS[@]/#/grub_platforms_}" |
56 |
|
57 |
REQUIRED_USE=" |
58 |
grub_platforms_coreboot? ( fonts ) |
59 |
grub_platforms_qemu? ( fonts ) |
60 |
grub_platforms_ieee1275? ( fonts ) |
61 |
grub_platforms_loongson? ( fonts ) |
62 |
" |
63 |
|
64 |
# os-prober: Used on runtime to detect other OSes |
65 |
# xorriso (dev-libs/libisoburn): Used on runtime for mkrescue |
66 |
RDEPEND=" |
67 |
app-arch/xz-utils |
68 |
>=sys-libs/ncurses-5.2-r5:0= |
69 |
debug? ( |
70 |
sdl? ( media-libs/libsdl ) |
71 |
) |
72 |
device-mapper? ( >=sys-fs/lvm2-2.02.45 ) |
73 |
libzfs? ( sys-fs/zfs ) |
74 |
mount? ( sys-fs/fuse ) |
75 |
truetype? ( media-libs/freetype:2= ) |
76 |
ppc? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils ) |
77 |
ppc64? ( sys-apps/ibm-powerpc-utils sys-apps/powerpc-utils ) |
78 |
" |
79 |
DEPEND="${RDEPEND} |
80 |
${PYTHON_DEPS} |
81 |
app-misc/pax-utils |
82 |
sys-devel/flex |
83 |
sys-devel/bison |
84 |
sys-apps/help2man |
85 |
sys-apps/texinfo |
86 |
fonts? ( media-libs/freetype:2 ) |
87 |
grub_platforms_xen? ( app-emulation/xen-tools:= ) |
88 |
grub_platforms_xen-32? ( app-emulation/xen-tools:= ) |
89 |
static? ( |
90 |
app-arch/xz-utils[static-libs(+)] |
91 |
truetype? ( |
92 |
app-arch/bzip2[static-libs(+)] |
93 |
media-libs/freetype[static-libs(+)] |
94 |
sys-libs/zlib[static-libs(+)] |
95 |
) |
96 |
) |
97 |
test? ( |
98 |
dev-libs/libisoburn |
99 |
app-emulation/qemu |
100 |
) |
101 |
themes? ( |
102 |
app-arch/unzip |
103 |
media-libs/freetype:2 |
104 |
) |
105 |
" |
106 |
RDEPEND+=" |
107 |
kernel_linux? ( |
108 |
grub_platforms_efi-32? ( sys-boot/efibootmgr ) |
109 |
grub_platforms_efi-64? ( sys-boot/efibootmgr ) |
110 |
) |
111 |
!multislot? ( !sys-boot/grub:0 ) |
112 |
nls? ( sys-devel/gettext ) |
113 |
" |
114 |
|
115 |
DEPEND+=" !!=media-libs/freetype-2.5.4" |
116 |
|
117 |
STRIP_MASK="*/grub/*/*.{mod,img}" |
118 |
RESTRICT="test" |
119 |
|
120 |
QA_EXECSTACK=" |
121 |
usr/bin/grub*-emu* |
122 |
usr/lib*/grub/*/*.mod |
123 |
usr/lib*/grub/*/*.module |
124 |
usr/lib*/grub/*/kernel.exec |
125 |
usr/lib*/grub/*/kernel.img |
126 |
" |
127 |
|
128 |
QA_WX_LOAD=" |
129 |
usr/lib*/grub/*/kernel.exec |
130 |
usr/lib*/grub/*/kernel.img |
131 |
usr/lib*/grub/*/*.image |
132 |
" |
133 |
|
134 |
QA_PRESTRIPPED=" |
135 |
usr/lib.*/grub/.*/kernel.img |
136 |
" |
137 |
|
138 |
src_unpack() { |
139 |
if [[ ${PV} == 9999 ]]; then |
140 |
git-r3_src_unpack |
141 |
fi |
142 |
default |
143 |
} |
144 |
|
145 |
src_prepare() { |
146 |
default |
147 |
|
148 |
sed -i -e /autoreconf/d autogen.sh || die |
149 |
|
150 |
if use multislot; then |
151 |
# fix texinfo file name, bug 416035 |
152 |
sed -i -e 's/^\* GRUB:/* GRUB2:/' -e 's/(grub)/(grub2)/' docs/grub.texi || die |
153 |
fi |
154 |
|
155 |
autopoint() { :; } |
156 |
eautoreconf |
157 |
} |
158 |
|
159 |
grub_do() { |
160 |
multibuild_foreach_variant run_in_build_dir "$@" |
161 |
} |
162 |
|
163 |
grub_do_once() { |
164 |
multibuild_for_best_variant run_in_build_dir "$@" |
165 |
} |
166 |
|
167 |
grub_configure() { |
168 |
local platform |
169 |
|
170 |
case ${MULTIBUILD_VARIANT} in |
171 |
efi-32) |
172 |
platform=efi |
173 |
if [[ ${CTARGET:-${CHOST}} == x86_64* ]]; then |
174 |
local CTARGET=${CTARGET:-i386} |
175 |
fi ;; |
176 |
efi-64) |
177 |
platform=efi |
178 |
if [[ ${CTARGET:-${CHOST}} == i?86* ]]; then |
179 |
local CTARGET=${CTARGET:-x86_64} |
180 |
local TARGET_CFLAGS="-Os -march=x86-64 ${TARGET_CFLAGS}" |
181 |
local TARGET_CPPFLAGS="-march=x86-64 ${TARGET_CPPFLAGS}" |
182 |
export TARGET_CFLAGS TARGET_CPPFLAGS |
183 |
fi ;; |
184 |
xen-32) |
185 |
platform=xen |
186 |
if [[ ${CHOST} == x86_64* ]]; then |
187 |
local CTARGET=i386 |
188 |
fi ;; |
189 |
guessed) ;; |
190 |
*) platform=${MULTIBUILD_VARIANT} ;; |
191 |
esac |
192 |
|
193 |
local myeconfargs=( |
194 |
--disable-werror |
195 |
--program-prefix= |
196 |
--libdir="${EPREFIX}"/usr/lib |
197 |
--htmldir="${EPREFIX}"/usr/share/doc/${PF}/html |
198 |
$(use_enable debug mm-debug) |
199 |
$(use_enable device-mapper) |
200 |
$(use_enable mount grub-mount) |
201 |
$(use_enable nls) |
202 |
$(use_enable themes grub-themes) |
203 |
$(use_enable truetype grub-mkfont) |
204 |
$(use_enable libzfs) |
205 |
$(use sdl && use_enable debug grub-emu-sdl) |
206 |
${platform:+--with-platform=}${platform} |
207 |
|
208 |
# Let configure detect this where supported |
209 |
$(usex efiemu '' '--disable-efiemu') |
210 |
) |
211 |
|
212 |
if use multislot; then |
213 |
myeconfargs+=( --program-transform-name="s,grub,grub2," ) |
214 |
fi |
215 |
|
216 |
# Set up font symlinks |
217 |
ln -s "${WORKDIR}/${UNIFONT}.pcf" unifont.pcf || die |
218 |
if use themes; then |
219 |
ln -s "${WORKDIR}/${DEJAVU}/ttf/DejaVuSans.ttf" DejaVuSans.ttf || die |
220 |
fi |
221 |
|
222 |
ECONF_SOURCE="${S}" econf "${myeconfargs[@]}" |
223 |
} |
224 |
|
225 |
grub_get_platforms() { |
226 |
MULTIBUILD_VARIANTS=() |
227 |
local platform |
228 |
for platform in "${GRUB_ALL_PLATFORMS[@]}"; do |
229 |
if use "grub_platforms_${platform}"; then |
230 |
MULTIBUILD_VARIANTS+=( "${platform}" ) |
231 |
fi |
232 |
done |
233 |
if (( ${#MULTIBUILD_VARIANTS[@]} == 0 )); then |
234 |
MULTIBUILD_VARIANTS=( guessed ) |
235 |
fi |
236 |
} |
237 |
|
238 |
src_configure() { |
239 |
# Bug 508758. |
240 |
replace-flags -O3 -O2 |
241 |
|
242 |
# We don't want to leak flags onto boot code. |
243 |
export HOST_CCASFLAGS=${CCASFLAGS} |
244 |
export HOST_CFLAGS=${CFLAGS} |
245 |
export HOST_CPPFLAGS=${CPPFLAGS} |
246 |
export HOST_LDFLAGS=${LDFLAGS} |
247 |
unset CCASFLAGS CFLAGS CPPFLAGS LDFLAGS |
248 |
|
249 |
use static && HOST_LDFLAGS+=" -static" |
250 |
|
251 |
tc-ld-disable-gold #439082 #466536 #526348 |
252 |
export TARGET_LDFLAGS="${TARGET_LDFLAGS} ${LDFLAGS}" |
253 |
unset LDFLAGS |
254 |
|
255 |
tc-export CC NM OBJCOPY RANLIB STRIP |
256 |
tc-export BUILD_CC # Bug 485592 |
257 |
|
258 |
# Portage will take care of cleaning up GRUB_PLATFORMS |
259 |
grub_get_platforms |
260 |
grub_do grub_configure |
261 |
} |
262 |
|
263 |
src_compile() { |
264 |
# Sandbox bug 404013. |
265 |
use libzfs && addpredict /etc/dfs:/dev/zfs |
266 |
|
267 |
grub_do emake |
268 |
use doc && grub_do_once emake -C docs html |
269 |
} |
270 |
|
271 |
src_test() { |
272 |
# The qemu dependency is a bit complex. |
273 |
# You will need to adjust QEMU_SOFTMMU_TARGETS to match the cpu/platform. |
274 |
grub_do emake check |
275 |
} |
276 |
|
277 |
src_install() { |
278 |
grub_do emake install DESTDIR="${D}" bashcompletiondir="$(get_bashcompdir)" |
279 |
use doc && grub_do_once emake -C docs install-html DESTDIR="${D}" |
280 |
|
281 |
einstalldocs |
282 |
|
283 |
if use multislot; then |
284 |
mv "${ED%/}"/usr/share/info/grub{,2}.info || die |
285 |
fi |
286 |
|
287 |
insinto /etc/default |
288 |
newins "${FILESDIR}"/grub.default-3 grub |
289 |
} |
290 |
|
291 |
pkg_postinst() { |
292 |
elog "For information on how to configure GRUB2 please refer to the guide:" |
293 |
elog " https://wiki.gentoo.org/wiki/GRUB2_Quick_Start" |
294 |
|
295 |
if has_version 'sys-boot/grub:0'; then |
296 |
elog "A migration guide for GRUB Legacy users is available:" |
297 |
elog " https://wiki.gentoo.org/wiki/GRUB2_Migration" |
298 |
fi |
299 |
|
300 |
if [[ -z ${REPLACING_VERSIONS} ]]; then |
301 |
elog |
302 |
elog "You may consider installing the following optional packages:" |
303 |
optfeature "Detect other operating systems (grub-mkconfig)" sys-boot/os-prober |
304 |
optfeature "Create rescue media (grub-mkrescue)" dev-libs/libisoburn |
305 |
optfeature "Enable RAID device detection" sys-fs/mdadm |
306 |
fi |
307 |
} |