gnu: ovmf: Use gexps.
* gnu/packages/firmware.scm (edk2-commit, edk2-version) (edk2-origin): Delete variables. (ovmf)[source]: Define here; it's the only user of it so far. [native-inputs]: Move below arguments. [phases]: Use gexps. Delete trailing #t. {patch-source}: New phase. {configure}: Use 'invoke' to execute the 'edksetup.sh' script; delete associated FIXME comment. (ovmf-aarch64, ovmf-arm): Adjust accordingly.
parent
c8803d89fe
commit
1589debbd9
|
@ -8,6 +8,7 @@
|
||||||
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
|
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
|
||||||
;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
|
;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
|
||||||
;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
|
;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
|
||||||
|
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -366,131 +367,125 @@ coreboot.")
|
||||||
;; cpl with a linking exception.
|
;; cpl with a linking exception.
|
||||||
license:cpl1.0))))
|
license:cpl1.0))))
|
||||||
|
|
||||||
;; OVMF is part of the edk2 source tree.
|
|
||||||
(define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
|
|
||||||
(define edk2-version (git-version "20170116" "1" edk2-commit))
|
|
||||||
(define edk2-origin
|
|
||||||
(origin
|
|
||||||
(method git-fetch)
|
|
||||||
(uri (git-reference
|
|
||||||
(url "https://github.com/tianocore/edk2")
|
|
||||||
(commit edk2-commit)))
|
|
||||||
(file-name (git-file-name "edk2" edk2-version))
|
|
||||||
(sha256
|
|
||||||
(base32
|
|
||||||
"1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
|
|
||||||
|
|
||||||
(define-public ovmf
|
(define-public ovmf
|
||||||
(package
|
(let ((commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
|
||||||
(name "ovmf")
|
(revision "1"))
|
||||||
(version edk2-version)
|
(package
|
||||||
(source edk2-origin)
|
(name "ovmf")
|
||||||
(build-system gnu-build-system)
|
(version (git-version "20170116" revision commit))
|
||||||
(native-inputs
|
(source (origin
|
||||||
`(("acpica" ,acpica)
|
(method git-fetch)
|
||||||
("gcc@5" ,gcc-5)
|
(uri (git-reference
|
||||||
("nasm" ,nasm)
|
;; OVMF is part of the edk2 source tree.
|
||||||
("python-2" ,python-2)
|
(url "https://github.com/tianocore/edk2")
|
||||||
("util-linux" ,util-linux "lib")))
|
(commit commit)))
|
||||||
(arguments
|
(file-name (git-file-name name version))
|
||||||
`(#:tests? #f ; No check target.
|
(sha256
|
||||||
#:phases
|
(base32
|
||||||
(modify-phases %standard-phases
|
"1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
|
||||||
;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent it from
|
(build-system gnu-build-system)
|
||||||
;; shadowing the version of GCC provided in native-inputs.
|
(arguments
|
||||||
(add-after 'set-paths 'hide-gcc7
|
(list
|
||||||
(lambda* (#:key inputs #:allow-other-keys)
|
#:tests? #f ; No check target.
|
||||||
(let ((gcc (assoc-ref inputs "gcc")))
|
#:phases
|
||||||
(setenv "CPLUS_INCLUDE_PATH"
|
#~(modify-phases %standard-phases
|
||||||
(string-join
|
;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent it from
|
||||||
(delete (string-append gcc "/include/c++")
|
;; shadowing the version of GCC provided in native-inputs.
|
||||||
(string-split (getenv "CPLUS_INCLUDE_PATH")
|
(add-after 'set-paths 'hide-implicit-gcc
|
||||||
#\:))
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
":"))
|
(let ((gcc (assoc-ref inputs "gcc")))
|
||||||
#t)))
|
(setenv "CPLUS_INCLUDE_PATH"
|
||||||
(replace 'configure
|
(string-join
|
||||||
(lambda _
|
(delete (string-append gcc "/include/c++")
|
||||||
(let* ((cwd (getcwd))
|
(string-split (getenv "CPLUS_INCLUDE_PATH")
|
||||||
(tools (string-append cwd "/BaseTools"))
|
#\:))
|
||||||
(bin (string-append tools "/BinWrappers/PosixLike")))
|
":")))))
|
||||||
(setenv "WORKSPACE" cwd)
|
(add-after 'unpack 'patch-source
|
||||||
(setenv "EDK_TOOLS_PATH" tools)
|
(lambda _
|
||||||
(setenv "PATH" (string-append (getenv "PATH") ":" bin))
|
(substitute* "edksetup.sh"
|
||||||
; FIXME: The below script errors out. When using 'invoke' instead
|
(("^return \\$\\?")
|
||||||
; of 'system*' this causes the build to fail.
|
"exit $?"))))
|
||||||
(system* "bash" "edksetup.sh")
|
(replace 'configure
|
||||||
(substitute* "Conf/target.txt"
|
(lambda _
|
||||||
(("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
|
(let* ((cwd (getcwd))
|
||||||
(("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
|
(tools (string-append cwd "/BaseTools"))
|
||||||
(format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
|
(bin (string-append tools "/BinWrappers/PosixLike")))
|
||||||
(number->string (parallel-job-count)))))
|
(setenv "WORKSPACE" cwd)
|
||||||
;; Build build support.
|
(setenv "EDK_TOOLS_PATH" tools)
|
||||||
(setenv "BUILD_CC" "gcc")
|
(setenv "PATH" (string-append (getenv "PATH") ":" bin))
|
||||||
(invoke "make" "-C" tools)
|
(invoke "bash" "edksetup.sh")
|
||||||
#t)))
|
(substitute* "Conf/target.txt"
|
||||||
(replace 'build
|
(("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
|
||||||
(lambda _
|
(("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
|
||||||
(invoke "build" "-a" "IA32" "-t" "GCC49"
|
(format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
|
||||||
"-p" "OvmfPkg/OvmfPkgIa32.dsc")))
|
(number->string (parallel-job-count)))))
|
||||||
,@(if (string=? "x86_64-linux" (%current-system))
|
;; Build build support.
|
||||||
'((add-after 'build 'build-x64
|
(setenv "BUILD_CC" "gcc")
|
||||||
(lambda _
|
(invoke "make" "-C" tools))))
|
||||||
(invoke "build" "-a" "X64" "-t" "GCC49"
|
(replace 'build
|
||||||
"-p" "OvmfPkg/OvmfPkgX64.dsc"))))
|
(lambda _
|
||||||
'())
|
(invoke "build" "-a" "IA32" "-t" "GCC49"
|
||||||
(replace 'install
|
"-p" "OvmfPkg/OvmfPkgIa32.dsc")))
|
||||||
(lambda* (#:key outputs #:allow-other-keys)
|
#$@(if (string=? "x86_64-linux" (%current-system))
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
#~((add-after 'build 'build-x64
|
||||||
(fmw (string-append out "/share/firmware")))
|
(lambda _
|
||||||
(mkdir-p fmw)
|
(invoke "build" "-a" "X64" "-t" "GCC49"
|
||||||
(copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
|
"-p" "OvmfPkg/OvmfPkgX64.dsc"))))
|
||||||
(string-append fmw "/ovmf_ia32.bin"))
|
#~())
|
||||||
,@(if (string=? "x86_64-linux" (%current-system))
|
(replace 'install
|
||||||
'((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
|
(lambda _
|
||||||
(string-append fmw "/ovmf_x64.bin")))
|
(let ((fmw (string-append #$output "/share/firmware")))
|
||||||
'()))
|
(mkdir-p fmw)
|
||||||
#t)))))
|
(copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
|
||||||
(supported-systems '("x86_64-linux" "i686-linux"))
|
(string-append fmw "/ovmf_ia32.bin"))
|
||||||
(home-page "https://www.tianocore.org")
|
#$@(if (string=? "x86_64-linux" (%current-system))
|
||||||
(synopsis "UEFI firmware for QEMU")
|
'((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
|
||||||
(description "OVMF is an EDK II based project to enable UEFI support for
|
(string-append fmw "/ovmf_x64.bin")))
|
||||||
|
'())))))))
|
||||||
|
(native-inputs
|
||||||
|
`(("acpica" ,acpica)
|
||||||
|
("gcc@5" ,gcc-5)
|
||||||
|
("nasm" ,nasm)
|
||||||
|
("python-2" ,python-2)
|
||||||
|
("util-linux" ,util-linux "lib")))
|
||||||
|
(supported-systems '("x86_64-linux" "i686-linux"))
|
||||||
|
(home-page "https://www.tianocore.org")
|
||||||
|
(synopsis "UEFI firmware for QEMU")
|
||||||
|
(description "OVMF is an EDK II based project to enable UEFI support for
|
||||||
Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
|
Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
|
||||||
(license (list license:expat
|
(license (list license:expat
|
||||||
license:bsd-2 license:bsd-3 license:bsd-4))))
|
license:bsd-2 license:bsd-3 license:bsd-4)))))
|
||||||
|
|
||||||
(define-public ovmf-aarch64
|
(define-public ovmf-aarch64
|
||||||
(package
|
(package
|
||||||
(inherit ovmf)
|
(inherit ovmf)
|
||||||
(name "ovmf-aarch64")
|
(name "ovmf-aarch64")
|
||||||
(native-inputs
|
(native-inputs
|
||||||
`(,@(package-native-inputs ovmf)
|
(append (package-native-inputs ovmf)
|
||||||
,@(if (not (string-prefix? "aarch64" (%current-system)))
|
(if (not (string-prefix? "aarch64" (%current-system)))
|
||||||
`(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu"))
|
`(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu"))
|
||||||
("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
|
("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
|
||||||
'())))
|
'())))
|
||||||
(arguments
|
(arguments
|
||||||
(substitute-keyword-arguments (package-arguments ovmf)
|
(substitute-keyword-arguments (package-arguments ovmf)
|
||||||
((#:phases phases)
|
((#:phases phases)
|
||||||
`(modify-phases ,phases
|
#~(modify-phases #$phases
|
||||||
(add-before 'configure 'set-env
|
(add-before 'configure 'set-env
|
||||||
(lambda _
|
(lambda _
|
||||||
,@(if (not (string-prefix? "aarch64" (%current-system)))
|
#$@(if (not (string-prefix? "aarch64" (%current-system)))
|
||||||
`((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-"))
|
#~((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-"))
|
||||||
'())
|
#~())))
|
||||||
#t))
|
(replace 'build
|
||||||
(replace 'build
|
(lambda _
|
||||||
(lambda _
|
(invoke "build" "-a" "AARCH64" "-t" "GCC49"
|
||||||
(invoke "build" "-a" "AARCH64" "-t" "GCC49"
|
"-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
|
||||||
"-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
|
(delete 'build-x64)
|
||||||
(delete 'build-x64)
|
(replace 'install
|
||||||
(replace 'install
|
(lambda _
|
||||||
(lambda* (#:key outputs #:allow-other-keys)
|
(let ((fmw (string-append #$output "/share/firmware")))
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(mkdir-p fmw)
|
||||||
(fmw (string-append out "/share/firmware")))
|
(copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
|
||||||
(mkdir-p fmw)
|
(string-append fmw "/ovmf_aarch64.bin")))))))))
|
||||||
(copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
|
|
||||||
(string-append fmw "/ovmf_aarch64.bin"))
|
|
||||||
#t)))))))
|
|
||||||
(supported-systems %supported-systems)))
|
(supported-systems %supported-systems)))
|
||||||
|
|
||||||
(define-public ovmf-arm
|
(define-public ovmf-arm
|
||||||
|
@ -498,34 +493,31 @@ Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
|
||||||
(inherit ovmf)
|
(inherit ovmf)
|
||||||
(name "ovmf-arm")
|
(name "ovmf-arm")
|
||||||
(native-inputs
|
(native-inputs
|
||||||
`(,@(package-native-inputs ovmf)
|
(append (package-native-inputs ovmf)
|
||||||
,@(if (not (string-prefix? "armhf" (%current-system)))
|
(if (not (string-prefix? "armhf" (%current-system)))
|
||||||
`(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))
|
`(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))
|
||||||
("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
|
("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
|
||||||
'())))
|
'())))
|
||||||
(arguments
|
(arguments
|
||||||
(substitute-keyword-arguments (package-arguments ovmf)
|
(substitute-keyword-arguments (package-arguments ovmf)
|
||||||
((#:phases phases)
|
((#:phases phases)
|
||||||
`(modify-phases ,phases
|
#~(modify-phases #$phases
|
||||||
(add-before 'configure 'set-env
|
(add-before 'configure 'set-env
|
||||||
(lambda _
|
(lambda _
|
||||||
,@(if (not (string-prefix? "armhf" (%current-system)))
|
#$@(if (not (string-prefix? "armhf" (%current-system)))
|
||||||
`((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-"))
|
#~((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-"))
|
||||||
'())
|
#~())))
|
||||||
#t))
|
(replace 'build
|
||||||
(replace 'build
|
(lambda _
|
||||||
(lambda _
|
(invoke "build" "-a" "ARM" "-t" "GCC49"
|
||||||
(invoke "build" "-a" "ARM" "-t" "GCC49"
|
"-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
|
||||||
"-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
|
(delete 'build-x64)
|
||||||
(delete 'build-x64)
|
(replace 'install
|
||||||
(replace 'install
|
(lambda _
|
||||||
(lambda* (#:key outputs #:allow-other-keys)
|
(let ((fmw (string-append #$output "/share/firmware")))
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(mkdir-p fmw)
|
||||||
(fmw (string-append out "/share/firmware")))
|
(copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
|
||||||
(mkdir-p fmw)
|
(string-append fmw "/ovmf_arm.bin")))))))))
|
||||||
(copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
|
|
||||||
(string-append fmw "/ovmf_arm.bin"))
|
|
||||||
#t)))))))
|
|
||||||
(supported-systems %supported-systems)))
|
(supported-systems %supported-systems)))
|
||||||
|
|
||||||
(define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
|
(define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
|
||||||
|
|
Reference in New Issue