archrelease: copy trunk to extra-x86_64
[arch-packages.git] / edk2 / repos / extra-any / PKGBUILD
blob6b84da99b3ab6dff3e98024077b699bc2e612075
1 # Maintainer: David Runge <dvzrv@archlinux.org>
2 # Contributor: Alexander Epaneshnikov <alex19ep@archlinux.org>
4 _brotli_ver=1.0.9
5 _openssl_ver=1.1.1o
6 pkgbase=edk2
7 pkgname=(edk2-armvirt edk2-shell edk2-ovmf)
8 pkgver=202205
9 pkgrel=2
10 pkgdesc="Modern, feature-rich firmware development environment for the UEFI specifications"
11 arch=(any)
12 url="https://github.com/tianocore/edk2"
13 license=(BSD)
14 makedepends=(aarch64-linux-gnu-gcc acpica git iasl util-linux-libs nasm python seabios)
15 options=(!makeflags)
16 source=(
17   $pkgbase-$pkgver.tar.gz::https://github.com/tianocore/$pkgbase/archive/$pkgbase-stable$pkgver.tar.gz
18   https://www.openssl.org/source/openssl-$_openssl_ver.tar.gz{,.asc}
19   brotli-$_brotli_ver.tar.gz::https://github.com/google/brotli/archive/v$_brotli_ver.tar.gz
20   50-edk2-ovmf-i386-secure.json
21   50-edk2-ovmf-x86_64-secure.json
22   60-edk2-ovmf-i386.json
23   60-edk2-ovmf-x86_64.json
24   60-edk2-ovmf-microvm.json
25   60-edk2-armvirt-aarch64.json
26   70-edk2-ovmf-i386-csm.json
27   70-edk2-ovmf-x86_64-csm.json
28   80-edk2-ovmf-ia32-on-x86_64-secure.json
29   81-edk2-ovmf-ia32-on-x86_64.json
30   82-edk2-ovmf-ia32-on-x86_64-csm.json
31   $pkgbase-202202-brotli.patch
33 sha512sums=('0a0d0a8ad7cf23d77d9a6590ccf15e165224c1172e702e61efbf5056b7b62a78ac6dd3bcf2494871c852ee0e69d720db049fdd27e379c21cae64351ec9944428'
34             '75b2f1499cb4640229eb6cd35d85cbff2e19db17b959ac4d04b60f1b395b73567f9003521452a0fcfeea9b31b26de0a7bccf476ecf9caae02298f3647cfb7e23'
35             'SKIP'
36             'b8e2df955e8796ac1f022eb4ebad29532cb7e3aa6a4b6aee91dbd2c7d637eee84d9a144d3e878895bb5e62800875c2c01c8f737a1261020c54feacf9f676b5f5'
37             '603cae145a87bae371bd069d05128beebddb7048e78b93650b19c44b86b2d27cabbcf3bc4c0b2384b862f32383ce7a914a10fc0ad564632bcadd6e4f9389fede'
38             '3e10bdc9ad13aadbd4111230fb8f37d5f16306aeb7bce2af5ec31c1e2b5adea26d5875cd0d7070ea82eca7546ecbacc8c195ed68425428bf6d2533b58e307b2d'
39             '56d0bffd6dd7be79709f66bcfba2112e8ef6208de9b5018e90251e3ba68b37f9d911f0bd5a03987b49bb19bd0d62f7fa9ac3ca9f234e80ada3c4dbdd619705b9'
40             '04b4c86f5afeab6170ad1b7b9937fa775a920c78719a33b213f7f8924e4e905709335307c38b8d5d9c127dd8c7000ddbe740b77f1ddfb68035819b7b4cf2b1e4'
41             '31874507e67e1332f678f6f4b10b9f893cef6bafb1db2ac781ea7bfded31a23a84c485b6df43699aaf6c4c7a5a30e024031ffd2b52ede104eedc7c8725e2b5d6'
42             '6d2799171058b45ff4205441ad222893ebe2fce5c5c71c9c52c97efc95e4cad65d66d390b6a554ce7a2ce505ceba7431d18f79f2c2c1101addccee55141d4a66'
43             '4ee69302de1cec37e4bf4c6a5525d887392f8f733ae8a95a54021f6531741e95baef31da1538b45667a1b198cbbab3069678169069f9ba8db641d603ebb3735b'
44             '77e23f0c116ae5a087553edb2754df172b2c4fe5bc346356abe0e1f2acfb41a346d06d87b0569102ca4ac9356e189198c0c74476cb35f1b62773a956cb6a1e04'
45             '8e5eb4e24fad4644a66eb52c95a90a82f01df0af6e57208ad61cb0859dd4425e623e75d93846e8fc3235370a88d93a1d27a512dc4e559bedfe3249404797838b'
46             '7c9f8e7ce7451e7aa852998ffcd3ca95c08083c313dc8dcf0877969ef23d9da6f69c60bb1e652387a223da6e690524fa094bfbaed14d8bdae2853e68530b2f82'
47             '891d3ea36d966114ff1f79c3619675a46b30b68def16ab426f2dee00bd0768f82ca0ee26acd7adedd379f25613e309ec9dfaed4e8a5d3f3e4fa7e8d845f55b18'
48             'd074c794796d17d77eed7c34201d93d7ef3f1322fe1ea4a2ddd7137fae884d49f94f465ee39cfd8346b026142668a41f5a8671e521409505dd6d002f71c0eebc')
49 b2sums=('27e5d3436ce8c4f9dc406651940211009dff483cece51a939afee26e16ae1c083e0a4e22ffe9b2e67c8a269a9f6f6fe8be898705a1877b4a761b24e7c0ad9d5d'
50         '5bd355fd17adf43ba4e3bf1a8036ceb724edd4f4ab80dc25aecc3d2647372e9db2bc12e2b89791fc4b6f7fd95a7b68e00490d09ca6518d25ab990ee27798e641'
51         'SKIP'
52         '8b9939d5224396ef33b43e019250ba4bc8949903583615e8dc02c85340fc0a1e2d1632161e00b0ee7355d77f05529ac772f482e05d2089afd71a0bf71e803904'
53         'fa75566a2ac591fc0c296812f907bfe3fd67f2ee90d3762f0fcae6427df0dfd6260238f5af4fc6b74a76eccfc264db2259db70f8c533871e8b58f37b91a90657'
54         'f6aaccf4b5a070b05e8eb58d5df60c8798d9b9de2f9febf1417a1ae178431be9a69890a7107d3ca100a439551b4949b937ba400ac36bb9eebaf7e1fdb61dc9d3'
55         '891719a70d14f29f6ec9e9cfe83cbf48abb5aedfaf5a3a02efaf9cf1dcca0c14f42f8e4486425df12c72001d7811b0f6030520bad2d83b4885f13d110ab2ae0f'
56         '899ecf699815216984905a7abdd3385890c6309f3ef7813778bedf63c15d42ab12c59532d45033a11838f990744417100eb13048b53cee5cdf46440af61b475d'
57         '271322de65313b310a390ea9148640eb065c71b4edcab8aa675f8dbdfbbfa961950994d47213e22f05aa093895d180b840627a15d324252323986596f5c9f067'
58         'e61378139f2da0d4185e67436d87a023600a075b4258234e818fe7f591bdb5d363713d29d250263df6074f5d37deed269c067983ee6bd322f2f7d0ee710bc452'
59         '8c211a1bbef20ff361c53735b91cc05660f9d94e7d8a937d903c061a1ec9c96ec2c37f0ef5e954cd4aac7f7962489f5a7a0507e44c781a7671211a9530dccb5b'
60         '7f48bb1747c732c597a749c851a6cac46de844c1727f3d5edca35249df845a0f578780e8bcda7d86ad2c4a62a9a2a0bc7e1cfab9b7b93d7b5415bb5817d73346'
61         'ddacbab89d0fd7831149594487559bb6bac1464b2b5620641043306fabfc37800db8c6d87a833c70ec35c699ea2f35cf09d34028ec7982a94686e8cd97b73300'
62         '99bf35c4042fd5105a3b3b7f71b0aeb18db7811da4ed4481ffec485258619c30d33b08633f9a1c762d383e3bf0191053be9b88b9a4c142350186c6df1261d1f7'
63         'd45b224c36eda139ca6ad9e4c6c04282724b264dd36a0b3ba904d71476b83e02963c8cadf1f1e1233955071d133dc0defa746740fa08b26398c489fbf6ba89a0'
64         '644c071dc4fbbccaa64b0b1babcad60395ffce1a7a317a6f5380eff44cbb886be5f29156a8e967ab02b508a33954fcf5602606b43362cc3bb1936a8cfc3a3c07')
65 validpgpkeys=('8657ABB260F056B1E5190839D9C4D26D0E604491') # Matt Caswell <matt@openssl.org>
66 _arch_list=(AARCH64 IA32 X64)
67 _build_type=RELEASE
68 _build_plugin=GCC5
70 prepare() {
71   # patch to be able to use brotli 1.0.9
72   patch -Np1 -d $pkgbase-$pkgbase-stable$pkgver -i ../$pkgbase-202202-brotli.patch
74   cd $pkgbase-$pkgbase-stable$pkgver
76   # symlinking openssl into place
77   rm -rfv CryptoPkg/Library/OpensslLib/openssl
78   ln -sfv "${srcdir}/openssl-$_openssl_ver" CryptoPkg/Library/OpensslLib/openssl
80   # symlinking brotli into place
81   rm -rfv BaseTools/Source/C/BrotliCompress/brotli MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
82   ln -sfv "${srcdir}/brotli-${_brotli_ver}" BaseTools/Source/C/BrotliCompress/brotli
83   ln -sfv "${srcdir}/brotli-${_brotli_ver}" MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
85   # -Werror, not even once
86   sed -e 's/ -Werror//g' -i BaseTools/Conf/*.template BaseTools/Source/C/Makefiles/*.makefile
88   # copy seabios's CSM binary into place, so that it can be included in the binaries:
89   cp -v /usr/share/qemu/bios-csm.bin OvmfPkg/Csm/Csm16/Csm16.bin
92 # TODO: check TPM_ENABLE/TPM2_ENABLE
93 build() {
94   local _arch
95   # shared targets for all
96   local _common_args=(
97     -b "$_build_type"
98     -n "$(nproc)"
99     -t "$_build_plugin"
100   )
101   # shared targets for all EFI binaries
102   local _efi_args=(
103     -D NETWORK_IP6_ENABLE
104     -D TPM_CONFIG_ENABLE
105     -D TPM1_ENABLE
106     -D TPM2_ENABLE
107   )
108   # shared targets x86_64 and i686
109   local _x86_args=(
110     -D FD_SIZE_2MB
111     -D HTTP_BOOT_ENABLE
112     -D TLS_ENABLE
113   )
115   cd $pkgbase-$pkgbase-stable$pkgver
116   export GCC5_IA32_PREFIX="x86_64-linux-gnu-"
117   export GCC5_X64_PREFIX="x86_64-linux-gnu-"
118   export GCC5_AARCH64_PREFIX="aarch64-linux-gnu-"
119   echo "Building base tools (AARCH64)"
120   ARCH=AARCH64 make -C BaseTools
121   echo "Building base tools"
122   make -C BaseTools
123   . edksetup.sh
125   for _arch in ${_arch_list[@]}; do
126     # shell
127     echo "Building shell ($_arch)."
128     BaseTools/BinWrappers/PosixLike/build -p ShellPkg/ShellPkg.dsc -a "$_arch" "${_common_args[@]}"
129     # ovmf
130     if [[ "$_arch" == IA32 ]]; then
131       echo "Building ovmf ($_arch) with secure boot support"
132       OvmfPkg/build.sh -p OvmfPkg/OvmfPkgIa32.dsc \
133                        -a "$_arch" \
134                        "${_common_args[@]}" \
135                        "${_efi_args[@]}" \
136                        "${_x86_args[@]}" \
137                        -D EXCLUDE_SHELL_FROM_FD \
138                        -D LOAD_X64_ON_IA32_ENABLE \
139                        -D SECURE_BOOT_ENABLE \
140                        -D SMM_REQUIRE
141       mv -v Build/Ovmf{Ia32,IA32-secure}
142       echo "Building ovmf ($_arch) with CSM support"
143       OvmfPkg/build.sh -p OvmfPkg/OvmfPkgIa32.dsc \
144                        -a "${_arch}" \
145                        "${_common_args[@]}" \
146                        "${_efi_args[@]}" \
147                        "${_x86_args[@]}" \
148                        -D CSM_ENABLE \
149                        -D LOAD_X64_ON_IA32_ENABLE
150       mv -v Build/Ovmf{Ia32,IA32-csm}
151       echo "Building ovmf ($_arch) default"
152       OvmfPkg/build.sh -p OvmfPkg/OvmfPkgIa32.dsc \
153                        -a "$_arch" \
154                        "${_common_args[@]}" \
155                        "${_efi_args[@]}" \
156                        "${_x86_args[@]}" \
157                        -D LOAD_X64_ON_IA32_ENABLE
158       mv -v Build/Ovmf{Ia32,IA32}
159     fi
160     if [[ "$_arch" == X64 ]]; then
161       echo "Building ovmf ($_arch) with microvm support"
162       OvmfPkg/build.sh -p OvmfPkg/Microvm/Microvm$_arch.dsc \
163                        -a "$_arch" \
164                        "${_common_args[@]}" \
165                        "${_efi_args[@]}" \
166                        "${_x86_args[@]}"
167       echo "Building ovmf ($_arch) with secure boot support"
168       OvmfPkg/build.sh -p OvmfPkg/OvmfPkgIa32X64.dsc \
169                        -a IA32 -a "$_arch" \
170                        "${_common_args[@]}" \
171                        "${_efi_args[@]}" \
172                        "${_x86_args[@]}" \
173                        -D SECURE_BOOT_ENABLE \
174                        -D SMM_REQUIRE \
175                        -D EXCLUDE_SHELL_FROM_FD
176       mv -v Build/Ovmf3264{,-secure}
177       echo "Building ovmf ($_arch) with CSM support"
178       OvmfPkg/build.sh -p OvmfPkg/OvmfPkg$_arch.dsc \
179                        -a "${_arch}" \
180                        "${_common_args[@]}" \
181                        "${_efi_args[@]}" \
182                        "${_x86_args[@]}" \
183                        -D CSM_ENABLE
184       mv -v Build/OvmfX64{,-csm}
185       echo "Building ovmf (${_arch}) without secure boot"
186       OvmfPkg/build.sh -p OvmfPkg/OvmfPkg$_arch.dsc \
187                        -a "$_arch" \
188                        "${_common_args[@]}" \
189                        "${_efi_args[@]}" \
190                        "${_x86_args[@]}"
191     fi
192     if [[ "$_arch" == AARCH64 ]]; then
193       echo "Building ArmVirtPkg ($_arch) with secure boot"
194       BaseTools/BinWrappers/PosixLike/build -p ArmVirtPkg/ArmVirtQemu.dsc \
195                                             -a "$_arch" \
196                                             "${_common_args[@]}" \
197                                             "${_efi_args[@]}" \
198                                             -D NETWORK_HTTP_BOOT_ENABLE \
199                                             -D NETWORK_TLS_ENABLE \
200                                             -D SECURE_BOOT_ENABLE
201       dd if=/dev/zero of=Build/ArmVirtQemu-$_arch/${_build_type}_${_build_plugin}/FV/QEMU_CODE.fd bs=1M count=64
202       dd if=Build/ArmVirtQemu-$_arch/${_build_type}_${_build_plugin}/FV/QEMU_EFI.fd of=Build/ArmVirtQemu-$_arch/${_build_type}_${_build_plugin}/FV/QEMU_CODE.fd conv=notrunc
203       dd if=/dev/zero of=Build/ArmVirtQemu-$_arch/${_build_type}_${_build_plugin}/FV/QEMU_VARS.fd bs=1M count=64
204     fi
205   done
208 package_edk2-armvirt() {
209   local _arch=AARCH64
211   pkgdesc="Firmware for Virtual Machines (aarch64)"
212   url="https://github.com/tianocore/tianocore.github.io/wiki/ArmVirtPkg"
214   cd $pkgbase-$pkgbase-stable$pkgver
215   install -vDm 644 Build/ArmVirtQemu-$_arch/${_build_type}_${_build_plugin}/FV/*.fd -t "$pkgdir/usr/share/$pkgname/${_arch,,}/"
216   # add libvirt compatibility (which hardcodes the following paths)
217   install -vdm 755 "$pkgdir/usr/share/AAVMF"
218   ln -svf /usr/share/$pkgname/${_arch,,}/QEMU_CODE.fd "$pkgdir/usr/share/AAVMF/AAVMF_CODE.fd"
219   ln -svf /usr/share/$pkgname/${_arch,,}/QEMU_VARS.fd "$pkgdir/usr/share/AAVMF/AAVMF_VARS.fd"
220   # install qemu descriptors in accordance with qemu:
221   # https://git.qemu.org/?p=qemu.git;a=tree;f=pc-bios/descriptors
222   install -vDm 644 ../*$pkgname*.json -t "$pkgdir/usr/share/qemu/firmware/"
223   # license
224   install -vDm 644 License.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
227 package_edk2-shell() {
228   local _arch
229   # minimal UEFI shell, as defined in ShellPkg/Application/Shell/ShellPkg.inf
230   local _min='7C04A583-9E3E-4f1c-AD65-E05268D0B4D1'
231   # full UEFI shell, as defined in ShellPkg/ShellPkg.dsc
232   local _full='EA4BB293-2D7F-4456-A681-1F22F42CD0BC'
234   pkgdesc="EDK2 UEFI Shell"
235   provides=(uefi-shell)
237   cd $pkgbase-$pkgbase-stable$pkgver
238   for _arch in ${_arch_list[@]}; do
239     if [[ "${_arch}" == 'AARCH64' ]]; then
240       install -vDm 644 Build/ArmVirtQemu-$_arch/${_build_type}_${_build_plugin}/$_arch/Shell.efi -t "$pkgdir/usr/share/$pkgname/${_arch,,}/"
241     else
242       install -vDm 644 Build/Shell/${_build_type}_${_build_plugin}/$_arch/Shell_$_min.efi "$pkgdir/usr/share/$pkgname/${_arch,,}/Shell.efi"
243       install -vDm 644 Build/Shell/${_build_type}_${_build_plugin}/$_arch/Shell_$_full.efi "$pkgdir/usr/share/$pkgname/${_arch,,}/Shell_Full.efi"
244     fi
245   done
246   # license
247   install -vDm 644 License.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
248   # docs
249   install -vDm 644 {ReadMe.rst,Maintainers.txt} -t "$pkgdir/usr/share/doc/$pkgname/"
252 package_edk2-ovmf() {
253   local _arch
255   pkgdesc="Firmware for Virtual Machines (x86_64, i686)"
256   url="https://github.com/tianocore/tianocore.github.io/wiki/OVMF"
257   license+=(MIT)
258   provides=(ovmf)
259   conflicts=(ovmf)
260   replaces=(ovmf)
261   install=$pkgname.install
263   cd $pkgbase-$pkgbase-stable$pkgver
264   # installing the various firmwares
265   for _arch in ${_arch_list[@]}; do
266     if [[ "$_arch" == AARCH64 ]]; then
267       continue
268     else
269       # installing OVMF.fd for xen: https://bugs.archlinux.org/task/58635
270       install -vDm 644 Build/Ovmf$_arch/${_build_type}_${_build_plugin}/FV/OVMF.fd -t "$pkgdir/usr/share/$pkgname/${_arch,,}/"
271       install -vDm 644 Build/Ovmf$_arch/${_build_type}_${_build_plugin}/FV/OVMF_CODE.fd -t "$pkgdir/usr/share/$pkgname/${_arch,,}/"
272       install -vDm 644 Build/Ovmf$_arch/${_build_type}_${_build_plugin}/FV/OVMF_VARS.fd -t "$pkgdir/usr/share/$pkgname/${_arch,,}/"
273       install -vDm 644 Build/Ovmf$_arch-csm/${_build_type}_${_build_plugin}/FV/OVMF_CODE.fd "$pkgdir/usr/share/$pkgname/${_arch,,}/OVMF_CODE.csm.fd"
274       if [[ "${_arch}" == 'X64' ]]; then
275         install -vDm 644 Build/Ovmf3264-secure/${_build_type}_${_build_plugin}/FV/OVMF_CODE.fd "$pkgdir/usr/share/$pkgname/${_arch,,}/OVMF_CODE.secboot.fd"
276         install -vDm 644 Build/MicrovmX64/${_build_type}_${_build_plugin}/FV/MICROVM.fd -t "$pkgdir/usr/share/$pkgname/${_arch,,}/"
277       else
278         install -vDm 644 Build/Ovmf$_arch-secure/${_build_type}_${_build_plugin}/FV/OVMF_CODE.fd "$pkgdir/usr/share/$pkgname/${_arch,,}/OVMF_CODE.secboot.fd"
279       fi
280     fi
281   done
282   # installing qemu descriptors in accordance with qemu:
283   # https://git.qemu.org/?p=qemu.git;a=tree;f=pc-bios/descriptors
284   # https://bugs.archlinux.org/task/64206
285   install -vDm 644 ../*$pkgname*.json -t "$pkgdir/usr/share/qemu/firmware/"
286   # adding symlink for previous ovmf location
287   # https://bugs.archlinux.org/task/66528
288   ln -svf /usr/share/$pkgname "$pkgdir/usr/share/ovmf"
289   # adding a symlink for applications with questionable heuristics (such as lxd)
290   ln -svf /usr/share/$pkgname "$pkgdir/usr/share/OVMF"
291   # licenses
292   install -vDm 644 License.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
293   install -vDm 644 OvmfPkg/License.txt "$pkgdir/usr/share/licenses/$pkgname/OvmfPkg.License.txt"
294   # docs
295   install -vDm 644 {OvmfPkg/README,ReadMe.rst,Maintainers.txt} -t "$pkgdir/usr/share/doc/$pkgname/"