# Copyright 2007 Bryan Østergaard # Copyright 2018 Redcore Linux Project # Distributed under the terms of the GNU General Public License v2 require gnu [ suffix=tar.xz ] \ flag-o-matic \ autotools [ supported_autoconf=[ 2.5 ] supported_automake=[ 1.16 1.15 ] ] export_exlib_phases pkg_setup src_prepare src_configure src_compile src_install SUMMARY="GRUB (Grand Unified Boot) bootloader" LICENCES="GPL-3" MYOPTIONS=" device-mapper [[ description = [ Ability to detect and use device-mapper devices ] ]] efi [[ description = [ Build EFI platform support ] ]] grub-mount [[ description = [ FUSE driver for filesystems that GRUB understands ] ]] mkfont [[ description = [ Build grub-mkfont which can create GRUB font files ] ]] pc [[ description = [ Build PC platform support ] ]] themes [[ description = [ Build and install GRUB themes (starfield) ] ]] ( providers: eudev systemd ) [[ number-selected = exactly-one ]] ( efi pc ) [[ number-selected = at-least-one ]] " # TODO: needs qemu-system-i386 RESTRICT="test" DEPENDENCIES=" build: sys-apps/help2man [[ note = [ man pages won't get created otherwise resulting in empty man dirs ] ]] sys-devel/bison sys-devel/flex[>=2.5.35] sys-devel/make device-mapper? ( sys-fs/lvm2 ) grub-mount? ( sys-fs/fuse:0 ) mkfont? ( fonts/unifont media-libs/freetype:2 ) themes? ( fonts/dejavu ) build+run: app-arch/xz sys-devel/gettext [[ note = [ required for grub-mkconfig, grep gettext in /etc/grub.d ] ]] !sys-boot/grub-static [[ description = [ /sbin/grub-install collides ] resolution = manual ]] providers:eudev? ( sys-apps/eudev ) providers:systemd? ( sys-apps/systemd ) run: efi? ( sys-boot/efibootmgr ) sys-boot/grub-config-redcore suggestion: sys-boot/os-prober [[ description = [ Ability to add other OSs automatically to grub.cfg via grub-mkconf ] ]] " AT_M4DIR=( m4 ) grub_pkg_setup() { # grub2 should be compiled with -Os, other optimizations may result in oversized core images replace-flags -O* -Os # retpoline flag is incompatible with the -mcmodel=large flag used by grub filter-flags -mindirect-branch=thunk } grub_src_prepare() { edo sed \ -e "s/.*Running autoreconf.*/exit 0/" \ -i autogen.sh edo ./autogen.sh autotools_src_prepare if option mkfont; then edo cp -ax "${ROOT}"usr/share/fonts/X11/unifont/unifont.pcf.gz unifont.pcf.gz edo gzip -d unifont.pcf.gz fi if option themes; then edo cp -ax "${ROOT}"usr/share/fonts/X11/dejavu/DejaVuSans.ttf DejaVuSans.ttf fi } grub_src_multibuild_prepare() { if option efi; then edo cp -ax "${WORK}" "${WORK}"-efi fi if option pc; then edo cp -ax "${WORK}" "${WORK}"-pc fi } grub_src_configure() { filter-flags -mfloat-abi=hard unset CFLAGS CPPFLAGS LDFLAGS grub_src_multibuild_prepare if option efi; then edo pushd "${WORK}"-efi myconf=( "CPP=${CC} -E" BUILD_CC=$(exhost --build)-cc BUILD_CFLAGS="$(print-build-flags CFLAGS)" BUILD_CPPFLAGS="$(print-build-flags CPPFLAGS)" BUILD_LDFLAGS="$(print-build-flags LDFLAGS)" --with-bootdir=/boot --with-grubdir=grub --with-platform=efi --enable-cache-stats --disable-libzfs --disable-werror # TODO: for now disable emulation utils --disable-efiemu --disable-grub-emu-sdl --disable-grub-emu-pci --disable-mm-debug gt_cv_func_gnugettext{1,2}_libc=yes ) econf "${myconf[@]}" \ $(option_enable device-mapper) \ $(option_enable grub-mount) \ $(option_enable mkfont grub-mkfont) \ $(option_enable themes grub-themes) fi if option pc; then edo pushd "${WORK}"-pc myconf=( "CPP=${CC} -E" BUILD_CC=$(exhost --build)-cc BUILD_CFLAGS="$(print-build-flags CFLAGS)" BUILD_CPPFLAGS="$(print-build-flags CPPFLAGS)" BUILD_LDFLAGS="$(print-build-flags LDFLAGS)" --with-bootdir=/boot --with-grubdir=grub --with-platform=pc --enable-cache-stats --disable-libzfs --disable-werror # TODO: for now disable emulation utils --disable-efiemu --disable-grub-emu-sdl --disable-grub-emu-pci --disable-mm-debug gt_cv_func_gnugettext{1,2}_libc=yes ) econf "${myconf[@]}" \ $(option_enable device-mapper) \ $(option_enable grub-mount) \ $(option_enable mkfont grub-mkfont) \ $(option_enable themes grub-themes) fi } grub_src_compile() { if option efi; then edo pushd "${WORK}"-efi emake fi if option pc; then edo pushd "${WORK}"-pc emake fi } grub_src_install() { if option efi; then edo pushd "${WORK}"-efi emake DESTDIR="${IMAGE}" install edo rm -rf "${WORK}"-efi fi if option pc; then edo pushd "${WORK}"-pc emake DESTDIR="${IMAGE}" install edo rm -rf "${WORK}"-pc fi dodoc "${WORK}"/docs/grub.cfg edo rm -f "${IMAGE}"/usr/$(exhost --target)/lib/charset.alias edo rm "${IMAGE%/}"/etc/bash_completion.d/${PN} edo rmdir "${IMAGE%/}"/etc/bash_completion.d/ }