# Template file for 'edk2-ovmf' pkgname=edk2-ovmf version=202405 revision=1 _mipi_ver=370b5944c046bab043dd8b133727b2135af7747a _openssl_ver=3.0.9 _mbedtls_ver=8c89224991adff88d53cd380f42a2baa36f91454 _softfloat_ver=b64af41c3276f97f0e181920400ee056b9c88037 _spdm_ver=3.3.0 archs="x86_64* i686* aarch64*" hostmakedepends="acpica-utils nasm python3 libuuid-devel" short_desc="EFI Development Kit II - Open Virtual Machine Firmware" maintainer="classabbyamp " license="BSD-2-Clause-Patent, MIT" homepage="https://github.com/tianocore/tianocore.github.io/wiki/EDK-II" changelog="https://github.com/tianocore/edk2/releases" distfiles="https://github.com/tianocore/edk2/archive/refs/tags/edk2-stable${version}.tar.gz https://github.com/MIPI-Alliance/public-mipi-sys-t/archive/${_mipi_ver}.tar.gz>mipi-${_mipi_ver}.tar.gz https://www.openssl.org/source/openssl-${_openssl_ver}.tar.gz https://github.com/Mbed-TLS/mbedtls/archive/${_mbedtls_ver}.tar.gz>mbedtls-${_mbedtls_ver}.tar.gz https://github.com/ucb-bar/berkeley-softfloat-3/archive/${_softfloat_ver}.tar.gz>softfloat-${_softfloat_ver}.tar.gz https://github.com/DMTF/libspdm/archive/refs/tags/${_spdm_ver}.tar.gz>libspdm-${_spdm_ver}.tar.gz" checksum="53cbf51f2ca7aea9ef67ca9aeb6276dc5643c87b5ccdb7fe9f9936361623d7be 9fda3b9a78343ab2be6f06ce6396536e7e065abac29b47c8eb2e42cbb4c4f00b eb1ab04781474360f77c318ab89d8c5a03abc38e63d65a603cabbf1b00a1dc90 b5c7e7c54e013c168f4aae036e59912785f11b4aeebd57f6165a14e879b9a82c faae889814ea6a292f7ca03d9b36e6c7e95bab2a64777804883cc822b8d48757 178c7bd785b3ac71b886b8360dab926d42e4d5edc55009bcd341295f25f56c91" skip_extraction="mipi-${_mipi_ver}.tar.gz openssl-${_openssl_ver}.tar.gz mbedtls-${_mbedtls_ver}.tar.gz softfloat-${_softfloat_ver}.tar.gz libspdm-${_spdm_ver}.tar.gz" case "$XBPS_TARGET_LIBC" in glibc) _pfx="gnu" ;; musl) _pfx="musl" ;; esac case "$XBPS_MACHINE" in x86_64*|i686*) hostmakedepends+=" cross-aarch64-linux-${_pfx} cross-arm-linux-${_pfx}eabihf" ;; esac case "$XBPS_TARGET_MACHINE" in x86_64*) _archs=(X64 IA32 AARCH64 ARM) ;; i686*) _archs=(IA32 AARCH64 ARM) ;; aarch64*) _archs=(AARCH64) ;; esac post_extract() { vsrcextract -C MdePkg/Library/MipiSysTLib/mipisyst "mipi-${_mipi_ver}.tar.gz" vsrcextract -C CryptoPkg/Library/OpensslLib/openssl "openssl-${_openssl_ver}.tar.gz" vsrcextract -C CryptoPkg/Library/MbedTlsLib/mbedtls "mbedtls-${_mbedtls_ver}.tar.gz" vsrcextract -C ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 "softfloat-${_softfloat_ver}.tar.gz" vsrcextract -C SecurityPkg/DeviceSecurity/SpdmLib/libspdm "libspdm-${_spdm_ver}.tar.gz" } do_build() { local PATH="BaseTools/BinWrappers/PosixLike:$PATH" local _common_args=(-b RELEASE -n "$XBPS_MAKEJOBS" -t GCC5) local _efi_args=(-D NETWORK_IP6_ENABLE -D TPM_CONFIG_ENABLE -D TPM1_ENABLE -D TPM2_ENABLE) local _x86_args=(-D FD_SIZE_2MB -D HTTP_BOOT_ENABLE -D TLS_ENABLE) local _4mb_args=(-D FD_SIZE_4MB -D FD_SIZE_IN_KB=4096 -D HTTP_BOOT_ENABLE -D TLS_ENABLE) case "$XBPS_MACHINE" in x86_64*|i686*) export GCC5_AARCH64_PREFIX="aarch64-linux-${_pfx}-" export GCC5_ARM_PREFIX="arm-linux-${_pfx}eabihf-" ;; esac for _arch in "${_archs[@]}"; do CC=gcc CXX=g++ ARCH="${_arch}" make "${makejobs}" -C BaseTools done . edksetup.sh for _arch in "${_archs[@]}"; do msg_normal "$pkgver: building shell ($_arch)\n" build -p ShellPkg/ShellPkg.dsc -a "$_arch" "${_common_args[@]}" case "${_arch}" in X64) msg_normal "$pkgver: building ovmf ($_arch) with secure boot support (4MB FD)\n" build -p "OvmfPkg/OvmfPkgIa32X64.dsc" -a IA32 -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_4mb_args[@]}" \ -D SECURE_BOOT_ENABLE -D SMM_REQUIRE -D EXCLUDE_SHELL_FROM_FD mv -v Build/Ovmf3264{,-secure-4mb} msg_normal "$pkgver: building ovmf ($_arch) with secure boot support\n" build -p "OvmfPkg/OvmfPkgIa32X64.dsc" -a IA32 -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_x86_args[@]}" \ -D SECURE_BOOT_ENABLE -D SMM_REQUIRE -D EXCLUDE_SHELL_FROM_FD mv -v Build/Ovmf3264{,-secure} msg_normal "$pkgver: building ovmf ($_arch) default (4MB FD)\n" build -p "OvmfPkg/OvmfPkg${_arch}.dsc" -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_4mb_args[@]}" mv -v Build/OvmfX64{,-4mb} msg_normal "$pkgver: building ovmf ($_arch) default\n" build -p "OvmfPkg/OvmfPkg${_arch}.dsc" -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_x86_args[@]}" msg_normal "$pkgver: building ovmf ($_arch) with microvm support (4MB FD)\n" build -p "OvmfPkg/Microvm/Microvm${_arch}.dsc" -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_4mb_args[@]}" mv -v Build/MicrovmX64{,-4mb} msg_normal "$pkgver: building ovmf ($_arch) with microvm support\n" build -p "OvmfPkg/Microvm/Microvm${_arch}.dsc" -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_x86_args[@]}" ;; IA32) msg_normal "$pkgver: building ovmf ($_arch) with secure boot support (4MB FD)\n" build -p "OvmfPkg/OvmfPkgIa32.dsc" -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_4mb_args[@]}" \ -D SECURE_BOOT_ENABLE -D SMM_REQUIRE -D EXCLUDE_SHELL_FROM_FD -D LOAD_X64_ON_IA32_ENABLE mv -v Build/Ovmf{Ia32,IA32-secure-4mb} msg_normal "$pkgver: building ovmf ($_arch) with secure boot support\n" build -p "OvmfPkg/OvmfPkgIa32.dsc" -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_x86_args[@]}" \ -D SECURE_BOOT_ENABLE -D SMM_REQUIRE -D EXCLUDE_SHELL_FROM_FD -D LOAD_X64_ON_IA32_ENABLE mv -v Build/Ovmf{Ia32,IA32-secure} msg_normal "$pkgver: building ovmf ($_arch) default (4MB FD)\n" build -p "OvmfPkg/OvmfPkgIa32.dsc" -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_4mb_args[@]}" \ -D LOAD_X64_ON_IA32_ENABLE mv -v Build/Ovmf{Ia32,IA32-4mb} msg_normal "$pkgver: building ovmf ($_arch) default\n" build -p "OvmfPkg/OvmfPkgIa32.dsc" -a "$_arch" \ "${_common_args[@]}" "${_efi_args[@]}" "${_x86_args[@]}" \ -D LOAD_X64_ON_IA32_ENABLE mv -v Build/Ovmf{Ia32,IA32} ;; A*) msg_normal "Building ArmVirtPkg ($_arch) with secure boot\n" build -p "ArmVirtPkg/ArmVirtQemu.dsc" -a "${_arch}" \ "${_common_args[@]}" "${_efi_args[@]}" \ -D NETWORK_HTTP_BOOT_ENABLE -D NETWORK_TLS_ENABLE -D SECURE_BOOT_ENABLE dd if=/dev/zero of="Build/ArmVirtQemu-$_arch/RELEASE_GCC5/FV/QEMU_CODE.fd" bs=1M count=64 dd if="Build/ArmVirtQemu-$_arch/RELEASE_GCC5/FV/QEMU_EFI.fd" \ of="Build/ArmVirtQemu-$_arch/RELEASE_GCC5/FV/QEMU_CODE.fd" conv=notrunc dd if=/dev/zero of="Build/ArmVirtQemu-$_arch/RELEASE_GCC5/FV/QEMU_VARS.fd" bs=1M count=64 ;; esac done } do_install() { vmkdir usr/share/qemu/firmware vmkdir usr/share/AAVMF for _arch in "${_archs[@]}"; do vmkdir "usr/share/edk2/${_arch,,}" vinstall "Build/Shell/RELEASE_GCC5/${_arch}/Shell_7C04A583-9E3E-4f1c-AD65-E05268D0B4D1.efi" 644 \ "usr/share/edk2/${_arch,,}" Shell.efi vinstall "Build/Shell/RELEASE_GCC5/${_arch}/Shell_EA4BB293-2D7F-4456-A681-1F22F42CD0BC.efi" 644 \ "usr/share/edk2/${_arch,,}" Shell_Full.efi case "$_arch" in X64) vinstall "Build/Ovmf${_arch}/RELEASE_GCC5/FV/OVMF.fd" 644 "usr/share/edk2/${_arch,,}" vinstall "Build/Ovmf${_arch}/RELEASE_GCC5/FV/OVMF_CODE.fd" 644 "usr/share/edk2/${_arch,,}" vinstall "Build/Ovmf${_arch}/RELEASE_GCC5/FV/OVMF_VARS.fd" 644 "usr/share/edk2/${_arch,,}" vinstall "Build/Ovmf${_arch}-4mb/RELEASE_GCC5/FV/OVMF.fd" 644 "usr/share/edk2/${_arch,,}" OVMF.4m.fd vinstall "Build/Ovmf${_arch}-4mb/RELEASE_GCC5/FV/OVMF_CODE.fd" 644 "usr/share/edk2/${_arch,,}" OVMF_CODE.4m.fd vinstall "Build/Ovmf${_arch}-4mb/RELEASE_GCC5/FV/OVMF_VARS.fd" 644 "usr/share/edk2/${_arch,,}" OVMF_VARS.4m.fd vinstall "Build/Ovmf3264-secure/RELEASE_GCC5/FV/OVMF_CODE.fd" 644 "usr/share/edk2/${_arch,,}" OVMF_CODE.secure.fd vinstall "Build/Ovmf3264-secure-4mb/RELEASE_GCC5/FV/OVMF_CODE.fd" 644 "usr/share/edk2/${_arch,,}" OVMF_CODE.secure.4m.fd vinstall "Build/MicrovmX64/RELEASE_GCC5/FV/MICROVM.fd" 644 "usr/share/edk2/${_arch,,}" MICROVM.fd vinstall "Build/MicrovmX64-4mb/RELEASE_GCC5/FV/MICROVM.fd" 644 "usr/share/edk2/${_arch,,}" MICROVM.4m.fd vcopy "${FILESDIR}/*x86_64*.json" usr/share/qemu/firmware vcopy "${FILESDIR}/*microvm*.json" usr/share/qemu/firmware ;; IA32) vinstall "Build/Ovmf${_arch}/RELEASE_GCC5/FV/OVMF.fd" 644 "usr/share/edk2/${_arch,,}" vinstall "Build/Ovmf${_arch}/RELEASE_GCC5/FV/OVMF_CODE.fd" 644 "usr/share/edk2/${_arch,,}" vinstall "Build/Ovmf${_arch}/RELEASE_GCC5/FV/OVMF_VARS.fd" 644 "usr/share/edk2/${_arch,,}" vinstall "Build/Ovmf${_arch}-4mb/RELEASE_GCC5/FV/OVMF.fd" 644 "usr/share/edk2/${_arch,,}" OVMF.4m.fd vinstall "Build/Ovmf${_arch}-4mb/RELEASE_GCC5/FV/OVMF_CODE.fd" 644 "usr/share/edk2/${_arch,,}" OVMF_CODE.4m.fd vinstall "Build/Ovmf${_arch}-4mb/RELEASE_GCC5/FV/OVMF_VARS.fd" 644 "usr/share/edk2/${_arch,,}" OVMF_VARS.4m.fd vinstall "Build/Ovmf${_arch}-secure/RELEASE_GCC5/FV/OVMF_CODE.fd" 644 "usr/share/edk2/${_arch,,}" OVMF_CODE.secure.fd vinstall "Build/Ovmf${_arch}-secure-4mb/RELEASE_GCC5/FV/OVMF_CODE.fd" 644 "usr/share/edk2/${_arch,,}" OVMF_CODE.secure.4m.fd vcopy "${FILESDIR}/*i386*.json" usr/share/qemu/firmware ;; AARCH64) vcopy "Build/ArmVirtQemu-${_arch}/RELEASE_GCC5/FV/*.fd" "usr/share/edk2/${_arch,,}" # libvirt hardcodes this ln -s ../edk2/aarch64/QEMU_CODE.fd "${DESTDIR}/usr/share/AAVMF/AAVMF_CODE.fd" ln -s ../edk2/aarch64/QEMU_VARS.fd "${DESTDIR}/usr/share/AAVMF/AAVMF_VARS.fd" vcopy "${FILESDIR}/*aarch64*.json" usr/share/qemu/firmware ;; ARM) vcopy "Build/ArmVirtQemu-${_arch}/RELEASE_GCC5/FV/*.fd" "usr/share/edk2/${_arch,,}" # libvirt hardcodes this ln -s ../edk2/arm/QEMU_CODE.fd "${DESTDIR}/usr/share/AAVMF/AAVMF32_CODE.fd" ln -s ../edk2/arm/QEMU_VARS.fd "${DESTDIR}/usr/share/AAVMF/AAVMF32_VARS.fd" vcopy "${FILESDIR}/*arm*.json" usr/share/qemu/firmware ;; esac done # lxd hardcodes this ln -s ./edk2 "${DESTDIR}/usr/share/OVMF" vlicense License.txt vlicense OvmfPkg/License.txt OvmfPkg.License.txt } edk2-shell_package() { short_desc="EFI Development Kit II - Shell" pkg_install() { for _arch in "${_archs[@]}"; do vmove "usr/share/edk2/${_arch,,}/Shell*.efi" done vlicense License.txt } }