blob: ed93d6311b9addb13e25b18e5c3cc3f60990bdeb [file] [log] [blame]
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Distributed under the terms of the GNU General Public License v2
EAPI=5
GRUB2_COMMIT="442a4e8a9fa9b6b4a5240b96742be063e7eca061"
GNULIB_COMMIT="0e9febb5e173f1dc85e5993a72aa886b431ff32f"
SRC_URI="https://github.com/rhboot/grub2/archive/${GRUB2_COMMIT}.tar.gz -> rhboot-grub2-${GRUB2_COMMIT}.tar.gz
https://github.com/rhboot/gnulib/archive/${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() {
epatch "${FILESDIR}"/grub-lakitu-fc34-0001-grub-lakitu-CHROMIUM-Forward-port-ChromeOS-specific-.patch
epatch "${FILESDIR}"/grub-lakitu-fc34-0002-grub-lakitu-CHROMIUM-Forward-port-gptpriority-comman.patch
epatch "${FILESDIR}"/grub-lakitu-fc34-0003-grub-lakitu-CHROMIUM-hook-linux-command.patch
epatch "${FILESDIR}"/grub-lakitu-fc34-0004-grub-lakitu-CHROMIUM-Make-grub-config-read-only-in-s.patch
epatch "${FILESDIR}"/grub-lakitu-fc34-0005-grub-lakitu-disable-grub-rpm-sort.patch
epatch "${FILESDIR}"/grub-lakitu-fc34-0006-grub-lakitu-fix-clang-build.patch
epatch "${FILESDIR}"/grub-lakitu-fc34-0007-git-lakitu-fix-clang-relocations.patch
epatch "${FILESDIR}"/grub-lakitu-fc34-0008-grub-lakitu-add-ARM64-linuxefi-command-fro-compatibi.patch
./bootstrap --no-git --no-bootstrap-sync --gnulib-srcdir=../gnulib-${GNULIB_COMMIT}
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
# 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-grub-mount \
--disable-rpm-sort \
--disable-efiemu \
--disable-libzfs \
--disable-nls \
--sbindir=/sbin \
--bindir=/bin \
--libdir=/$(get_libdir) \
--with-platform=${platform} \
--target=${target} \
--prefix="${D}"
popd >/dev/null
done
done
multijob_finish
}
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" \
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"
}