summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/bootloaders.scm87
1 files changed, 75 insertions, 12 deletions
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 074ceb3df08..da571e38fd3 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -6,7 +6,7 @@
6;;; Copyright © 2016-2018, 2021-2023 Marius Bakke <marius@gnu.org> 6;;; Copyright © 2016-2018, 2021-2023 Marius Bakke <marius@gnu.org>
7;;; Copyright © 2016, 2017 Danny Milosavljevic <dannym@scratchpost.org> 7;;; Copyright © 2016, 2017 Danny Milosavljevic <dannym@scratchpost.org>
8;;; Copyright © 2016, 2017 David Craven <david@craven.ch> 8;;; Copyright © 2016, 2017 David Craven <david@craven.ch>
9;;; Copyright © 2017, 2018, 2020-2024 Efraim Flashner <efraim@flashner.co.il> 9;;; Copyright © 2017, 2018, 2020-2025 Efraim Flashner <efraim@flashner.co.il>
10;;; Copyright © 2018–2022 Tobias Geerinckx-Rice <me@tobias.gr> 10;;; Copyright © 2018–2022 Tobias Geerinckx-Rice <me@tobias.gr>
11;;; Copyright © 2019 nee <nee@cock.li> 11;;; Copyright © 2019 nee <nee@cock.li>
12;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com> 12;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
@@ -21,6 +21,7 @@
21;;; Copyright © 2023-2024 Herman Rimm <herman@rimm.ee> 21;;; Copyright © 2023-2024 Herman Rimm <herman@rimm.ee>
22;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com> 22;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
23;;; Copyright © 2024 Zheng Junjie <873216071@qq.com> 23;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
24;;; Copyright © 2025 Esther Flashner <esther@flashner.co.il>
24;;; 25;;;
25;;; This file is part of GNU Guix. 26;;; This file is part of GNU Guix.
26;;; 27;;;
@@ -411,15 +412,27 @@ menu to select one of the installed operating systems.")
411 (modify-inputs (package-inputs grub) 412 (modify-inputs (package-inputs grub)
412 (prepend efibootmgr mtools))) 413 (prepend efibootmgr mtools)))
413 (native-inputs 414 (native-inputs
414 ;; The tests are skipped in this package so we remove some test dependencies. 415 (cond ((or (target-x86-64?)
415 (modify-inputs (package-native-inputs grub) 416 (target-x86-32?)
416 (delete "parted" "qemu" "qemu-minimal" "xorriso"))) 417 (target-aarch64?)
418 (target-arm32?))
419 ;; We add the firmware needed to run the tests.
420 (modify-inputs (package-native-inputs grub)
421 (prepend
422 (cond ((target-x86-64?) ovmf-x86-64)
423 ((target-x86-32?) ovmf-i686)
424 ((target-aarch64?) ovmf-aarch64)
425 ((target-arm32?) ovmf-arm)
426 (else pkg-config)))))
427 (else
428 ;; The tests are skipped in this package so we remove some
429 ;; test dependencies.
430 (modify-inputs (package-native-inputs grub)
431 (delete "parted" "qemu-minimal" "xorriso")))))
417 (arguments 432 (arguments
418 ;; TODO: Tests need a UEFI firmware for qemu. There is one at
419 ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
420 ;; Search for 'OVMF' in "tests/util/grub-shell.in".
421 (substitute-keyword-arguments (package-arguments grub) 433 (substitute-keyword-arguments (package-arguments grub)
422 ((#:tests? _ #f) #f) 434 ((#:tests? _ #f) (and (not (%current-target-system))
435 (this-package-native-input "qemu-minimal")))
423 ((#:configure-flags flags #~'()) 436 ((#:configure-flags flags #~'())
424 #~(cons* "--with-platform=efi" 437 #~(cons* "--with-platform=efi"
425 #$@(if (string-prefix? "x86_64" 438 #$@(if (string-prefix? "x86_64"
@@ -430,6 +443,32 @@ menu to select one of the installed operating systems.")
430 #$flags)) 443 #$flags))
431 ((#:phases phases) 444 ((#:phases phases)
432 #~(modify-phases #$phases 445 #~(modify-phases #$phases
446 #$@(if (this-package-native-input "qemu-minimal")
447 #~((add-after 'patch-stuff 'patch-ovmf-path
448 (lambda* (#:key inputs #:allow-other-keys)
449 (let ((arch #$(cond ((target-x86-64?) "x64")
450 ((target-x86-32?) "ia32")
451 ((target-aarch64?) "aarch64")
452 ((target-arm32?) "arm")
453 (else ""))))
454 (substitute* "tests/util/grub-shell.in"
455 (("OVMF-ia32\\.fd")
456 (search-input-file
457 inputs (string-append
458 "/share/firmware/ovmf_" arch ".bin")))
459 (("OVMF\\.fd")
460 (search-input-file
461 inputs (string-append
462 "/share/firmware/ovmf_" arch ".bin")))
463 (("/usr/share/qemu-efi/QEMU_EFI\\.fd")
464 (search-input-file
465 inputs (string-append
466 "/share/firmware/ovmf_" arch ".bin")))
467 (("/usr/share/ovmf-arm/QEMU_EFI\\.fd")
468 (search-input-file
469 inputs (string-append
470 "/share/firmware/ovmf_" arch ".bin"))))))))
471 #~())
433 (add-after 'patch-stuff 'use-absolute-efibootmgr-path 472 (add-after 'patch-stuff 'use-absolute-efibootmgr-path
434 (lambda* (#:key inputs #:allow-other-keys) 473 (lambda* (#:key inputs #:allow-other-keys)
435 (substitute* "grub-core/osdep/unix/platform.c" 474 (substitute* "grub-core/osdep/unix/platform.c"
@@ -466,14 +505,38 @@ menu to select one of the installed operating systems.")
466 ((target-arm?) 505 ((target-arm?)
467 #~("--target=arm")) 506 #~("--target=arm"))
468 (else #~())) 507 (else #~()))
469 #$flags)))) 508 #$flags))
509 ((#:phases phases)
510 #~(modify-phases #$phases
511 #$@(if (or (target-x86?)
512 (target-arm?))
513 #~((replace 'patch-ovmf-path
514 (lambda* (#:key inputs #:allow-other-keys)
515 (let ((arch #$(cond ((target-x86?) "ia32")
516 ((target-arm?) "arm")
517 (else ""))))
518 (substitute* "tests/util/grub-shell.in"
519 (("OVMF-ia32\\.fd")
520 (search-input-file
521 inputs (string-append
522 "/share/firmware/ovmf_" arch ".bin")))
523 (("/usr/share/ovmf-arm/QEMU_EFI\\.fd")
524 (search-input-file
525 inputs (string-append
526 "/share/firmware/ovmf_" arch ".bin"))))))))
527 #~())))))
470 (native-inputs 528 (native-inputs
471 (if (target-aarch64?) 529 (cond
530 ((target-x86-64?)
531 (modify-inputs (package-native-inputs grub-efi)
532 (replace "ovmf-x86-64" ovmf-i686)))
533 ((target-aarch64?)
472 (modify-inputs (package-native-inputs grub-efi) 534 (modify-inputs (package-native-inputs grub-efi)
473 (prepend 535 (prepend
474 (cross-gcc "arm-linux-gnueabihf") 536 (cross-gcc "arm-linux-gnueabihf")
475 (cross-binutils "arm-linux-gnueabihf"))) 537 (cross-binutils "arm-linux-gnueabihf"))
476 (package-native-inputs grub-efi))))) 538 (replace "ovmf-aarch64" ovmf-arm)))
539 (else (package-native-inputs grub-efi))))))
477 540
478(define-public grub-emu 541(define-public grub-emu
479 (package/inherit grub 542 (package/inherit grub