Merge pull request #269877 from RaitoBezarius/ovmf-darwin

This commit is contained in:
Ryan Lahfa 2023-11-26 02:32:06 +01:00 committed by GitHub
commit 6dd2f029a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 9 deletions

View file

@ -7,7 +7,9 @@
, tpmSupport ? false , tpmSupport ? false
, tlsSupport ? false , tlsSupport ? false
, debug ? false , debug ? false
, sourceDebug ? debug # Usually, this option is broken, do not use it except if you know what you are
# doing.
, sourceDebug ? false
}: }:
assert csmSupport -> seabios != null; assert csmSupport -> seabios != null;
@ -20,6 +22,8 @@ let
"OvmfPkg/OvmfPkgX64.dsc" "OvmfPkg/OvmfPkgX64.dsc"
else if stdenv.hostPlatform.isAarch then else if stdenv.hostPlatform.isAarch then
"ArmVirtPkg/ArmVirtQemu.dsc" "ArmVirtPkg/ArmVirtQemu.dsc"
else if stdenv.hostPlatform.isRiscV then
"OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc"
else else
throw "Unsupported architecture"; throw "Unsupported architecture";
@ -67,7 +71,8 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
cp ${seabios}/Csm16.bin OvmfPkg/Csm/Csm16/Csm16.bin cp ${seabios}/Csm16.bin OvmfPkg/Csm/Csm16/Csm16.bin
''; '';
postFixup = if stdenv.hostPlatform.isAarch then '' postFixup = (
if stdenv.hostPlatform.isAarch then ''
mkdir -vp $fd/FV mkdir -vp $fd/FV
mkdir -vp $fd/AAVMF mkdir -vp $fd/AAVMF
mv -v $out/FV/QEMU_{EFI,VARS}.fd $fd/FV mv -v $out/FV/QEMU_{EFI,VARS}.fd $fd/FV
@ -80,10 +85,18 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
# Also add symlinks for Fedora dir layout: https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/edk2.spec # Also add symlinks for Fedora dir layout: https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/edk2.spec
ln -s $fd/FV/AAVMF_CODE.fd $fd/AAVMF/QEMU_EFI-pflash.raw ln -s $fd/FV/AAVMF_CODE.fd $fd/AAVMF/QEMU_EFI-pflash.raw
ln -s $fd/FV/AAVMF_VARS.fd $fd/AAVMF/vars-template-pflash.raw ln -s $fd/FV/AAVMF_VARS.fd $fd/AAVMF/vars-template-pflash.raw
'' else '' ''
else if stdenv.hostPlatform.isRiscV then ''
mkdir -vp $fd/FV
mv -v $out/FV/RISCV_VIRT_{CODE,VARS}.fd $fd/FV/
truncate -s 32M $fd/FV/RISCV_VIRT_CODE.fd
truncate -s 32M $fd/FV/RISCV_VIRT_VARS.fd
''
else ''
mkdir -vp $fd/FV mkdir -vp $fd/FV
mv -v $out/FV/OVMF{,_CODE,_VARS}.fd $fd/FV mv -v $out/FV/OVMF{,_CODE,_VARS}.fd $fd/FV
''; '');
dontPatchELF = true; dontPatchELF = true;
@ -105,5 +118,6 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
license = lib.licenses.bsd2; license = lib.licenses.bsd2;
inherit (edk2.meta) platforms; inherit (edk2.meta) platforms;
maintainers = with lib.maintainers; [ adamcstephens raitobezarius ]; maintainers = with lib.maintainers; [ adamcstephens raitobezarius ];
broken = stdenv.isDarwin;
}; };
}) })

View file

@ -21,6 +21,8 @@ else if stdenv.isAarch32 then
"ARM" "ARM"
else if stdenv.isAarch64 then else if stdenv.isAarch64 then
"AARCH64" "AARCH64"
else if stdenv.hostPlatform.isRiscV64 then
"RISCV64"
else else
throw "Unsupported architecture"; throw "Unsupported architecture";
@ -31,7 +33,7 @@ buildType = if stdenv.isDarwin then
edk2 = stdenv.mkDerivation rec { edk2 = stdenv.mkDerivation rec {
pname = "edk2"; pname = "edk2";
version = "202308"; version = "202311";
patches = [ patches = [
# pass targetPrefix as an env var # pass targetPrefix as an env var
@ -46,7 +48,7 @@ edk2 = stdenv.mkDerivation rec {
repo = "edk2"; repo = "edk2";
rev = "edk2-stable${edk2.version}"; rev = "edk2-stable${edk2.version}";
fetchSubmodules = true; fetchSubmodules = true;
hash = "sha256-Eoi1xf/hw/Knr7n0f0rgVof7wTgrHkmvV4eJjJV1NhM="; hash = "sha256-gC/If8U9qo70rGvNl3ld/mmZszwY0w/5Ge/K21mhzYw=";
}; };
# We don't want EDK2 to keep track of OpenSSL, # We don't want EDK2 to keep track of OpenSSL,
@ -60,11 +62,12 @@ edk2 = stdenv.mkDerivation rec {
''; '';
nativeBuildInputs = [ pythonEnv ]; nativeBuildInputs = [ pythonEnv ];
depsBuildBuild = [ buildPackages.stdenv.cc buildPackages.util-linux buildPackages.bash ]; depsBuildBuild = [ buildPackages.stdenv.cc buildPackages.bash ];
depsHostHost = [ libuuid ];
strictDeps = true; strictDeps = true;
# trick taken from https://src.fedoraproject.org/rpms/edk2/blob/08f2354cd280b4ce5a7888aa85cf520e042955c3/f/edk2.spec#_319 # trick taken from https://src.fedoraproject.org/rpms/edk2/blob/08f2354cd280b4ce5a7888aa85cf520e042955c3/f/edk2.spec#_319
${"GCC5_${targetArch}_PREFIX"}=stdenv.cc.targetPrefix; ${"GCC5_${targetArch}_PREFIX"} = stdenv.cc.targetPrefix;
makeFlags = [ "-C BaseTools" ]; makeFlags = [ "-C BaseTools" ];
@ -91,7 +94,7 @@ edk2 = stdenv.mkDerivation rec {
description = "Intel EFI development kit"; description = "Intel EFI development kit";
homepage = "https://github.com/tianocore/tianocore.github.io/wiki/EDK-II/"; homepage = "https://github.com/tianocore/tianocore.github.io/wiki/EDK-II/";
license = licenses.bsd2; license = licenses.bsd2;
platforms = with platforms; aarch64 ++ arm ++ i686 ++ x86_64; platforms = with platforms; aarch64 ++ arm ++ i686 ++ x86_64 ++ riscv64;
}; };
passthru = { passthru = {