template (3297B)
1 # Template file for 'grub' 2 pkgname=grub 3 version=2.14 4 revision=0 5 short_desc="Bootloader with support for BIOS and UEFI" 6 maintainer="finwo <finwo@pm.me>" 7 license="GPL-3.0-or-later" 8 homepage="https://www.gnu.org/software/grub/" 9 # NOTE: gnu publishes PGP .sig only, no sha256 file - TOFU pin. 10 distfiles="https://ftp.gnu.org/gnu/grub/grub-2.14.tar.xz" 11 checksum=bc8d3c73535b8838d8c8e2654d73edc4e6ae8c8acdb45d5df5dc9a1547446d43 12 # xz: grub-install links liblzma (readelf-proven, not guessed). 13 depends="xz" 14 makedepends="xz" 15 hostmakedepends="bison flex" 16 17 # Notes: 18 # - x86_64-efi ONLY in v1 (not i386-pc): grub 2.14's pc kernel.img links 19 # .text at 0x9074 instead of the required 0x9000 under host binutils 20 # 2.44 (headers counted where old ld overlapped them), and grub-mkimage 21 # fail-louds on it. Objects compile fine (-m32 codegen works); only the 22 # flat core layout is wrong. Revisit when the toolchain allows: older 23 # binutils, upstream fix, or a verified link flag - NOT by shipping 24 # artifacts that build unbootable images. Modern whiteboxes and QEMU-OVMF 25 # are UEFI anyway; legacy BIOS is a follow-up, not a blocker. 26 # - Single out-of-tree build. --disable-nls (no localized boot menus) and 27 # --disable-werror (host gcc is newer than grub's vintage). 28 # - Inclusive install, then prune (grub-install needs its helpers at 29 # runtime; cherry-picking risks breaking it). Pruned: info docs, themes, 30 # locales, grub-mkconfig (UNOS writes a static grub.cfg - deterministic, 31 # no probing). grub-script-check ships to validate that static config. 32 # Man pages kept (tinyssh precedent). 33 # - Upstream defaults are trimmed ONLY where auto-detection would create 34 # host-dependent runtime deps (same lesson as iproute2's scrub): no 35 # custom console fonts (serial only, drops freetype), no TPM-sealed boot 36 # (drops tasn1), no FUSE mount, no ZFS, no device-mapper. 37 # - CPPFLAGS/LDFLAGS put the sysroot first: configure "guesses" liblzma 38 # via try-link, which would otherwise take host headers. 39 # - No `make check` (needs qemu RVA); CI story pending. 40 do_configure() { 41 mkdir -p "${WORK}/build-efi" 42 cd "${WORK}/build-efi" 43 CPPFLAGS="-I${SYSROOT}/usr/include" LDFLAGS="-L${SYSROOT}/usr/lib" \ 44 "${WRKSRC}/configure" --prefix=/usr --with-platform=efi \ 45 --disable-nls --disable-werror \ 46 --disable-grub-mkfont --disable-grub-mount --disable-grub-protect \ 47 --disable-libzfs --disable-device-mapper 48 } 49 50 do_build() { 51 make -C "${WORK}/build-efi" -j"$(nproc)" 52 [ -x "${WORK}/build-efi/grub-mkimage" ] || die "grub: efi grub-mkimage missing" 53 } 54 55 do_install() { 56 # install-strip: upstream binaries ship with debug_info; strip programs. 57 # (.mod files install as data and stay unstripped - measured acceptable.) 58 make -C "${WORK}/build-efi" install-strip DESTDIR="${DESTDIR}" 59 # prune: docs, themes, locales - serial/console boot needs none of them 60 rm -rf "${DESTDIR}/usr/share/info" "${DESTDIR}/usr/share/grub/themes" \ 61 "${DESTDIR}/usr/share/locale" 62 # no probing config generation on a switch (see Notes) 63 rm -f "${DESTDIR}"/usr/sbin/grub-mkconfig "${DESTDIR}"/usr/share/man/man8/grub-mkconfig.8 64 [ -x "${DESTDIR}/usr/sbin/grub-install" ] || die "grub: grub-install missing" 65 [ -d "${DESTDIR}/usr/lib/grub/x86_64-efi" ] || die "grub: x86_64-efi modules missing" 66 }