From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id wC6jNiCp5GUcWwAAe85BDQ:P1 (envelope-from ) for ; Sun, 03 Mar 2024 17:45:21 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id wC6jNiCp5GUcWwAAe85BDQ (envelope-from ) for ; Sun, 03 Mar 2024 17:45:20 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=jpoiret.xyz header.s=dkim header.b=dmrQGsWN; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=reject) header.from=jpoiret.xyz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1709484320; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=UkpbJAfJjG5k7AqF4qQfWoKWvFZinFPZ53VMSmJuwe0=; b=ZSRrRTzf5Yt2Cl0PUU+Rp2lHaEnXBg0gduObrIOY4fH0aED7d4aqflJ6iap6NqghX1lzV+ PF+9JM/N4q5IyZ2U4UZkdKqP6Qo3vV7UGpopcwFm6UJOq1/M9OjV/VaVejx13B8sVfuYcK EwXuo/lN2NxMMtk3wBU/4TGe+ZVikMiaUZi3M7T4K0ixdDFdeA3CPu6hSTXN7ShSfUI2Tr 5ztv+5AZEG8N1ylRkRJrUhOy9RT1wI1Kk1ovszYYCKQdOxjm0rA22CZxMWM1PMk7SQIDcC ncL7gXC9QOD/fhVjROkPOC9LNMuyGGqvvjYTsV5qeoESIrefyRNPOCPETK2I0w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=jpoiret.xyz header.s=dkim header.b=dmrQGsWN; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=reject) header.from=jpoiret.xyz ARC-Seal: i=1; s=key1; d=yhetil.org; t=1709484320; a=rsa-sha256; cv=none; b=RZxJGzZbGmPwddXXQG5tt115DEPgp7XuUfL0xg0dwXFzAyJCmpWMXUwisO8xKPdnR6BdKX ScmBEj00lbkTMX5zLK3ZLHJk2mb+z5/C88LF5jqK2OYVwqZTgFqWFlJZqdaywHbcLdovt8 KY+gy+0TQG01Q6v6cr5DV2CWWmD3cF++FxJNHfHP5iHZMEyS3C7YV8jLAPlQkTf/js+VvT rc8uaTKtOrtq6gHyNiaXCc3Lyo5Xov2MKg5HSr613T6izf+o8lT+3QVSujA31IlapoFyQ1 7JyhWPm+KGND/1hNc4twcR6RF8gpJ4oateDn3BDoylzilwgP4PNLkhyq0k8UDQ== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7079A35128 for ; Sun, 3 Mar 2024 17:45:20 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgov0-0005wr-2I; Sun, 03 Mar 2024 11:42:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgouv-0005wE-9G for guix-devel@gnu.org; Sun, 03 Mar 2024 11:42:25 -0500 Received: from jpoiret.xyz ([206.189.101.64]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgouq-0006Su-Kr for guix-devel@gnu.org; Sun, 03 Mar 2024 11:42:23 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 5E5A6185461; Sun, 3 Mar 2024 16:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1709484138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UkpbJAfJjG5k7AqF4qQfWoKWvFZinFPZ53VMSmJuwe0=; b=dmrQGsWN1pxQThjdPe9DEojRIUylNdQBhJv6iKRzQTJlEhJdVuzD/NAUfR3sCmp/4I7FAE NQbKS5FeUfQz2jwc8p6YpF8+F5d/+w4nmHE30kBqLAjs/my+vhQEYNGkL91WMCSFNNQhPb XtuYdI+rbVbNwL1kvAMsb8cejW8Lw4qPwqqlE5fxcJEyEYoY+DomnGahCGxD3w4+fJAKKL 0bCbh4FBCziRk/l3t9fWCsQCdexmr1u8VoNDI7cVNuUedgaqSumNTDHc0em+8VBAOsD/XY 9hTO+f5NMcqgSPTWNGWl7it/pYuEJ/2OYOTXIAwvvGzCMHwegKeIdtRmFUVtZw== From: Josselin Poiret To: Fabio Natali , Josselin Poiret Cc: guix-devel@gnu.org, Oleg Pykhalov , Felix Lechner Subject: [PATCH 2/2] gnu: grub: Modernize. Date: Sun, 3 Mar 2024 17:42:14 +0100 Message-ID: In-Reply-To: <87bk7vhett.fsf@fabionatali.com> References: <87bk7vhett.fsf@fabionatali.com> MIME-Version: 1.0 X-Debbugs-Cc: Efraim Flashner , Vagrant Cascadian Content-Transfer-Encoding: 8bit X-Spamd-Bar: ++++++ Received-SPF: pass client-ip=206.189.101.64; envelope-from=dev@jpoiret.xyz; helo=jpoiret.xyz X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: 0.52 X-Spam-Score: 0.52 X-Migadu-Queue-Id: 7079A35128 X-TUID: DBLq5+tFftmz From: Josselin Poiret * 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