summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-06-15 21:58:34 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-06-16 21:52:49 -0400
commit1589debbd9f28e8af5b34cc41343a00ddfc88a7d (patch)
tree2243d38e1e7a4f19f4f2d6c25d162912dd00c910 /gnu
parentc8803d89fe531a1ff0de8ccdbc77c86249d5e778 (diff)
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.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/firmware.scm270
1 files changed, 131 insertions, 139 deletions
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index b63ad63749c..291696b5c84 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -8,6 +8,7 @@
8;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com> 8;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
9;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org> 9;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
10;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com> 10;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
11;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
11;;; 12;;;
12;;; This file is part of GNU Guix. 13;;; This file is part of GNU Guix.
13;;; 14;;;
@@ -366,131 +367,125 @@ coreboot.")
366 ;; cpl with a linking exception. 367 ;; cpl with a linking exception.
367 license:cpl1.0)))) 368 license:cpl1.0))))
368 369
369;; OVMF is part of the edk2 source tree.
370(define edk2-commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
371(define edk2-version (git-version "20170116" "1" edk2-commit))
372(define edk2-origin
373 (origin
374 (method git-fetch)
375 (uri (git-reference
376 (url "https://github.com/tianocore/edk2")
377 (commit edk2-commit)))
378 (file-name (git-file-name "edk2" edk2-version))
379 (sha256
380 (base32
381 "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
382
383(define-public ovmf 370(define-public ovmf
384 (package 371 (let ((commit "13a50a6fe1dcfa6600c38456ee24e0f9ecf51b5f")
385 (name "ovmf") 372 (revision "1"))
386 (version edk2-version) 373 (package
387 (source edk2-origin) 374 (name "ovmf")
388 (build-system gnu-build-system) 375 (version (git-version "20170116" revision commit))
389 (native-inputs 376 (source (origin
390 `(("acpica" ,acpica) 377 (method git-fetch)
391 ("gcc@5" ,gcc-5) 378 (uri (git-reference
392 ("nasm" ,nasm) 379 ;; OVMF is part of the edk2 source tree.
393 ("python-2" ,python-2) 380 (url "https://github.com/tianocore/edk2")
394 ("util-linux" ,util-linux "lib"))) 381 (commit commit)))
395 (arguments 382 (file-name (git-file-name name version))
396 `(#:tests? #f ; No check target. 383 (sha256
397 #:phases 384 (base32
398 (modify-phases %standard-phases 385 "1gy2332kdqk8bjzpcsripx10896rbvgl0ic7r344kmpiwdgm948b"))))
399 ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent it from 386 (build-system gnu-build-system)
400 ;; shadowing the version of GCC provided in native-inputs. 387 (arguments
401 (add-after 'set-paths 'hide-gcc7 388 (list
402 (lambda* (#:key inputs #:allow-other-keys) 389 #:tests? #f ; No check target.
403 (let ((gcc (assoc-ref inputs "gcc"))) 390 #:phases
404 (setenv "CPLUS_INCLUDE_PATH" 391 #~(modify-phases %standard-phases
405 (string-join 392 ;; Hide the default GCC from CPLUS_INCLUDE_PATH to prevent it from
406 (delete (string-append gcc "/include/c++") 393 ;; shadowing the version of GCC provided in native-inputs.
407 (string-split (getenv "CPLUS_INCLUDE_PATH") 394 (add-after 'set-paths 'hide-implicit-gcc
408 #\:)) 395 (lambda* (#:key inputs #:allow-other-keys)
409 ":")) 396 (let ((gcc (assoc-ref inputs "gcc")))
410 #t))) 397 (setenv "CPLUS_INCLUDE_PATH"
411 (replace 'configure 398 (string-join
412 (lambda _ 399 (delete (string-append gcc "/include/c++")
413 (let* ((cwd (getcwd)) 400 (string-split (getenv "CPLUS_INCLUDE_PATH")
414 (tools (string-append cwd "/BaseTools")) 401 #\:))
415 (bin (string-append tools "/BinWrappers/PosixLike"))) 402 ":")))))
416 (setenv "WORKSPACE" cwd) 403 (add-after 'unpack 'patch-source
417 (setenv "EDK_TOOLS_PATH" tools) 404 (lambda _
418 (setenv "PATH" (string-append (getenv "PATH") ":" bin)) 405 (substitute* "edksetup.sh"
419 ; FIXME: The below script errors out. When using 'invoke' instead 406 (("^return \\$\\?")
420 ; of 'system*' this causes the build to fail. 407 "exit $?"))))
421 (system* "bash" "edksetup.sh") 408 (replace 'configure
422 (substitute* "Conf/target.txt" 409 (lambda _
423 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n") 410 (let* ((cwd (getcwd))
424 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$") 411 (tools (string-append cwd "/BaseTools"))
425 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%" 412 (bin (string-append tools "/BinWrappers/PosixLike")))
426 (number->string (parallel-job-count))))) 413 (setenv "WORKSPACE" cwd)
427 ;; Build build support. 414 (setenv "EDK_TOOLS_PATH" tools)
428 (setenv "BUILD_CC" "gcc") 415 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
429 (invoke "make" "-C" tools) 416 (invoke "bash" "edksetup.sh")
430 #t))) 417 (substitute* "Conf/target.txt"
431 (replace 'build 418 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
432 (lambda _ 419 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
433 (invoke "build" "-a" "IA32" "-t" "GCC49" 420 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
434 "-p" "OvmfPkg/OvmfPkgIa32.dsc"))) 421 (number->string (parallel-job-count)))))
435 ,@(if (string=? "x86_64-linux" (%current-system)) 422 ;; Build build support.
436 '((add-after 'build 'build-x64 423 (setenv "BUILD_CC" "gcc")
437 (lambda _ 424 (invoke "make" "-C" tools))))
438 (invoke "build" "-a" "X64" "-t" "GCC49" 425 (replace 'build
439 "-p" "OvmfPkg/OvmfPkgX64.dsc")))) 426 (lambda _
440 '()) 427 (invoke "build" "-a" "IA32" "-t" "GCC49"
441 (replace 'install 428 "-p" "OvmfPkg/OvmfPkgIa32.dsc")))
442 (lambda* (#:key outputs #:allow-other-keys) 429 #$@(if (string=? "x86_64-linux" (%current-system))
443 (let* ((out (assoc-ref outputs "out")) 430 #~((add-after 'build 'build-x64
444 (fmw (string-append out "/share/firmware"))) 431 (lambda _
445 (mkdir-p fmw) 432 (invoke "build" "-a" "X64" "-t" "GCC49"
446 (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd" 433 "-p" "OvmfPkg/OvmfPkgX64.dsc"))))
447 (string-append fmw "/ovmf_ia32.bin")) 434 #~())
448 ,@(if (string=? "x86_64-linux" (%current-system)) 435 (replace 'install
449 '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd" 436 (lambda _
450 (string-append fmw "/ovmf_x64.bin"))) 437 (let ((fmw (string-append #$output "/share/firmware")))
451 '())) 438 (mkdir-p fmw)
452 #t))))) 439 (copy-file "Build/OvmfIa32/RELEASE_GCC49/FV/OVMF.fd"
453 (supported-systems '("x86_64-linux" "i686-linux")) 440 (string-append fmw "/ovmf_ia32.bin"))
454 (home-page "https://www.tianocore.org") 441 #$@(if (string=? "x86_64-linux" (%current-system))
455 (synopsis "UEFI firmware for QEMU") 442 '((copy-file "Build/OvmfX64/RELEASE_GCC49/FV/OVMF.fd"
456 (description "OVMF is an EDK II based project to enable UEFI support for 443 (string-append fmw "/ovmf_x64.bin")))
444 '())))))))
445 (native-inputs
446 `(("acpica" ,acpica)
447 ("gcc@5" ,gcc-5)
448 ("nasm" ,nasm)
449 ("python-2" ,python-2)
450 ("util-linux" ,util-linux "lib")))
451 (supported-systems '("x86_64-linux" "i686-linux"))
452 (home-page "https://www.tianocore.org")
453 (synopsis "UEFI firmware for QEMU")
454 (description "OVMF is an EDK II based project to enable UEFI support for
457Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.") 455Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
458 (license (list license:expat 456 (license (list license:expat
459 license:bsd-2 license:bsd-3 license:bsd-4)))) 457 license:bsd-2 license:bsd-3 license:bsd-4)))))
460 458
461(define-public ovmf-aarch64 459(define-public ovmf-aarch64
462 (package 460 (package
463 (inherit ovmf) 461 (inherit ovmf)
464 (name "ovmf-aarch64") 462 (name "ovmf-aarch64")
465 (native-inputs 463 (native-inputs
466 `(,@(package-native-inputs ovmf) 464 (append (package-native-inputs ovmf)
467 ,@(if (not (string-prefix? "aarch64" (%current-system))) 465 (if (not (string-prefix? "aarch64" (%current-system)))
468 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu")) 466 `(("cross-gcc" ,(cross-gcc "aarch64-linux-gnu"))
469 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu"))) 467 ("cross-binutils" ,(cross-binutils "aarch64-linux-gnu")))
470 '()))) 468 '())))
471 (arguments 469 (arguments
472 (substitute-keyword-arguments (package-arguments ovmf) 470 (substitute-keyword-arguments (package-arguments ovmf)
473 ((#:phases phases) 471 ((#:phases phases)
474 `(modify-phases ,phases 472 #~(modify-phases #$phases
475 (add-before 'configure 'set-env 473 (add-before 'configure 'set-env
476 (lambda _ 474 (lambda _
477 ,@(if (not (string-prefix? "aarch64" (%current-system))) 475 #$@(if (not (string-prefix? "aarch64" (%current-system)))
478 `((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-")) 476 #~((setenv "GCC49_AARCH64_PREFIX" "aarch64-linux-gnu-"))
479 '()) 477 #~())))
480 #t)) 478 (replace 'build
481 (replace 'build 479 (lambda _
482 (lambda _ 480 (invoke "build" "-a" "AARCH64" "-t" "GCC49"
483 (invoke "build" "-a" "AARCH64" "-t" "GCC49" 481 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
484 "-p" "ArmVirtPkg/ArmVirtQemu.dsc"))) 482 (delete 'build-x64)
485 (delete 'build-x64) 483 (replace 'install
486 (replace 'install 484 (lambda _
487 (lambda* (#:key outputs #:allow-other-keys) 485 (let ((fmw (string-append #$output "/share/firmware")))
488 (let* ((out (assoc-ref outputs "out")) 486 (mkdir-p fmw)
489 (fmw (string-append out "/share/firmware"))) 487 (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
490 (mkdir-p fmw) 488 (string-append fmw "/ovmf_aarch64.bin")))))))))
491 (copy-file "Build/ArmVirtQemu-AARCH64/RELEASE_GCC49/FV/QEMU_EFI.fd"
492 (string-append fmw "/ovmf_aarch64.bin"))
493 #t)))))))
494 (supported-systems %supported-systems))) 489 (supported-systems %supported-systems)))
495 490
496(define-public ovmf-arm 491(define-public ovmf-arm
@@ -498,34 +493,31 @@ Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
498 (inherit ovmf) 493 (inherit ovmf)
499 (name "ovmf-arm") 494 (name "ovmf-arm")
500 (native-inputs 495 (native-inputs
501 `(,@(package-native-inputs ovmf) 496 (append (package-native-inputs ovmf)
502 ,@(if (not (string-prefix? "armhf" (%current-system))) 497 (if (not (string-prefix? "armhf" (%current-system)))
503 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf")) 498 `(("cross-gcc" ,(cross-gcc "arm-linux-gnueabihf"))
504 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf"))) 499 ("cross-binutils" ,(cross-binutils "arm-linux-gnueabihf")))
505 '()))) 500 '())))
506 (arguments 501 (arguments
507 (substitute-keyword-arguments (package-arguments ovmf) 502 (substitute-keyword-arguments (package-arguments ovmf)
508 ((#:phases phases) 503 ((#:phases phases)
509 `(modify-phases ,phases 504 #~(modify-phases #$phases
510 (add-before 'configure 'set-env 505 (add-before 'configure 'set-env
511 (lambda _ 506 (lambda _
512 ,@(if (not (string-prefix? "armhf" (%current-system))) 507 #$@(if (not (string-prefix? "armhf" (%current-system)))
513 `((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-")) 508 #~((setenv "GCC49_ARM_PREFIX" "arm-linux-gnueabihf-"))
514 '()) 509 #~())))
515 #t)) 510 (replace 'build
516 (replace 'build 511 (lambda _
517 (lambda _ 512 (invoke "build" "-a" "ARM" "-t" "GCC49"
518 (invoke "build" "-a" "ARM" "-t" "GCC49" 513 "-p" "ArmVirtPkg/ArmVirtQemu.dsc")))
519 "-p" "ArmVirtPkg/ArmVirtQemu.dsc"))) 514 (delete 'build-x64)
520 (delete 'build-x64) 515 (replace 'install
521 (replace 'install 516 (lambda _
522 (lambda* (#:key outputs #:allow-other-keys) 517 (let ((fmw (string-append #$output "/share/firmware")))
523 (let* ((out (assoc-ref outputs "out")) 518 (mkdir-p fmw)
524 (fmw (string-append out "/share/firmware"))) 519 (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
525 (mkdir-p fmw) 520 (string-append fmw "/ovmf_arm.bin")))))))))
526 (copy-file "Build/ArmVirtQemu-ARM/RELEASE_GCC49/FV/QEMU_EFI.fd"
527 (string-append fmw "/ovmf_arm.bin"))
528 #t)))))))
529 (supported-systems %supported-systems))) 521 (supported-systems %supported-systems)))
530 522
531(define* (make-arm-trusted-firmware platform #:optional (arch "aarch64")) 523(define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))