git: 2e6a6ccd15d1 - main - sysutils/edk2: Add bhyve as a new FLAVOR of edk2

From: Rebecca Cran <bcran_at_FreeBSD.org>
Date: Wed, 25 May 2022 19:34:07 UTC
The branch main has been updated by bcran (src committer):

URL: https://cgit.FreeBSD.org/ports/commit/?id=2e6a6ccd15d1c2b83ea238325b9feddff4f8eaa7

commit 2e6a6ccd15d1c2b83ea238325b9feddff4f8eaa7
Author:     Rebecca Cran <bcran@FreeBSD.org>
AuthorDate: 2022-05-25 19:33:53 +0000
Commit:     Rebecca Cran <bcran@FreeBSD.org>
CommitDate: 2022-05-25 19:33:53 +0000

    sysutils/edk2: Add bhyve as a new FLAVOR of edk2
    
    Instead of having a separate sysutils/uefi-edk2-bhyve port, add bhyve
    as a FLAVOR of sysutils/edk2 and delete sysutils/uefi-edk2-bhyve.
    
    To support existing users who depend on firmware in
    /usr/local/share/uefi-firmware create compatibility symlinks.
    
    Update sysutils/bhyve-firmware to depend on edk2@bhyve.
    
    Differential Revision: https://reviews.freebsd.org/D35148
    Reviewed by: manu
    Approved by: manu
---
 MOVED                                              |  1 +
 sysutils/bhyve-firmware/Makefile                   |  2 +-
 sysutils/edk2/Makefile                             | 41 +++++++++-
 sysutils/uefi-edk2-bhyve/Makefile                  | 92 ----------------------
 sysutils/uefi-edk2-bhyve/distinfo                  | 13 ---
 sysutils/uefi-edk2-bhyve/files/patch-fix-warnings  | 29 -------
 .../files/patch-stringpop-overflows                | 22 ------
 sysutils/uefi-edk2-bhyve/pkg-descr                 | 17 ----
 8 files changed, 42 insertions(+), 175 deletions(-)

diff --git a/MOVED b/MOVED
index c999acfc2be1..d15deaad4576 100644
--- a/MOVED
+++ b/MOVED
@@ -17177,4 +17177,5 @@ java/openjdk13||2022-05-24|Has expired: EOLed since 31 march 2020
 java/openjdk14||2022-05-24|Has expired: EOLed since 30 september 2020
 java/openjdk15||2022-05-24|Has expired: EOLed since 31 march 2021
 java/openjdk16||2022-05-24|Has expired: EOLed since 30 September 2021
+sysutils/uefi-edk2-bhyve||2022-05-24|No more need for this port: please use sysutils/edk2 FLAVOR bhyve instead
 archivers/p7zip|archivers/7-zip|2022-05-25|Unmaintained for years and has known vulnerabilities. Use 7-Zip instead
diff --git a/sysutils/bhyve-firmware/Makefile b/sysutils/bhyve-firmware/Makefile
index 3c601a11f7ef..5af09d45882b 100644
--- a/sysutils/bhyve-firmware/Makefile
+++ b/sysutils/bhyve-firmware/Makefile
@@ -6,7 +6,7 @@ CATEGORIES=	sysutils
 MAINTAINER=	fabian.freyer@physik.tu-berlin.de
 COMMENT=	Collection of Firmware for bhyve
 
-RUN_DEPENDS=	uefi-edk2-bhyve>=0:sysutils/uefi-edk2-bhyve
+RUN_DEPENDS=	${LOCALBASE}/share/uefi-firmware/BHYVE_UEFI_CODE.fd:sysutils/edk2@bhyve
 
 USES=			metaport
 OPTIONS_DEFINE=		CSM
diff --git a/sysutils/edk2/Makefile b/sysutils/edk2/Makefile
index a0aea2b1e139..325b85ab166d 100644
--- a/sysutils/edk2/Makefile
+++ b/sysutils/edk2/Makefile
@@ -11,7 +11,7 @@ ONLY_FOR_ARCHS=		aarch64 amd64
 ONLY_FOR_ARCHS_REASON=	only provides firmware for aarch64 and amd64
 
 PKGNAMESUFFIX=	-${FLAVOR:C/_/-/g}
-FLAVORS=	macchiatobin fvp rpi3 rpi4 xen_x64
+FLAVORS=	macchiatobin fvp rpi3 rpi4 xen_x64 bhyve
 
 USES=	cpe gmake python:3.7+,build
 CPE_VENDOR=	tianocore
@@ -95,7 +95,33 @@ PLAT_RESULT=	OvmfXen/${PLAT_TARGET}_GCC5/FV/OVMF.fd
 PLAT_FILENAME=	XEN_X64_EFI.fd
 .endif
 
+.if ${FLAVOR} == bhyve
+ONLY_FOR_ARCHS=	amd64
+ONLY_FOR_ARCHS_REASON= Bhyve only runs on x64
+PLAT=		bhyve
+PLAT_ARCH=	X64
+PLAT_TARGET=	RELEASE
+PLATFILE=	OvmfPkg/Bhyve/BhyveX64.dsc
+PLAT_RESULT=	BhyveX64/${PLAT_TARGET}_GCC5/FV/BHYVE.fd
+PLAT_RESULT_CODE=	BhyveX64/${PLAT_TARGET}_GCC5/FV/BHYVE_CODE.fd
+PLAT_RESULT_VARS=	BhyveX64/${PLAT_TARGET}_GCC5/FV/BHYVE_VARS.fd
+PLAT_FILENAME=	BHYVE_UEFI.fd
+PLAT_FILENAME_CODE	= BHYVE_UEFI_CODE.fd
+PLAT_FILENAME_VARS	= BHYVE_UEFI_VARS.fd
+.endif
+
 PLIST_FILES=	${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME}
+.if defined(PLAT_FILENAME_CODE)
+PLIST_FILES+=	${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME_CODE}
+.endif
+.if defined(PLAT_FILENAME_VARS)
+PLIST_FILES+=	${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME_VARS}
+.endif
+.if ${FLAVOR} == bhyve
+PLIST_FILES+=	${PREFIX}/share/uefi-firmware/${PLAT_FILENAME}
+PLIST_FILES+=	${PREFIX}/share/uefi-firmware/${PLAT_FILENAME_CODE}
+PLIST_FILES+=	${PREFIX}/share/uefi-firmware/${PLAT_FILENAME_VARS}
+.endif
 
 # Emulate source edk2/edksetup.sh
 MAKE_ENV+=	WORKSPACE=${WRKDIR} \
@@ -132,5 +158,18 @@ do-build:
 do-install:
 	${MKDIR} ${STAGEDIR}/${PREFIX}/share/${PORTNAME}-${PLAT}/
 	${INSTALL_DATA} ${WRKDIR}/Build/${PLAT_RESULT} ${STAGEDIR}/${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME}
+.if defined(PLAT_FILENAME_CODE)
+	${INSTALL_DATA} ${WRKDIR}/Build/${PLAT_RESULT_CODE} ${STAGEDIR}/${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME_CODE}
+.endif
+.if defined(PLAT_FILENAME_VARS)
+	${INSTALL_DATA} ${WRKDIR}/Build/${PLAT_RESULT_VARS} ${STAGEDIR}/${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME_VARS}
+.endif
+.if ${FLAVOR} == bhyve
+	# For backwards compatibility
+	${MKDIR} ${STAGEDIR}/${PREFIX}/share/uefi-firmware/
+	${RLN} ${STAGEDIR}/${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME} ${STAGEDIR}/${PREFIX}/share/uefi-firmware/${PLAT_FILENAME}
+	${RLN} ${STAGEDIR}/${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME_CODE} ${STAGEDIR}/${PREFIX}/share/uefi-firmware/${PLAT_FILENAME_CODE}
+	${RLN} ${STAGEDIR}/${PREFIX}/share/${PORTNAME}-${PLAT}/${PLAT_FILENAME_VARS} ${STAGEDIR}/${PREFIX}/share/uefi-firmware/${PLAT_FILENAME_VARS}
+.endif
 
 .include <bsd.port.post.mk>
diff --git a/sysutils/uefi-edk2-bhyve/Makefile b/sysutils/uefi-edk2-bhyve/Makefile
deleted file mode 100644
index 9769fc41316b..000000000000
--- a/sysutils/uefi-edk2-bhyve/Makefile
+++ /dev/null
@@ -1,92 +0,0 @@
-PORTNAME=	uefi-edk2-bhyve
-PORTVERSION=	g20210226
-PORTREVISION=	1
-PORTEPOCH=	2
-CATEGORIES=	sysutils
-
-MAINTAINER=	bcran@FreeBSD.org
-COMMENT=	UEFI EDK2 firmware for bhyve
-
-LICENSE=	BSD2CLAUSE+PATENT
-LICENSE_GROUPS=	FSF OSI COPYFREE
-LICENSE_NAME=	BSD-2-Clause Plus Patent License
-LICENSE_FILE=	${WRKSRC}/License.txt
-LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
-
-ONLY_FOR_ARCHS=	amd64
-ONLY_FOR_ARCHS_REASON=	bhyve firmware has only been ported to X64
-
-BUILD_DEPENDS=	nasm:devel/nasm \
-		bash:shells/bash
-
-USES=		gmake \
-		python:3.7+,build
-USE_GCC=	yes:build
-USE_GITHUB=	yes
-GH_ACCOUNT=	tianocore
-GH_PROJECT=	edk2
-GH_TAGNAME=	edk2-stable202102
-GH_TUPLE=	ucb-bar:berkeley-softfloat-3:master:softfloat/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 \
-		google:brotli:v1.0.7-17-g666c328:brotli/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli \
-		openssl:openssl:OpenSSL_1_1_1g:openssl/CryptoPkg/Library/OpensslLib/openssl \
-		kkos:oniguruma:v6.9.4_mark1:oniguruma/MdeModulePkg/Universal/RegularExpressionDxe/oniguruma \
-		akheron:jansson:v2.13.1:jansson/RedfishPkg/Library/JsonLib/jansson \
-
-BINARY_ALIAS=	make=${LOCALBASE}/bin/gmake \
-		gcc=${LOCALBASE}/bin/gcc${GCC_DEFAULT} \
-		gcc-ar=${LOCALBASE}/bin/gcc-ar${GCC_DEFAULT} \
-		g++=${LOCALBASE}/bin/g++${GCC_DEFAULT} \
-		python3=${PYTHON_CMD} python=${PYTHON_CMD}
-
-PLAT_ARCH=	X64
-PLAT_FILE=	OvmfPkg/Bhyve/BhyveX64.dsc
-PLAT_RESULT=	BhyveX64/${PLAT_TARGET}_GCC5/FV/BHYVE.fd
-PLAT_RESULT_CODE=	BhyveX64/${PLAT_TARGET}_GCC5/FV/BHYVE_CODE.fd
-PLAT_RESULT_VARS=	BhyveX64/${PLAT_TARGET}_GCC5/FV/BHYVE_VARS.fd
-
-PLIST_FILES=	${PREFIX}/share/uefi-firmware/BHYVE_UEFI.fd      \
-		${PREFIX}/share/uefi-firmware/BHYVE_UEFI_CODE.fd \
-		${PREFIX}/share/uefi-firmware/BHYVE_UEFI_VARS.fd
-
-OPTIONS_DEFINE=	DEBUG HTTP_BOOT
-OPTIONS_DEFAULT=	HTTP_BOOT
-
-DEBUG_DESC=	Build a debug configuration
-HTTP_BOOT_DESC=	Build with HTTP(S) boot support
-
-DEBUG_VARS=	PLAT_TARGET=DEBUG
-DEBUG_VARS_OFF=	PLAT_TARGET=RELEASE
-HTTP_BOOT_VARS=	PLAT_ARGS+=-DNETWORK_HTTP_BOOT_ENABLE=TRUE
-
-PLAT_ARGS+=	-DDEBUG_ON_SERIAL_PORT=TRUE
-
-# Emulate source edk2/edksetup.sh
-MAKE_ENV+=	WORKSPACE=${WRKDIR} \
-		PACKAGES_PATH=${WRKDIR}/edk2-${GH_TAGNAME} \
-		CONF_PATH=${WRKDIR}/edk2-${GH_TAGNAME}/Conf \
-		EDK_TOOLS_PATH=${WRKDIR}/edk2-${GH_TAGNAME}/BaseTools \
-		PATH=${WRKDIR}/edk2-${GH_TAGNAME}/BaseTools/BinWrappers/PosixLike:${PATH} \
-		PYTHON_COMMAND=python3 \
-		PYTHONHASHSEED=1
-
-# We can't have two submodule with the same origin in GH_TUPLE
-post-extract:
-	(cd ${WRKDIR}/edk2-${GH_TAGNAME}/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli && tar cf - * | tar xf - -C ../../../../BaseTools/Source/C/BrotliCompress/brotli)
-
-do-build:
-	# This is normaly done during source edksetup.sh
-	(cp ${WRKDIR}/edk2-${GH_TAGNAME}/BaseTools/Conf/build_rule.template ${WRKDIR}/edk2-${GH_TAGNAME}/Conf/build_rule.txt)
-	(cp ${WRKDIR}/edk2-${GH_TAGNAME}/BaseTools/Conf/tools_def.template ${WRKDIR}/edk2-${GH_TAGNAME}/Conf/tools_def.txt)
-	(cp ${WRKDIR}/edk2-${GH_TAGNAME}/BaseTools/Conf/target.template ${WRKDIR}/edk2-${GH_TAGNAME}/Conf/target.txt)
-	# Build the basetools
-	(cd ${WRKDIR} && ${SETENV} ${MAKE_ENV} ${MAKE_CMD} -C edk2-${GH_TAGNAME}/BaseTools -j ${MAKE_JOBS_NUMBER} ${_MAKE_JOBS})
-	# Build EDK2
-	(cd ${WRKDIR}/edk2-${GH_TAGNAME} && ${SETENV} ${MAKE_ENV} BaseTools/BinWrappers/PosixLike/build -a ${PLAT_ARCH} -p ${PLAT_FILE} -n ${MAKE_JOBS_NUMBER} -t GCC5 -b ${PLAT_TARGET} ${PLAT_ARGS})
-
-do-install:
-	${MKDIR} ${STAGEDIR}/${PREFIX}/share/uefi-firmware/
-	${INSTALL_DATA} ${WRKDIR}/Build/${PLAT_RESULT_CODE} ${STAGEDIR}/${PREFIX}/share/uefi-firmware/BHYVE_UEFI.fd
-	${INSTALL_DATA} ${WRKDIR}/Build/${PLAT_RESULT_CODE} ${STAGEDIR}/${PREFIX}/share/uefi-firmware/BHYVE_UEFI_CODE.fd
-	${INSTALL_DATA} ${WRKDIR}/Build/${PLAT_RESULT_VARS} ${STAGEDIR}/${PREFIX}/share/uefi-firmware/BHYVE_UEFI_VARS.fd
-
-.include <bsd.port.mk>
diff --git a/sysutils/uefi-edk2-bhyve/distinfo b/sysutils/uefi-edk2-bhyve/distinfo
deleted file mode 100644
index 42ce56628a63..000000000000
--- a/sysutils/uefi-edk2-bhyve/distinfo
+++ /dev/null
@@ -1,13 +0,0 @@
-TIMESTAMP = 1619914029
-SHA256 (tianocore-edk2-g20210226-edk2-stable202102_GH0.tar.gz) = 268591f0db8fd1f8c977509e8ac37bd6090c8373bf63a9657c88bb27bb43a279
-SIZE (tianocore-edk2-g20210226-edk2-stable202102_GH0.tar.gz) = 13604550
-SHA256 (ucb-bar-berkeley-softfloat-3-master_GH0.tar.gz) = a40ccfa8d5c04971e6af8014217c93b58fba4d08c337bc0436bb141e9e79426a
-SIZE (ucb-bar-berkeley-softfloat-3-master_GH0.tar.gz) = 148747
-SHA256 (google-brotli-v1.0.7-17-g666c328_GH0.tar.gz) = caed254751585590b20b4a34d6600e9c9aae153ab1f9e1ae6b67f9bc3ee09b92
-SIZE (google-brotli-v1.0.7-17-g666c328_GH0.tar.gz) = 23854268
-SHA256 (openssl-openssl-OpenSSL_1_1_1g_GH0.tar.gz) = 281e4f13142b53657bd154481e18195b2d477572fdffa8ed1065f73ef5a19777
-SIZE (openssl-openssl-OpenSSL_1_1_1g_GH0.tar.gz) = 9975550
-SHA256 (kkos-oniguruma-v6.9.4_mark1_GH0.tar.gz) = 7f7576c926f7d4a071d594a01691c477bbb9391df250378bd5e1c003d42b4318
-SIZE (kkos-oniguruma-v6.9.4_mark1_GH0.tar.gz) = 592141
-SHA256 (akheron-jansson-v2.13.1_GH0.tar.gz) = f22901582138e3203959c9257cf83eba9929ac41d7be4a42557213a22ebcc7a0
-SIZE (akheron-jansson-v2.13.1_GH0.tar.gz) = 144979
diff --git a/sysutils/uefi-edk2-bhyve/files/patch-fix-warnings b/sysutils/uefi-edk2-bhyve/files/patch-fix-warnings
deleted file mode 100644
index 10e373e824a6..000000000000
--- a/sysutils/uefi-edk2-bhyve/files/patch-fix-warnings
+++ /dev/null
@@ -1,29 +0,0 @@
---- BaseTools/Source/C/BrotliCompress/brotli/c/dec/decode.c	
-+++ BaseTools/Source/C/BrotliCompress/brotli/c/dec/decode.c	
-@@ -2033,8 +2033,10 @@ static BROTLI_NOINLINE BrotliDecoderErrorCode SafeProcessCommands(
- }
- 
- BrotliDecoderResult BrotliDecoderDecompress(
--    size_t encoded_size, const uint8_t* encoded_buffer, size_t* decoded_size,
--    uint8_t* decoded_buffer) {
-+    size_t encoded_size,
-+    const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)],
-+    size_t* decoded_size,
-+    uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)]) {
-   BrotliDecoderState s;
-   BrotliDecoderResult result;
-   size_t total_out = 0;
---- BaseTools/Source/C/BrotliCompress/brotli/c/enc/encode.c	
-+++ BaseTools/Source/C/BrotliCompress/brotli/c/enc/encode.c	
-@@ -1470,8 +1470,9 @@ static size_t MakeUncompressedStream(
- 
- BROTLI_BOOL BrotliEncoderCompress(
-     int quality, int lgwin, BrotliEncoderMode mode, size_t input_size,
--    const uint8_t* input_buffer, size_t* encoded_size,
--    uint8_t* encoded_buffer) {
-+    const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)],
-+    size_t* encoded_size,
-+    uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)]) {
-   BrotliEncoderState* s;
-   size_t out_size = *encoded_size;
-   const uint8_t* input_start = input_buffer;
diff --git a/sysutils/uefi-edk2-bhyve/files/patch-stringpop-overflows b/sysutils/uefi-edk2-bhyve/files/patch-stringpop-overflows
deleted file mode 100644
index 9f7a4986a53f..000000000000
--- a/sysutils/uefi-edk2-bhyve/files/patch-stringpop-overflows
+++ /dev/null
@@ -1,22 +0,0 @@
---- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c	
-+++ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c	
-@@ -285,7 +285,7 @@ UsbHcBulkTransfer (
-   IN  UINT8                               DevSpeed,
-   IN  UINTN                               MaxPacket,
-   IN  UINT8                               BufferNum,
--  IN  OUT VOID                            *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
-+  IN  OUT VOID                            **Data,
-   IN  OUT UINTN                           *DataLength,
-   IN  OUT UINT8                           *DataToggle,
-   IN  UINTN                               TimeOut,
---- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h	
-+++ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h	
-@@ -149,7 +149,7 @@ UsbHcBulkTransfer (
-   IN  UINT8                               DevSpeed,
-   IN  UINTN                               MaxPacket,
-   IN  UINT8                               BufferNum,
--  IN  OUT VOID                            *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
-+  IN  OUT VOID                            **Data,
-   IN  OUT UINTN                           *DataLength,
-   IN  OUT UINT8                           *DataToggle,
-   IN  UINTN                               TimeOut,
diff --git a/sysutils/uefi-edk2-bhyve/pkg-descr b/sysutils/uefi-edk2-bhyve/pkg-descr
deleted file mode 100644
index 1ad80c379e33..000000000000
--- a/sysutils/uefi-edk2-bhyve/pkg-descr
+++ /dev/null
@@ -1,17 +0,0 @@
-UEFI EDK2 firmware for bhyve.
-
-From https://github.com/tianocore/tianocore/wiki/UEFI :
-"The Unified Extensible Firmware Interface, or UEFI, specifies the
-firmware layer between an operating system and platform hardware. UEFI
-replaces the legacy Basic Input Output System (BIOS)."
-
-EDK2 is the project from TianoCore (https://tianocore.org) that provides
-"a modern, feature-rich, cross-platform development environment for the
-UEFI and UEFI Platform Initialization (PI) specifications."
-
-It's open source under the BSD-2-Clause-Patent license.
-
-This port provides a version of EDK2 for use with VMs running
-operating systems which have UEFI support.
-
-WWW: https://github.com/tianocore/edk2/tree/master/OvmfPkg/Bhyve