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