blob: 133959ac9fd1c05e37602c80c9e0743e0442a700 [file] [log] [blame]
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
EAPI=5
SRC_URI="https://github.com/rhboot/shim/releases/download/${PV}/shim-${PV}.tar.bz2"
KEYWORDS="*"
inherit eutils multilib toolchain-funcs
DESCRIPTION="Red Hat UEFI shim loader"
HOMEPAGE="https://github.com/rhboot/shim"
LICENSE="BSD-2"
SLOT="0"
IUSE=""
RDEPEND=""
DEPEND="dev-libs/openssl
sys-boot/gnu-efi
platform-key? ( sys-boot/platform-key )
"
IUSE="platform-key"
S="${WORKDIR}/${P}"
shim_arch() {
case ${ARCH} in
amd64) echo "x86_64";;
arm64) echo "aarch64";;
*) eerror "unsupported architecture: ${ARCH}";;
esac
}
shim_binary() {
case ${ARCH} in
amd64) echo "shimx64.efi";;
arm64) echo "shimaa64.efi";;
*) eerror "unsupported architecture: ${ARCH}";;
esac
}
src_prepare() {
cros_use_gcc
epatch "${FILESDIR}"/${PN}-15-fix-aarch64-build.patch
epatch "${FILESDIR}"/${PN}-15-fix-vlogerror-arm64-crash.patch
epatch "${FILESDIR}"/${PN}-15-built-in-platform-key.patch
default
}
src_compile() {
local extra_opts=()
if tc-ld-is-gold; then
extra_opts+=( ARCH_LDFLAGS="--no-experimental-use-relr" )
fi
if use platform-key; then
extra_opts+=( VENDOR_CERT_FILE="${ROOT}/build/share/platform-key/signing_key.cer" )
fi
emake ARCH="$(shim_arch)" \
CROSS_COMPILE="${CHOST}-" \
EFI_INCLUDE="${ROOT}/usr/include/efi" \
EFI_PATH="${ROOT}/usr/$(get_libdir)" \
DEFAULT_LOADER="\\\\\\\\grub-lakitu.efi" \
"${extra_opts[@]}" \
$(shim_binary)
}
src_install() {
insinto /boot/efi/boot
doins "$(shim_binary)"
}