me
/
guix
Archived
1
0
Fork 0

gnu: grub: Remove input labels and use gexps.

* gnu/packages/bootloaders.scm (grub)[arguments]: Use gexps.
[inputs, native-inputs]: Remove labels.
(grub-minimal, grub-coreboot, grub-efi, grub-efi32)
(grub-hybrid): Likewise.

Change-Id: I2773e6d96d170fae991d9c5db9e10196ea603371
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
master
Ludovic Courtès 2024-06-03 22:01:23 +02:00 committed by Maxim Cournoyer
parent e6facbe069
commit b9c38f26f1
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
1 changed files with 254 additions and 258 deletions

View File

@ -128,15 +128,18 @@
(("exit 99") "exit 77")))))) (("exit 99") "exit 77"))))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:configure-flags (list #:configure-flags
;; Counterintuitively, this *disables* a spurious Python dependency by ;; Counterintuitively, this *disables* a spurious Python dependency by
;; calling the true binary instead. Python is only needed during ;; calling the true binary instead. Python is only needed during
;; bootstrapping (for genptl.py), not when building from a release. ;; bootstrapping (for genptl.py), not when building from a release.
(list "PYTHON=true") #~(list "PYTHON=true")
;; Grub fails to load modules stripped with --strip-unneeded.
#:strip-flags '("--strip-debug" "--enable-deterministic-archives") ;; GRUB fails to load modules stripped with --strip-unneeded.
#:strip-flags
#~(list "--strip-debug" "--enable-deterministic-archives")
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'patch-stuff (add-after 'unpack 'patch-stuff
(lambda* (#:key native-inputs inputs #:allow-other-keys) (lambda* (#:key native-inputs inputs #:allow-other-keys)
(substitute* "grub-core/Makefile.in" (substitute* "grub-core/Makefile.in"
@ -145,17 +148,15 @@
;; Give the absolute file name of 'mdadm', used to determine the ;; Give the absolute file name of 'mdadm', used to determine the
;; root file system when it's a RAID device. Failing to do that, ;; root file system when it's a RAID device. Failing to do that,
;; 'grub-probe' silently fails if 'mdadm' is not in $PATH. ;; 'grub-probe' silently fails if 'mdadm' is not in $PATH.
(when (assoc-ref inputs "mdadm") (let ((mdadm (false-if-exception
(search-input-file inputs "/sbin/mdadm"))))
(when mdadm
(substitute* "grub-core/osdep/linux/getroot.c" (substitute* "grub-core/osdep/linux/getroot.c"
(("argv\\[0\\] = \"mdadm\"") (("argv\\[0\\] = \"mdadm\"")
(string-append "argv[0] = \"" (string-append "argv[0] = \"" mdadm "/sbin/mdadm\"")))))
(assoc-ref inputs "mdadm")
"/sbin/mdadm\""))))
;; Make the font visible. ;; Make the font visible.
(copy-file (assoc-ref (or native-inputs inputs) (copy-file #+unifont "unifont.bdf.gz")
"unifont")
"unifont.bdf.gz")
(system* "gunzip" "unifont.bdf.gz") (system* "gunzip" "unifont.bdf.gz")
;; Give the absolute file name of 'ckbcomp'. ;; Give the absolute file name of 'ckbcomp'.
@ -191,58 +192,65 @@
(substitute* "Makefile.in" (substitute* "Makefile.in"
(("test_unset grub_func_test") (("test_unset grub_func_test")
"test_unset"))))) "test_unset")))))
;; Disable tests on ARM and AARCH64 platforms or when cross-compiling. ;; Disable tests on ARM and AARCH64 platforms or when cross-compiling.
#:tests? ,(not (or (any (cute string-prefix? <> (or (%current-target-system) #:tests? (not (or (any (cute string-prefix? <> (%current-system))
(%current-system)))
'("arm" "aarch64")) '("arm" "aarch64"))
(%current-target-system))))) (%current-target-system)))))
(inputs (inputs
`(("gettext" ,gettext-minimal) (append (list gettext-minimal freetype ncurses
;; Console-setup's ckbcomp is invoked by grub-kbdcomp. It
;; is required for generating alternative keyboard layouts.
console-setup)
;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and ;; Depend on LVM2 for libdevmapper, used by 'grub-probe' and
;; 'grub-install' to recognize mapped devices (LUKS, etc.) ;; 'grub-install' to recognize mapped devices (LUKS, etc.)
,@(if (member (or (%current-target-system) (if (member (or (%current-target-system)
(%current-system)) (%current-system))
(package-supported-systems lvm2)) (package-supported-systems lvm2))
`(("lvm2" ,lvm2)) (list lvm2)
'()) '())
;; Depend on mdadm, which is invoked by 'grub-probe' and 'grub-install' ;; Depend on mdadm, which is invoked by 'grub-probe' and
;; to determine whether the root file system is RAID. ;; 'grub-install' to determine whether the root file system is
,@(if (member (or (%current-target-system) ;; RAID.
(if (member (or (%current-target-system)
(%current-system)) (%current-system))
(package-supported-systems mdadm)) (package-supported-systems mdadm))
`(("mdadm" ,mdadm)) (list mdadm)
'()) '())
;; Console-setup's ckbcomp is invoked by grub-kbdcomp. It is required ;; Needed for grub-mount, the only reliable way to tell whether
;; for generating alternative keyboard layouts. ;; a given file system will be readable by GRUB without
("console-setup" ,console-setup) ;; rebooting.
(if (member (or (%current-target-system)
;; Needed for grub-mount, the only reliable way to tell whether a given
;; file system will be readable by GRUB without rebooting.
,@(if (member (or (%current-target-system)
(%current-system)) (%current-system))
(package-supported-systems fuse-2)) (package-supported-systems fuse-2))
`(("fuse" ,fuse-2)) (list fuse-2)
'()) '())))
("freetype" ,freetype)
;; ("libusb" ,libusb)
("ncurses" ,ncurses)))
(native-inputs (native-inputs
`(("pkg-config" ,pkg-config) (append (list pkg-config
("unifont" ,unifont) bison
("bison" ,bison) flex
("flex" ,flex) texinfo
("texinfo" ,texinfo) help2man
("help2man" ,help2man) freetype ;native version needed for build-grub-mkfont
("freetype" ,freetype) ;native version needed for build-grub-mkfont
;; Dependencies of the test suite.
parted
xorriso)
;; For the test suite, the "real" QEMU is needed because several
;; targets are used.
(if (member (%current-system) (package-supported-systems qemu-minimal))
(list qemu-minimal)
'())
;; XXX: When building GRUB 2.02 on 32-bit x86, we need a binutils ;; XXX: When building GRUB 2.02 on 32-bit x86, we need a binutils
;; capable of assembling 64-bit instructions. However, our default ;; capable of assembling 64-bit instructions. However, our default
;; binutils on 32-bit x86 is not 64-bit capable. ;; binutils on 32-bit x86 is not 64-bit capable.
,@(if (string-match "^i[3456]86-" (%current-system)) (if (string-match "^i[3456]86-" (%current-system))
(let ((binutils (package/inherit (let ((binutils (package/inherit
binutils binutils
(name "binutils-i386") (name "binutils-i386")
@ -250,18 +258,10 @@
(substitute-keyword-arguments (package-arguments binutils) (substitute-keyword-arguments (package-arguments binutils)
((#:configure-flags flags ''()) ((#:configure-flags flags ''())
`(cons "--enable-64-bit-bfd" ,flags))))))) `(cons "--enable-64-bit-bfd" ,flags)))))))
`(("ld-wrapper" ,(make-ld-wrapper "ld-wrapper-i386" (list (make-ld-wrapper "ld-wrapper-i386"
#:binutils binutils)) #:binutils binutils)
("binutils" ,binutils))) binutils))
'()) '())))
;; Dependencies for the test suite. The "real" QEMU is needed here,
;; because several targets are used.
("parted" ,parted)
,@(if (member (%current-system) (package-supported-systems qemu-minimal))
`(("qemu" ,qemu-minimal))
'())
("xorriso" ,xorriso)))
(home-page "https://www.gnu.org/software/grub/") (home-page "https://www.gnu.org/software/grub/")
(synopsis "GRand Unified Boot loader") (synopsis "GRand Unified Boot loader")
(description (description
@ -286,24 +286,21 @@ menu to select one of the installed operating systems.")
(delete "help2man" "texinfo" "parted" "qemu" "xorriso"))) (delete "help2man" "texinfo" "parted" "qemu" "xorriso")))
(arguments (arguments
(substitute-keyword-arguments (package-arguments grub) (substitute-keyword-arguments (package-arguments grub)
((#:configure-flags _ ''()) ((#:configure-flags _ #~'())
'(list "PYTHON=true")) #~(list "PYTHON=true"))
((#:tests? _ #t) ((#:tests? _ #t)
#f) #f)
((#:phases phases '%standard-phases) ((#:phases phases #~%standard-phases)
`(modify-phases ,phases #~(modify-phases #$phases
(replace 'patch-stuff (replace 'patch-stuff
(lambda* (#:key native-inputs inputs #:allow-other-keys) (lambda* (#:key native-inputs inputs #:allow-other-keys)
(substitute* "grub-core/Makefile.in" (substitute* "grub-core/Makefile.in"
(("/bin/sh") (which "sh"))) (("/bin/sh")
(which "sh")))
;; Make the font visible. ;; Make the font visible.
(copy-file (assoc-ref (or native-inputs inputs) (copy-file #+unifont "unifont.bdf.gz")
"unifont") (system* "gunzip" "unifont.bdf.gz")))))))))
"unifont.bdf.gz")
(system* "gunzip" "unifont.bdf.gz")
#t))))))))
(define-public grub-coreboot (define-public grub-coreboot
(package (package
@ -311,14 +308,13 @@ menu to select one of the installed operating systems.")
(name "grub-coreboot") (name "grub-coreboot")
(synopsis "GRand Unified Boot loader (Coreboot payload version)") (synopsis "GRand Unified Boot loader (Coreboot payload version)")
(arguments (arguments
`(,@(substitute-keyword-arguments (package-arguments grub) (substitute-keyword-arguments (package-arguments grub)
((#:phases phases '%standard-phases) ((#:phases phases #~%standard-phases)
`(modify-phases ,phases #~(modify-phases #$phases
(add-before 'check 'disable-broken-tests (add-before 'check 'disable-broken-tests
(lambda _ (lambda _
(setenv "DISABLE_HARD_ERRORS" "1") (setenv "DISABLE_HARD_ERRORS" "1")
(setenv (setenv "XFAIL_TESTS"
"XFAIL_TESTS"
(string-join (string-join
;; TODO: All the tests below use grub shell ;; TODO: All the tests below use grub shell
;; (tests/util/grub-shell.in), and here grub-shell uses ;; (tests/util/grub-shell.in), and here grub-shell uses
@ -326,8 +322,7 @@ menu to select one of the installed operating systems.")
;; don't have a Coreboot package in Guix yet these tests ;; don't have a Coreboot package in Guix yet these tests
;; are disabled. See the Guix bug #64667 for more details ;; are disabled. See the Guix bug #64667 for more details
;; (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64667). ;; (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64667).
(list (list "pata_test"
"pata_test"
"ahci_test" "ahci_test"
"uhci_test" "uhci_test"
"ehci_test" "ehci_test"
@ -367,10 +362,8 @@ menu to select one of the installed operating systems.")
"test_unset" "test_unset"
"file_filter_test") "file_filter_test")
" ")))))) " "))))))
((#:configure-flags flags ((#:configure-flags flags #~'())
''()) #~(cons* "--with-platform=coreboot" #$flags))))))
`(cons* "--with-platform=coreboot"
,flags)))))))
(define-public grub-efi (define-public grub-efi
(package (package
@ -385,39 +378,38 @@ menu to select one of the installed operating systems.")
(modify-inputs (package-native-inputs grub) (modify-inputs (package-native-inputs grub)
(delete "parted" "qemu" "xorriso"))) (delete "parted" "qemu" "xorriso")))
(arguments (arguments
`(;; TODO: Tests need a UEFI firmware for qemu. There is one at ;; TODO: Tests need a UEFI firmware for qemu. There is one at
;; https://github.com/tianocore/edk2/tree/master/OvmfPkg . ;; https://github.com/tianocore/edk2/tree/master/OvmfPkg .
;; Search for 'OVMF' in "tests/util/grub-shell.in". ;; Search for 'OVMF' in "tests/util/grub-shell.in".
,@(substitute-keyword-arguments (package-arguments grub) (substitute-keyword-arguments (package-arguments grub)
((#:tests? _ #f) #f) ((#:tests? _ #f) #f)
((#:configure-flags flags ''()) ((#:configure-flags flags #~'())
`(cons* "--with-platform=efi" #~(cons* "--with-platform=efi"
,@(if (string-prefix? "x86_64" #$@(if (string-prefix? "x86_64"
(or (%current-target-system) (or (%current-target-system)
(%current-system))) (%current-system)))
'("--enable-stack-protector") ; EFI-only for now #~("--enable-stack-protector") ;EFI-only for now
'()) #~())
,flags)) #$flags))
((#:phases phases) ((#:phases phases)
`(modify-phases ,phases #~(modify-phases #$phases
(add-after 'patch-stuff 'use-absolute-efibootmgr-path (add-after 'patch-stuff 'use-absolute-efibootmgr-path
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(substitute* "grub-core/osdep/unix/platform.c" (substitute* "grub-core/osdep/unix/platform.c"
(("efibootmgr") (("efibootmgr")
(search-input-file inputs (search-input-file inputs "/sbin/efibootmgr")))))
"/sbin/efibootmgr")))))
(add-after 'patch-stuff 'use-absolute-mtools-path (add-after 'patch-stuff 'use-absolute-mtools-path
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let ((mtools (assoc-ref inputs "mtools")))
(substitute* "util/grub-mkrescue.c" (substitute* "util/grub-mkrescue.c"
(("\"mformat\"") (("\"mformat\"")
(string-append "\"" mtools (string-append "\""
"/bin/mformat\""))) (search-input-file inputs "/bin/mformat")
"\"")))
(substitute* "util/grub-mkrescue.c" (substitute* "util/grub-mkrescue.c"
(("\"mcopy\"") (("\"mcopy\"")
(string-append "\"" mtools (string-append "\""
"/bin/mcopy\""))) (search-input-file inputs "/bin/mcopy")
#t)))))))))) "\"")))))))))))
(define-public grub-efi32 (define-public grub-efi32
(package (package
@ -425,17 +417,19 @@ menu to select one of the installed operating systems.")
(name "grub-efi32") (name "grub-efi32")
(synopsis "GRand Unified Boot loader (UEFI 32bit version)") (synopsis "GRand Unified Boot loader (UEFI 32bit version)")
(arguments (arguments
`(,@(substitute-keyword-arguments (package-arguments grub-efi) (substitute-keyword-arguments (package-arguments grub-efi)
((#:configure-flags flags ''()) ((#:configure-flags flags #~'())
`(cons* #~(cons* #$@(cond ((target-x86?)
,@(cond ((target-x86?) '("--target=i386")) #~("--target=i386"))
((target-aarch64?) ((target-aarch64?)
(list "--target=arm" #~("--target=arm"
(string-append "TARGET_CC=" (string-append "TARGET_CC="
(cc-for-target "arm-linux-gnueabihf")))) #$(cc-for-target
((target-arm?) '("--target=arm")) "arm-linux-gnueabihf"))))
(else '())) ((target-arm?)
,flags))))) #~("--target=arm"))
(else #~()))
#$flags))))
(native-inputs (native-inputs
(if (target-aarch64?) (if (target-aarch64?)
(modify-inputs (package-native-inputs grub-efi) (modify-inputs (package-native-inputs grub-efi)
@ -459,24 +453,26 @@ menu to select one of the installed operating systems.")
(prepend grub))) (prepend grub)))
(arguments (arguments
(substitute-keyword-arguments (package-arguments grub-efi) (substitute-keyword-arguments (package-arguments grub-efi)
((#:modules modules `((guix build utils) (guix build gnu-build-system))) ((#:modules modules `((guix build utils)
(guix build gnu-build-system)))
`((ice-9 ftw) ,@modules)) `((ice-9 ftw) ,@modules))
((#:phases phases) ((#:phases phases)
`(modify-phases ,phases #~(modify-phases #$phases
(add-after 'install 'install-non-efi (add-after 'install 'install-non-efi
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let ((input-dir (search-input-directory inputs (let ((input-dir (search-input-directory inputs "/lib/grub"))
"/lib/grub"))
(output-dir (string-append (assoc-ref outputs "out") (output-dir (string-append (assoc-ref outputs "out")
"/lib/grub"))) "/lib/grub")))
(for-each (for-each (lambda (basename)
(lambda (basename) (unless (or (string-prefix? "." basename)
(if (not (or (string-prefix? "." basename) (file-exists? (string-append
(file-exists? (string-append output-dir "/" basename)))) output-dir "/"
(symlink (string-append input-dir "/" basename) basename)))
(string-append output-dir "/" basename)))) (symlink (string-append input-dir "/"
(scandir input-dir)) basename)
#t))))))))) (string-append output-dir "/"
basename))))
(scandir input-dir)))))))))))
(define-public (make-grub-efi-netboot name subdir) (define-public (make-grub-efi-netboot name subdir)
"Make a grub-efi-netboot package named NAME, which will be able to boot over "Make a grub-efi-netboot package named NAME, which will be able to boot over