From: Josselin Poiret <dev@jpoiret.xyz>
To: Fabio Natali <me@fabionatali.com>, Josselin Poiret <dev@jpoiret.xyz>
Cc: guix-devel@gnu.org, Oleg Pykhalov <go.wigust@gmail.com>,
Felix Lechner <felix.lechner@lease-up.com>
Subject: [PATCH 2/2] gnu: grub: Modernize.
Date: Sun, 3 Mar 2024 17:42:14 +0100 [thread overview]
Message-ID: <f6075fb65432dfdbb351ddeba1246f5cd49ae507.1709484088.git.dev@jpoiret.xyz> (raw)
In-Reply-To: <87bk7vhett.fsf@fabionatali.com>
From: Josselin Poiret <dev@jpoiret.xyz>
* gnu/packages/bootloaders.scm (grub-minimal, grub-coreboot, grub-efi32, grub-hybrid): Use G-Exps.
(grub-efi): Use G-Exps. Also use OVMF to test.
Change-Id: Ic9c73753004739d6027b8426eb46c114a6a31051
---
gnu/packages/bootloaders.scm | 286 +++++++++++++++++++----------------
1 file changed, 152 insertions(+), 134 deletions(-)
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 1327055484..39b98b0876 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -307,20 +307,18 @@ (define-public grub-minimal
'(list "PYTHON=true"))
((#:tests? _ #t)
#f)
- ((#:phases phases '%standard-phases)
- `(modify-phases ,phases
- (replace 'patch-stuff
- (lambda* (#:key native-inputs inputs #:allow-other-keys)
- (substitute* "grub-core/Makefile.in"
- (("/bin/sh") (which "sh")))
-
- ;; Make the font visible.
- (copy-file (assoc-ref (or native-inputs inputs)
- "unifont")
- "unifont.bdf.gz")
- (system* "gunzip" "unifont.bdf.gz")
-
- #t))))))))
+ ((#:phases phases #~%standard-phases)
+ #~(modify-phases #$phases
+ (replace 'patch-stuff
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (substitute* "grub-core/Makefile.in"
+ (("/bin/sh") (which "sh")))
+
+ ;; Make the font visible.
+ (copy-file (assoc-ref (or native-inputs inputs)
+ "unifont")
+ "unifont.bdf.gz")
+ (system* "gunzip" "unifont.bdf.gz")))))))))
(define-public grub-coreboot
(package
@@ -328,64 +326,64 @@ (define-public grub-coreboot
(name "grub-coreboot")
(synopsis "GRand Unified Boot loader (Coreboot payload version)")
(arguments
- `(,@(substitute-keyword-arguments (package-arguments grub)
- ((#:phases phases '%standard-phases)
- `(modify-phases ,phases
- (add-before 'check 'disable-broken-tests
- (lambda _
- (setenv "DISABLE_HARD_ERRORS" "1")
- (setenv
- "XFAIL_TESTS"
- (string-join
- ;; TODO: All the tests below use grub shell
- ;; (tests/util/grub-shell.in), and here grub-shell uses
- ;; QEMU and a Coreboot image to run the tests. Since we
- ;; don't have a Coreboot package in Guix yet these tests
- ;; are disabled. See the Guix bug #64667 for more details
- ;; (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64667).
- (list
- "pata_test"
- "ahci_test"
- "uhci_test"
- "ehci_test"
- "example_grub_script_test"
- "ohci_test"
- "grub_script_eval"
- "grub_script_echo1"
- "grub_script_test"
- "grub_script_leading_whitespace"
- "grub_script_echo_keywords"
- "grub_script_vars1"
- "grub_script_for1"
- "grub_script_while1"
- "grub_script_if"
- "grub_script_comments"
- "grub_script_functions"
- "grub_script_continue"
- "grub_script_break"
- "grub_script_shift"
- "grub_script_blockarg"
- "grub_script_return"
- "grub_script_setparams"
- "grub_cmd_date"
- "grub_cmd_sleep"
- "grub_cmd_regexp"
- "grub_script_not"
- "grub_cmd_echo"
- "grub_script_expansion"
- "grub_script_gettext"
- "grub_script_escape_comma"
- "help_test"
- "grub_script_strcmp"
- "test_sha512sum"
- "grub_cmd_tr"
- "test_unset"
- "file_filter_test")
- " "))))))
- ((#:configure-flags flags
- ''())
- `(cons* "--with-platform=coreboot"
- ,flags)))))))
+ (substitute-keyword-arguments (package-arguments grub)
+ ((#:phases phases #~%standard-phases)
+ #~(modify-phases #$phases
+ (add-before 'check 'disable-broken-tests
+ (lambda _
+ (setenv "DISABLE_HARD_ERRORS" "1")
+ (setenv
+ "XFAIL_TESTS"
+ (string-join
+ ;; TODO: All the tests below use grub shell
+ ;; (tests/util/grub-shell.in), and here grub-shell uses
+ ;; QEMU and a Coreboot image to run the tests. Since we
+ ;; don't have a Coreboot package in Guix yet these tests
+ ;; are disabled. See the Guix bug #64667 for more details
+ ;; (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64667).
+ (list
+ "pata_test"
+ "ahci_test"
+ "uhci_test"
+ "ehci_test"
+ "example_grub_script_test"
+ "ohci_test"
+ "grub_script_eval"
+ "grub_script_echo1"
+ "grub_script_test"
+ "grub_script_leading_whitespace"
+ "grub_script_echo_keywords"
+ "grub_script_vars1"
+ "grub_script_for1"
+ "grub_script_while1"
+ "grub_script_if"
+ "grub_script_comments"
+ "grub_script_functions"
+ "grub_script_continue"
+ "grub_script_break"
+ "grub_script_shift"
+ "grub_script_blockarg"
+ "grub_script_return"
+ "grub_script_setparams"
+ "grub_cmd_date"
+ "grub_cmd_sleep"
+ "grub_cmd_regexp"
+ "grub_script_not"
+ "grub_cmd_echo"
+ "grub_script_expansion"
+ "grub_script_gettext"
+ "grub_script_escape_comma"
+ "help_test"
+ "grub_script_strcmp"
+ "test_sha512sum"
+ "grub_cmd_tr"
+ "test_unset"
+ "file_filter_test")
+ " "))))))
+ ((#:configure-flags flags
+ ''())
+ #~(cons* "--with-platform=coreboot"
+ #$flags))))))
(define-public grub-efi
(package
@@ -396,43 +394,58 @@ (define-public grub-efi
(modify-inputs (package-inputs grub)
(prepend efibootmgr mtools)))
(native-inputs
- ;; The tests are skipped in this package so we remove some test dependencies.
(modify-inputs (package-native-inputs grub)
- (delete "parted" "qemu" "xorriso")))
+ (prepend (match (or (%current-target-system) (%current-system))
+ ((? target-x86?) ovmf)
+ ((? target-arm32?) ovmf-arm)
+ ((? target-aarch64?) ovmf-aarch64)))))
(arguments
- `(;; TODO: Tests need a UEFI firmware for qemu. There is one at
- ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
- ;; Search for 'OVMF' in "tests/util/grub-shell.in".
- ,@(substitute-keyword-arguments (package-arguments grub)
- ((#:tests? _ #f) #f)
- ((#:configure-flags flags ''())
- `(cons* "--with-platform=efi"
- ,@(if (string-prefix? "x86_64"
- (or (%current-target-system)
- (%current-system)))
- '("--enable-stack-protector") ; EFI-only for now
- '())
- ,flags))
- ((#:phases phases)
- `(modify-phases ,phases
- (add-after 'patch-stuff 'use-absolute-efibootmgr-path
- (lambda* (#:key inputs #:allow-other-keys)
- (substitute* "grub-core/osdep/unix/platform.c"
- (("efibootmgr")
- (search-input-file inputs
- "/sbin/efibootmgr")))))
- (add-after 'patch-stuff 'use-absolute-mtools-path
- (lambda* (#:key inputs #:allow-other-keys)
- (let ((mtools (assoc-ref inputs "mtools")))
- (substitute* "util/grub-mkrescue.c"
- (("\"mformat\"")
- (string-append "\"" mtools
- "/bin/mformat\"")))
- (substitute* "util/grub-mkrescue.c"
- (("\"mcopy\"")
- (string-append "\"" mtools
- "/bin/mcopy\"")))
- #t))))))))))
+ (substitute-keyword-arguments (package-arguments grub)
+ ((#:configure-flags flags ''())
+ `(cons* "--with-platform=efi"
+ ,@(if (string-prefix? "x86_64"
+ (or (%current-target-system)
+ (%current-system)))
+ '("--enable-stack-protector") ; EFI-only for now
+ '())
+ ,flags))
+ ((#:phases phases)
+ #~(modify-phases #$phases
+ (add-after 'patch-stuff 'use-absolute-efibootmgr-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "grub-core/osdep/unix/platform.c"
+ (("efibootmgr")
+ (search-input-file inputs
+ "/sbin/efibootmgr")))))
+ (add-after 'patch-stuff 'use-abolute-ovmf-path
+ (lambda* (#:key inputs native-inputs #:allow-other-keys)
+ #$(match-let
+ (((str . replacement)
+ (match (or (%current-target-system) (%current-system))
+ ((? target-x86-32?)
+ '("OVMF-ia32.fd" . "ovmf_ia32.bin"))
+ ((? target-x86-64?)
+ '("OVMF.fd" . "ovmf_x64.bin"))
+ ((? target-arm32?)
+ '("/usr/share/ovmf-arm/QEMU_EFI.fd" . "ovmf_arm.bin"))
+ ((? target-aarch64?)
+ '("/usr/share/qemu-efi/QEMU_EFI.fd" . "ovmf_aarch64.bin")))))
+ #~(substitute* "tests/util/grub-shell.in"
+ ((#$str)
+ (search-input-file
+ (or native-inputs inputs)
+ (string-append "/share/firmware/" #$replacement)))))))
+ (add-after 'patch-stuff 'use-absolute-mtools-path
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((mformat (search-input-file inputs "/bin/mformat"))
+ (mcopy (search-input-file inputs "/bin/mcopy")))
+ (substitute* "util/grub-mkrescue.c"
+ (("\"mformat\"")
+ (string-append "\"" mformat "\"")))
+ (substitute* "util/grub-mkrescue.c"
+ (("\"mcopy\"")
+ (string-append "\"" mcopy "\""))))))))))
+ (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux" "aarch64-linux"))))
(define-public grub-efi32
(package
@@ -440,17 +453,24 @@ (define-public grub-efi32
(name "grub-efi32")
(synopsis "GRand Unified Boot loader (UEFI 32bit version)")
(arguments
- `(,@(substitute-keyword-arguments (package-arguments grub-efi)
- ((#:configure-flags flags ''())
- `(cons*
- ,@(cond ((target-x86?) '("--target=i386"))
- ((target-aarch64?)
- (list "--target=arm"
- (string-append "TARGET_CC="
- (cc-for-target "arm-linux-gnueabihf"))))
- ((target-arm?) '("--target=arm"))
- (else '()))
- ,flags)))))
+ (substitute-keyword-arguments
+ (parameterize ((%current-target-system
+ (match (or (%current-target-system) (%current-system))
+ ((? target-x86?)
+ "i686-linux")
+ ((? target-arm?)
+ "arm-linux-gnueabihf"))))
+ (package-arguments grub-efi))
+ ((#:configure-flags flags ''())
+ `(cons*
+ ,@(cond ((target-x86?) '("--target=i386"))
+ ((target-aarch64?)
+ (list "--target=arm"
+ (string-append "TARGET_CC="
+ (cc-for-target "arm-linux-gnueabihf"))))
+ ((target-arm?) '("--target=arm"))
+ (else '()))
+ ,flags))))
(native-inputs
(if (target-aarch64?)
(modify-inputs (package-native-inputs grub-efi)
@@ -476,22 +496,20 @@ (define-public grub-hybrid
(substitute-keyword-arguments (package-arguments grub-efi)
((#:modules modules `((guix build utils) (guix build gnu-build-system)))
`((ice-9 ftw) ,@modules))
- ((#:phases phases)
- `(modify-phases ,phases
- (add-after 'install 'install-non-efi
- (lambda* (#:key inputs outputs #:allow-other-keys)
- (let ((input-dir (search-input-directory inputs
- "/lib/grub"))
- (output-dir (string-append (assoc-ref outputs "out")
- "/lib/grub")))
- (for-each
- (lambda (basename)
- (if (not (or (string-prefix? "." basename)
- (file-exists? (string-append output-dir "/" basename))))
- (symlink (string-append input-dir "/" basename)
- (string-append output-dir "/" basename))))
- (scandir input-dir))
- #t)))))))))
+ ((#:phases phases #~%standard-phases)
+ #~(modify-phases #$phases
+ (add-after 'install 'install-non-efi
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((input-dir (search-input-directory inputs
+ "/lib/grub"))
+ (output-dir (string-append #$output "/lib/grub")))
+ (for-each
+ (lambda (basename)
+ (if (not (or (string-prefix? "." basename)
+ (file-exists? (string-append output-dir "/" basename))))
+ (symlink (string-append input-dir "/" basename)
+ (string-append output-dir "/" basename))))
+ (scandir input-dir)))))))))))
(define-public (make-grub-efi-netboot name subdir)
"Make a grub-efi-netboot package named NAME, which will be able to boot over
--
2.41.0
next prev parent reply other threads:[~2024-03-03 16:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 9:08 LUKS2 support in Guix Fabio Natali
2024-03-01 13:25 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
2024-03-02 7:41 ` Oleg Pykhalov
2024-03-02 12:45 ` Fabio Natali
2024-03-02 21:23 ` Josselin Poiret
2024-03-03 8:58 ` Fabio Natali
2024-03-03 16:42 ` [PATCH 1/2] gnu: grub: Update to 2.12 Josselin Poiret
2024-03-03 16:42 ` Josselin Poiret [this message]
2024-03-05 9:53 ` [PATCH 2/2] gnu: grub: Modernize Fabio Natali
2024-03-09 9:42 ` Josselin Poiret
2024-03-11 14:47 ` Fabio Natali
2024-03-03 3:08 ` LUKS2 support in Guix Maxim Cournoyer
2024-03-03 9:03 ` Fabio Natali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f6075fb65432dfdbb351ddeba1246f5cd49ae507.1709484088.git.dev@jpoiret.xyz \
--to=dev@jpoiret.xyz \
--cc=felix.lechner@lease-up.com \
--cc=go.wigust@gmail.com \
--cc=guix-devel@gnu.org \
--cc=me@fabionatali.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.