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