| # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| # Distributed under the terms of the GNU General Public License v2 |
| |
| EAPI=7 |
| |
| # fedora-39 branch in rhboot/grub2 |
| GRUB2_COMMIT="72b17102c157707acfffb01ae7694de6cf23eb5c" |
| |
| # This information is required for .sbat section of the EFI binary |
| # https://github.com/rhboot/shim/blob/main/SBAT.md |
| # Should be kept up to date with every version update |
| GRUB_VERSION="2.06" |
| # whenever updating GRUB package it's better to synchronize with |
| # Fedora Core releases and cross-reference git commits in rhboot/grub2 |
| # with the changelog in GRUB2 rpm file or with sources from the srpm |
| # rpm -q --changelog grub2-efi-x64-2.06-6.fc36.x86_64.rpm |
| FC_GRUB_VERSION="2.06-118.fc39" |
| |
| # gnulibversion in Fedora's grub2.spec |
| GNULIB_COMMIT="9f48fb992a3d7e96610c4ce8be969cff2d61a01b" |
| SRC_URI="https://github.com/rhboot/grub2/archive/${GRUB2_COMMIT}.tar.gz -> rhboot-grub2-${GRUB2_COMMIT}.tar.gz |
| https://git.savannah.gnu.org/cgit/gnulib.git/snapshot/gnulib-${GNULIB_COMMIT}.tar.gz -> rhboot-gnulib-${GNULIB_COMMIT}.tar.gz" |
| |
| inherit autotools eutils git-r3 toolchain-funcs multiprocessing cros-workon |
| |
| DESCRIPTION="Fedora's GRUB 2" |
| HOMEPAGE="https://fedoraproject.org/wiki/GRUB_2" |
| LICENSE="GPL-3" |
| SLOT="0" |
| KEYWORDS="-* arm64 amd64" |
| IUSE="" |
| |
| DEPEND="dev-lang/python" |
| |
| export STRIP_MASK="*.img *.mod *.module" |
| |
| # The ordering doesn't seem to matter. |
| PLATFORMS=( "efi" ) |
| TARGETS=( "${CHOST}" ) |
| |
| grub_output_format() { |
| case ${ARCH} in |
| amd64) echo "x86_64-efi";; |
| arm64) echo "arm64-efi";; |
| *) eerror "unsupported architecture: ${ARCH}";; |
| esac |
| } |
| |
| grub_output_dir() { |
| case ${ARCH} in |
| amd64) echo "x86_64-efi";; |
| arm64) echo "arm64-efi";; |
| *) eerror "unsupported architecture: ${ARCH}";; |
| esac |
| } |
| |
| src_unpack() { |
| default |
| S="${WORKDIR}/grub2-${GRUB2_COMMIT}" |
| } |
| |
| src_prepare() { |
| cros_allow_gnu_build_tools |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0001-grub-lakitu-CHROMIUM-Forward-port-ChromeOS-specific-.patch |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0002-grub-lakitu-CHROMIUM-Forward-port-gptpriority-comman.patch |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0003-grub-lakitu-CHROMIUM-hook-linux-command.patch |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0004-grub-lakitu-CHROMIUM-Make-grub-config-read-only-in-s.patch |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0005-grub-lakitu-fix-clang-build.patch |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0006-git-lakitu-fix-clang-relocations.patch |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0007-grub-lakitu-add-ARM64-linuxefi-command-fro-compatibi.patch |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0008-grub-lakitu-fix-build.patch |
| eapply "${FILESDIR}"/grub-lakitu-fc36-0010-use-fno-common.patch |
| ./bootstrap --no-git --no-bootstrap-sync --gnulib-srcdir=../gnulib-${GNULIB_COMMIT} |
| eapply "${FILESDIR}"/grub-lakitu-fc36-gnulib-base64-build-fix.patch |
| default |
| sed -i -e /autoreconf/d autogen.sh || die |
| bash autogen.sh || die |
| autopoint() { :; } |
| eautoreconf -vi |
| } |
| |
| src_configure() { |
| local platform target |
| # Fix timestamps to prevent unnecessary rebuilding |
| find "${S}" -exec touch -r "${S}/configure" {} + |
| multijob_init |
| for platform in "${PLATFORMS[@]}" ; do |
| for target in "${TARGETS[@]}" ; do |
| # Grub does not search for clang when choosing a cross-compiler; it |
| # only searches for gcc, egcs, and cc (in that order). To work |
| # around this, explicitly set TARGET_CC to the compiler type in CC. |
| export TARGET_CC="${target}-${CC#"${CHOST}-"}" |
| mkdir -p "${target}"-"${platform}"-build |
| pushd "${target}"-"${platform}"-build >/dev/null || die |
| # GRUB defaults to a --program-prefix set based on target |
| # platform; explicitly set it to nothing to install unprefixed |
| # tools. https://savannah.gnu.org/bugs/?39818 |
| ECONF_SOURCE="${S}" multijob_child_init econf_build \ |
| --disable-werror \ |
| --disable-grub-mkfont \ |
| --disable-grub-mount \ |
| --disable-efiemu \ |
| --disable-libzfs \ |
| --disable-nls \ |
| --sbindir=/sbin \ |
| --bindir=/bin \ |
| --libdir=/"$(get_libdir)" \ |
| --with-platform="${platform}" \ |
| --target="${target}" \ |
| --prefix="${D}" |
| popd >/dev/null || die |
| done |
| done |
| multijob_finish |
| < "${FILESDIR}/sbat.csv.in" sed "s/@@GRUB_VERSION@@/${GRUB_VERSION}/g" \ |
| | sed "s/@@FC_GRUB_VERSION@@/${FC_GRUB_VERSION}/g" \ |
| | sed "s/@@VERSION@@/${PVR}/g" > "${S}/sbat.csv" |
| } |
| |
| src_compile() { |
| local platform target |
| multijob_init |
| for platform in "${PLATFORMS[@]}" ; do |
| for target in "${TARGETS[@]}" ; do |
| multijob_child_init \ |
| emake -C "${target}"-"${platform}"-build -j1 |
| done |
| done |
| multijob_finish |
| } |
| |
| src_install() { |
| local platform target |
| # The installations have several file conflicts that prevent |
| # parallel installation. |
| for platform in "${PLATFORMS[@]}" ; do |
| for target in "${TARGETS[@]}" ; do |
| emake -C "${target}"-"${platform}"-build DESTDIR="${D}" \ |
| install |
| done |
| done |
| "${D}/bin/grub-mkimage" -O "$(grub_output_format)" \ |
| -p "(hd0,gpt12)/efi/boot" \ |
| -c "${FILESDIR}/grub.cfg" \ |
| -d "${D}/$(get_libdir)/grub/$(grub_output_dir)" \ |
| -o "${S}/grub-lakitu.efi" \ |
| --sbat "${S}/sbat.csv" \ |
| part_gpt test fat ext2 normal boot \ |
| efi_gop configfile search search_fs_uuid search_label \ |
| terminal echo serial tpm gptpriority linux |
| rm -Rf "${D}"/* |
| insinto /boot/efi/boot |
| doins "grub-lakitu.efi" |
| } |