void-packages/srcpkgs/edk2-ovmf/template

241 lines
10 KiB
Bash
Raw Permalink Normal View History

2023-11-27 06:47:57 +01:00
# Template file for 'edk2-ovmf'
pkgname=edk2-ovmf
2024-11-15 01:05:26 +01:00
version=202408.01
2024-05-27 00:32:20 +02:00
revision=1
_mipi_ver=370b5944c046bab043dd8b133727b2135af7747a
_openssl_ver=3.0.9
_mbedtls_ver=8c89224991adff88d53cd380f42a2baa36f91454
_softfloat_ver=b64af41c3276f97f0e181920400ee056b9c88037
2024-08-31 08:09:32 +02:00
_spdm_ver=3.4.0
_fdt_ver=cfff805481bdea27f900c32698171286542b8d3c
2024-03-26 01:36:42 +01:00
archs="x86_64* i686* aarch64*"
hostmakedepends="acpica-utils nasm python3 libuuid-devel"
2023-11-27 06:47:57 +01:00
short_desc="EFI Development Kit II - Open Virtual Machine Firmware"
maintainer="classabbyamp <void@placeviolette.net>"
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
2024-05-27 00:32:20 +02:00
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
2024-08-31 08:09:32 +02:00
https://github.com/DMTF/libspdm/archive/refs/tags/${_spdm_ver}.tar.gz>libspdm-${_spdm_ver}.tar.gz
https://github.com/devicetree-org/pylibfdt/archive/${_fdt_ver}.tar.gz>libfdt-${_fdt_ver}.tar.gz"
2024-11-15 01:05:26 +01:00
checksum="3ea3988f885d9ca28b255111646440eb31491dc6d3f556b770e7ac90099755e0
2023-11-27 06:47:57 +01:00
9fda3b9a78343ab2be6f06ce6396536e7e065abac29b47c8eb2e42cbb4c4f00b
eb1ab04781474360f77c318ab89d8c5a03abc38e63d65a603cabbf1b00a1dc90
b5c7e7c54e013c168f4aae036e59912785f11b4aeebd57f6165a14e879b9a82c
2024-05-27 00:32:20 +02:00
faae889814ea6a292f7ca03d9b36e6c7e95bab2a64777804883cc822b8d48757
2024-08-31 08:09:32 +02:00
44f967aeb0c481676affe59069615252854bc0c072368ce4b26b6809a54daff5
1193910f475fde07f3cd4fe1c1a353d69b8cedb574967134838fcdc8208d224e"
2024-05-27 00:32:20 +02:00
skip_extraction="mipi-${_mipi_ver}.tar.gz
openssl-${_openssl_ver}.tar.gz
mbedtls-${_mbedtls_ver}.tar.gz
softfloat-${_softfloat_ver}.tar.gz
2024-08-31 08:09:32 +02:00
libspdm-${_spdm_ver}.tar.gz
libfdt-${_fdt_ver}.tar.gz"
2023-11-27 06:47:57 +01:00
case "$XBPS_TARGET_LIBC" in
2024-03-26 01:36:42 +01:00
glibc) _pfx="gnu" ;;
musl) _pfx="musl" ;;
2023-11-27 06:47:57 +01:00
esac
case "$XBPS_MACHINE" in
2024-03-26 01:36:42 +01:00
x86_64*|i686*) hostmakedepends+=" cross-aarch64-linux-${_pfx} cross-arm-linux-${_pfx}eabihf" ;;
esac
case "$XBPS_TARGET_MACHINE" in
2023-11-27 06:47:57 +01:00
x86_64*) _archs=(X64 IA32 AARCH64 ARM) ;;
i686*) _archs=(IA32 AARCH64 ARM) ;;
2024-03-26 01:36:42 +01:00
aarch64*) _archs=(AARCH64) ;;
2023-11-27 06:47:57 +01:00
esac
post_extract() {
2024-05-27 00:32:20 +02:00
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"
2024-08-31 08:09:32 +02:00
vsrcextract -C MdePkg/Library/BaseFdtLib/libfdt "libfdt-${_fdt_ver}.tar.gz"
2023-11-27 06:47:57 +01:00
}
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)
2024-03-26 01:36:42 +01:00
case "$XBPS_MACHINE" in
x86_64*|i686*)
export GCC5_AARCH64_PREFIX="aarch64-linux-${_pfx}-"
export GCC5_ARM_PREFIX="arm-linux-${_pfx}eabihf-"
;;
esac
2023-11-27 06:47:57 +01:00
2024-03-26 01:36:42 +01:00
for _arch in "${_archs[@]}"; do
CC=gcc CXX=g++ ARCH="${_arch}" make "${makejobs}" -C BaseTools
2023-11-27 06:47:57 +01:00
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
}
}