sys-firmware/edk2: New package

Create a new EDK2/UEFI ebuild sys-firmware/edk2 to replace the current
per-arch edk2-armvirt and edk2-ovmf ebuilds.  Updates to use the latest
EDK2 UDK2017 and openssl-1.1.0f releases.

For amd64 builds UDK2017 requires an update to nasm-2.10 or greater.

Fixes UEFI startup problems like these when running Container Linux in
a KVM guest on arm64 machines:

  Synchronous Exception at 0x00000000BF033004

Signed-off-by: Geoff Levand <geoff@infradead.org>
This commit is contained in:
Geoff Levand 2017-07-27 15:42:28 -07:00
parent be7c907260
commit 884e75efef
6 changed files with 215 additions and 0 deletions

View File

@ -0,0 +1,2 @@
DIST openssl-1.1.0f.tar.gz 5278176 SHA256 12f746f3f2493b2f39da7ecf63d7ee19c6ac9ec6a4fcd8c229da8a522cb12765 SHA512 340ab3f38c90dea346e543b58bc0eff0adede15be212ad20b7cf38718a7f94fab51996da414855c180540f7488b8bd31d8b9a0d04bb19159f735c46d8f6df22c WHIRLPOOL bb4ce1d100c5eb567de0139e4a1c0a2bb1cd308bd014704d6bb796d3fcfc16b91fe69839068944831746e0b937a6ccb234b5cea3b4911fab4283500ed380f0b6
DIST vUDK2017.tar.gz 38737278 SHA256 4697c58206f1914eb3779e8515d8fd3de058d736ffdfc78e3e76708d7b7699f1 SHA512 62e42cd4523df0de5abf0d655c7e5a38298296fe2ee7bb504f0663bf576637fdc759cae5294a123623430c7711ecc90ffc2d6ff6265e1987e42502cc03d3a1d0 WHIRLPOOL c3d87b6f47347b15837f1da67ce3a06c66ecf2f6d04f03788b9cbda9fd5c7a46d677f79755d3f4a30b2ce79d0df48ba52aab1f5268e35cb02bca2e7cd4218a27

View File

@ -0,0 +1 @@
edk2-99999.ebuild

View File

@ -0,0 +1,131 @@
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
inherit eutils multiprocessing toolchain-funcs
DESCRIPTION="EDK II Open Source UEFI Firmware"
HOMEPAGE="https://github.com/tianocore/tianocore.github.io/wiki/EDK-II"
LICENSE="BSD-2"
SLOT="0"
IUSE="debug +qemu +secure-boot"
if [[ ${PV} == 99999 ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/tianocore/edk2.git"
KEYWORDS="-* ~arm64 ~amd64"
else
EDK2_PV="vUDK2017"
S="${WORKDIR}/edk2-${EDK2_PV}"
SRC_URI="https://github.com/tianocore/edk2/archive/${EDK2_PV}.tar.gz"
KEYWORDS="-* arm64 amd64"
fi
OPENSSL_PV="1.1.0f"
OPENSSL_P="openssl-${OPENSSL_PV}"
SRC_URI+=" https://www.openssl.org/source/${OPENSSL_P}.tar.gz"
DEPEND="
amd64? (
>=dev-lang/nasm-2.10.0
sys-power/iasl
)"
RDEPEND="
!sys-firmware/edk2-armvirt
!sys-firmware/edk2-ovmf
amd64? (
qemu? ( app-emulation/qemu )
)"
src_unpack() {
[[ ${EGIT_REPO_URI} ]] && git-r3_src_unpack
unpack ${A}
}
src_prepare() {
epatch "${FILESDIR}/${PN}-2017.06-edksetup.patch"
epatch "${FILESDIR}/${PN}-2017.06-BaseTools.patch"
if use secure-boot; then
local openssllib="${S}/CryptoPkg/Library/OpensslLib"
mv "${WORKDIR}/${OPENSSL_P}" "${openssllib}/openssl" || \
die "openssl setup failed."
fi
}
src_configure() {
./edksetup.sh || die "edksetup.sh failed."
TARGET_NAME=$(usex debug DEBUG RELEASE)
TARGET_TOOLS="GCC$(gcc-version | tr -d .)"
case ${ARCH} in
amd64) TARGET_ARCH=X64 ;;
arm64) TARGET_ARCH=AARCH64 ;;
*) die "Unsupported ${ARCH}" ;;
esac
}
src_compile() {
# The BaseTools makefile has a conflicting ARCH variable.
local arch_save=${ARCH}
unset ARCH
emake -C BaseTools -j1
ARCH=${arch_save}
export GCC49_AARCH64_PREFIX="${CHOST}-"
source ./edksetup.sh || die "edksetup.sh failed."
case ${ARCH} in
amd64)
./OvmfPkg/build.sh \
-a "${TARGET_ARCH}" \
-b "${TARGET_NAME}" \
-t "${TARGET_TOOLS}" \
-n $(makeopts_jobs) \
-D SECURE_BOOT_ENABLE=$(usex secure-boot TRUE FALSE) \
-D FD_SIZE_2MB \
|| die "edk2 build failed."
;;
arm64)
build \
-a ${TARGET_ARCH} \
-b ${TARGET_NAME} \
-p ArmVirtPkg/ArmVirtQemu.dsc \
-t ${TARGET_TOOLS} \
-n $(makeopts_jobs) \
-D SECURE_BOOT_ENABLE=$(usex secure-boot TRUE FALSE) \
-D FD_SIZE_2MB \
|| die "edk2 build failed."
;;
*)
die "Unsupported ${ARCH}"
;;
esac
}
src_install() {
insinto /usr/share/${PN}
case ${ARCH} in
amd64)
local fv="Build/OvmfX64/${TARGET_NAME}_${TARGET_TOOLS}/FV"
doins "${fv}"/OVMF{,_CODE,_VARS}.fd
dosym OVMF.fd /usr/share/${PN}/bios.bin
if use qemu; then
dosym ../${PN}/OVMF.fd /usr/share/qemu/efi-bios.bin
fi
;;
arm64)
local fv="Build/ArmVirtQemu-${TARGET_ARCH}/${TARGET_NAME}_${TARGET_TOOLS}/FV"
doins "${fv}"/QEMU_EFI.fd
dosym QEMU_EFI.fd /usr/share/${PN}/bios.bin
;;
esac
}

View File

@ -0,0 +1,60 @@
commit 7a17214744ad7fdeee181d454618b0ceabd4f51c
Author: Geoff Levand <geoff@infradead.org>
Date: Wed Jul 26 17:52:24 2017 -0700
Fix BaseTools makefiles for pie compiler
Signed-off-by: Geoff Levand <geoff@infradead.org>
diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
index 063982b82f..693e08b942 100644
--- a/BaseTools/Source/C/Makefiles/header.makefile
+++ b/BaseTools/Source/C/Makefiles/header.makefile
@@ -51,7 +51,7 @@ BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-depreca
else
BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g
endif
-BUILD_LFLAGS =
+BUILD_LFLAGS = -nopie
BUILD_CXXFLAGS = -Wno-unused-result
ifeq ($(ARCH), IA32)
diff --git a/BaseTools/Source/C/VfrCompile/GNUmakefile b/BaseTools/Source/C/VfrCompile/GNUmakefile
index 2ebf3e0465..b81f51ecd7 100644
--- a/BaseTools/Source/C/VfrCompile/GNUmakefile
+++ b/BaseTools/Source/C/VfrCompile/GNUmakefile
@@ -36,6 +36,8 @@ include $(MAKEROOT)/Makefiles/header.makefile
APPLICATION = $(MAKEROOT)/bin/$(APPNAME)
+LFLAGS = -nopie
+
.PHONY:all
all: $(MAKEROOT)/bin $(APPLICATION)
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
index 8f2cc78c59..5bac6f9e5d 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
+++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/makefile
@@ -170,7 +170,7 @@ ANTLR=${BIN_DIR}/antlr
DLG=${BIN_DIR}/dlg
OBJ_EXT=o
OUT_OBJ = -o
-BUILD_CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536
+BUILD_CFLAGS= -nopie $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN $(COTHER) -DZZLEXBUFSIZE=65536
BUILD_CPPFLAGS=
#
# SGI Users, use this CFLAGS
diff --git a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile
index b3a34d3b46..1676ee7761 100644
--- a/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile
+++ b/BaseTools/Source/C/VfrCompile/Pccts/dlg/makefile
@@ -118,7 +118,7 @@ BUILD_CC?=cc
COPT=-O
ANTLR=${BIN_DIR}/antlr
DLG=${BIN_DIR}/dlg
-BUILD_CFLAGS= $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536
+BUILD_CFLAGS= -nopie $(COPT) -I. -I$(SET) -I$(PCCTS_H) -DUSER_ZZSYN -DZZLEXBUFSIZE=65536
BUILD_CPPFLAGS=
OBJ_EXT=o
OUT_OBJ = -o

View File

@ -0,0 +1,17 @@
commit cc3c0e45b929927ed49b16e0edddebbd2da05f74
Author: Geoff Levand <geoff@infradead.org>
Date: Thu Jul 20 16:26:08 2017 -0700
fix edksetup.sh
Signed-off-by: Geoff Levand <geoff@infradead.org>
diff --git a/edksetup.sh b/edksetup.sh
index ec54f9ea40..fb0213bd1b 100755
--- a/edksetup.sh
+++ b/edksetup.sh
@@ -146,4 +146,3 @@ SourceEnv
unset SCRIPTNAME RECONFIG
-return $?

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
</pkgmetadata>