From patchwork Sun Sep 4 17:25:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42212 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 6E30B27BBEA; Sun, 4 Sep 2022 18:27:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C921B27BBE9 for ; Sun, 4 Sep 2022 18:27:10 +0100 (BST) Received: from localhost ([::1]:49920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUtOn-0008BT-VZ for patchwork@mira.cbaines.net; Sun, 04 Sep 2022 13:27:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUtOh-0008BI-05 for guix-patches@gnu.org; Sun, 04 Sep 2022 13:27:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUtOg-0004AW-OH for guix-patches@gnu.org; Sun, 04 Sep 2022 13:27:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUtOg-00079p-Db for guix-patches@gnu.org; Sun, 04 Sep 2022 13:27:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH v4 1/3] gnu: bootloader: Extend `' for chain-loader. References: In-Reply-To: Resent-From: typ22@foxmail.com Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Sep 2022 17:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57496 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57496@debbugs.gnu.org Cc: julien@lepiller.eu, tiantian Received: via spool by 57496-submit@debbugs.gnu.org id=B57496.166231241027495 (code B ref 57496); Sun, 04 Sep 2022 17:27:02 +0000 Received: (at 57496) by debbugs.gnu.org; 4 Sep 2022 17:26:50 +0000 Received: from localhost ([127.0.0.1]:45602 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUtOT-00079O-Lk for submit@debbugs.gnu.org; Sun, 04 Sep 2022 13:26:50 -0400 Received: from out162-62-57-87.mail.qq.com ([162.62.57.87]:44441) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUtOQ-000797-17 for 57496@debbugs.gnu.org; Sun, 04 Sep 2022 13:26:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1662312397; bh=Q9UgzfBzvnlqxDUpKL0g9usuB3muksaRoIJHLqKKqho=; h=From:To:Cc:Subject:Date; b=lPvzro+/oDbynFPBFpC4aEml797dTjmrUvZZziBG70x55l5xDFsk+WCZGOT2m9lst AeQBKP1MK+XwWd4p170fy+OoHlVTYF7zMnkTYvwN/oyF3wIN2wJqP2A9R4Bd02QXhP vLgSvDhAwsQgzdW1C5Wr7w6wSawopTnLWURggj9s= Received: from localhost.localdomain ([240e:398:28a4:3121:5ae1:85dd:ab7b:103f]) by newxmesmtplogicsvrsza31.qq.com (NewEsmtp) with SMTP id 6A38201E; Mon, 05 Sep 2022 01:26:35 +0800 X-QQ-mid: xmsmtpt1662312395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: <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: tiantian * gnu/bootloader.scm ()[chain-loader]: New field. (menu-entry->sexp, sexp->menu-entry): Support chain-loader. * doc/guix.texi (Bootloader Configuration): Document it. Co-Authored-By: Julien Lepiller --- v2: Correct the document and specify all fields of in the pattern of menu-entry->sexp. Now still judge linux, multiboot-kernel and chain-loader. Because if don't judge, the menu-entry that all of linux, linux-multiboot and chainloader are #f will match the first one. Then produce Error message: guix system: error: #: invalid G-expression input This error message does not help. v3: correct the document and delete an extra blank line. v4: Add check for initrd in menu-entry->sexp, which is a change moved from the third patch of v3. all: The documents are mainly corrected by Julien Lepiller. Thank you here. doc/guix.texi | 18 ++++++++++++++++++ gnu/bootloader.scm | 33 +++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 6 deletions(-) base-commit: 6beadc82df204f315d06ea35f2e232bb32f8e440 diff --git a/doc/guix.texi b/doc/guix.texi index 957b9a668e..cc64a7ed70 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -37536,6 +37536,24 @@ Bootloader Configuration @dots{})) @end lisp +@item @code{chain-loader} (default: @code{#f}) +A string that can be accepted by @code{grub}'s @code{chainloader} +directive. This has no effect if either @code{linux} or +@code{multiboot-kernel} fields are specified. The following is an +example of chainloading a different GNU/Linux system. + +@lisp +(bootloader + (bootloader-configuration + ;; @dots{} + (menu-entries + (list + (menu-entry + (label "GNU/Linux") + (device (uuid "1C31-A17C" 'fat)) + (chain-loader "/EFI/GNULinux/grubx64.efi")))))) +@end lisp + @end table @end deftp diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 77c05e8946..9fe6b65212 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -46,6 +46,7 @@ (define-module (gnu bootloader) menu-entry-multiboot-kernel menu-entry-multiboot-arguments menu-entry-multiboot-modules + menu-entry-chain-loader menu-entry->sexp sexp->menu-entry @@ -104,8 +105,10 @@ (define-record-type* (multiboot-arguments menu-entry-multiboot-arguments (default '())) ; list of string-valued gexps (multiboot-modules menu-entry-multiboot-modules - (default '()))) ; list of multiboot commands, where + (default '())) ; list of multiboot commands, where ; a command is a list of + (chain-loader menu-entry-chain-loader + (default #f))) ; string, path of efi file (define (menu-entry->sexp entry) "Return ENTRY serialized as an sexp." @@ -117,8 +120,9 @@ (define (menu-entry->sexp entry) `(label ,(file-system-label->string label))) (_ device))) (match entry - (($ label device mount-point linux linux-arguments initrd #f - ()) + (($ label device mount-point + (? identity linux) linux-arguments (? identity initrd) + #f () () #f) `(menu-entry (version 0) (label ,label) (device ,(device->sexp device)) @@ -127,14 +131,22 @@ (define (menu-entry->sexp entry) (linux-arguments ,linux-arguments) (initrd ,initrd))) (($ label device mount-point #f () #f - multiboot-kernel multiboot-arguments multiboot-modules) + (? identity multiboot-kernel) multiboot-arguments + multiboot-modules #f) `(menu-entry (version 0) (label ,label) (device ,(device->sexp device)) (device-mount-point ,mount-point) (multiboot-kernel ,multiboot-kernel) (multiboot-arguments ,multiboot-arguments) - (multiboot-modules ,multiboot-modules))))) + (multiboot-modules ,multiboot-modules))) + (($ label device mount-point #f () #f #f () () + (? identity chain-loader)) + `(menu-entry (version 0) + (label ,label) + (device ,(device->sexp device)) + (device-mount-point ,mount-point) + (chain-loader ,chain-loader))))) (define (sexp->menu-entry sexp) "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a @@ -171,7 +183,16 @@ (define (sexp->menu-entry sexp) (device-mount-point mount-point) (multiboot-kernel multiboot-kernel) (multiboot-arguments multiboot-arguments) - (multiboot-modules multiboot-modules))))) + (multiboot-modules multiboot-modules))) + (('menu-entry ('version 0) + ('label label) ('device device) + ('device-mount-point mount-point) + ('chain-loader chain-loader) _ ...) + (menu-entry + (label label) + (device (sexp->device device)) + (device-mount-point mount-point) + (chain-loader chain-loader))))) ;;; From patchwork Sun Sep 4 17:25:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42213 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9B46A27BBE9; Sun, 4 Sep 2022 18:28:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id F1DEF27BBEA for ; Sun, 4 Sep 2022 18:28:14 +0100 (BST) Received: from localhost ([::1]:46234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUtPq-0000Wu-4t for patchwork@mira.cbaines.net; Sun, 04 Sep 2022 13:28:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUtPe-0000Ve-Jl for guix-patches@gnu.org; Sun, 04 Sep 2022 13:28:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUtPe-0004Lg-BQ for guix-patches@gnu.org; Sun, 04 Sep 2022 13:28:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUtPe-0007Bj-5B for guix-patches@gnu.org; Sun, 04 Sep 2022 13:28:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH v4 2/3] gnu: bootloader: grub: Add support for chain-loader. Resent-From: typ22@foxmail.com Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Sep 2022 17:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57496 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57496@debbugs.gnu.org Cc: julien@lepiller.eu, tiantian Received: via spool by 57496-submit@debbugs.gnu.org id=B57496.166231246727591 (code B ref 57496); Sun, 04 Sep 2022 17:28:02 +0000 Received: (at 57496) by debbugs.gnu.org; 4 Sep 2022 17:27:47 +0000 Received: from localhost ([127.0.0.1]:45606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUtPP-0007Ax-6X for submit@debbugs.gnu.org; Sun, 04 Sep 2022 13:27:47 -0400 Received: from out162-62-57-64.mail.qq.com ([162.62.57.64]:39021) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUtPN-0007Ag-25 for 57496@debbugs.gnu.org; Sun, 04 Sep 2022 13:27:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1662312455; bh=K2KEaGF1Z/wq2RfdW16B7Tvop2xEYaIG+A5AOK+vmwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ef2LnPLnywuTMa07Uj87e3TSSER96E3oSjoTGtrBH4M7wmviim9+eiQyfBGTp5H9a rvS0kZ8946ryexqRE/sntQtLxPfboRLeg6igyxLy1cDYv6Y7KnCPpJ4oHyAHgn39Ib 4qxQARHsJmb1IJ//+GGu3dIL+PyzRxA6g7gFr8zg= Received: from localhost.localdomain ([240e:398:28a4:3121:5ae1:85dd:ab7b:103f]) by newxmesmtplogicsvrsza31.qq.com (NewEsmtp) with SMTP id 6A38201E; Mon, 05 Sep 2022 01:26:35 +0800 X-QQ-mid: xmsmtpt1662312397tnp5mmfky Message-ID: X-QQ-XMAILINFO: OXimaFo5SPf+NIPIPZcNdpymtPUPrBm8pz/q01R7jkuqWj0QG9TOM3Ro6R4boY NyAGSt3HJmTb41lkbFMzn8oyu0lr2FKDbQU3lzFD14tiRi2DBYgIxRPkmH0yhdHAE/bOrWQ6arX9 WmVlnC7Bgly6Qs+GmzXxD9d19PuurwSfKtSu/2Fhx+ogecrRdMb0Z8Ca4iitghcy/1Xbdncq5dGY b2EEkpxhabDYCdo4G/pA6hiREjnSH+a03WtQp9jzBhSzL+TtZTethHNX2DExs91/5H13tNSwh1bQ 7PmN1d86CoKMK+LExIDfWhYH7XnXq9ppI8DCdZXXBXneLmLNSdadfFp+K/SKPkd7YevkdfODFv24 kDCOML1gPTqCvRcdio7v4xwRdufujvzukESRdYeZ4/gcxfZDbh9NFMMa10OkfDTBCial+WTpf24B jg4+llRRvS/VbC8Vfjo5lCNFoH3ceXZX73lzhwmOSywsUtdgluu3lcrCMWKW7fezE74lOF4nLyU4 Ful3KRo9e+N1qUrV4xyHLiqPcVmTNy279gcj6i5i2M1j0YWS49EYqSDZYZwzJcD7fHiV+V+xIZKv pGcYerxsc0ThimttrYwd2wKLSMnYhmEx+cXkh9E7/u+uB8aknWsvD/A8Sxk33q51adkKHy7vKxKE Qj222vVvcE9g60QzpmDhgqisB9jeoyMjt+WUf2kt+HWt/nlbIUAdDR4NK6s/+Far8A+SM/hldO/k tdDQguqAN7+b8t6JylwzfY1a5kpxvcmDOt8XrtHjTKxV6Tu0dWthS7RQyBwh8AS3N5SxhtIwR+V9 n75u1xhpkTDT0mswTSLXu6gWKjnfNIYtCLG3pT3a7DID6cKLoqv8nk79mNal8derNb1B0MUhIbPd khorm5Jp7qibr6ji7xII1agQBg1QVPmLKJHgcWrC13fuWkqWk+jKFyEE0XbE/1yWz3aICVroaDY4 GobcxDHzXhV24rFzTVQd9rmuyydDIzdGJPmkt4IwoBe1y0lvuzqQ== From: typ22@foxmail.com Date: Mon, 5 Sep 2022 01:25:40 +0800 X-OQ-MSGID: X-Mailer: git-send-email 2.37.2 In-Reply-To: <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com> References: <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: tiantian * gnu/bootloader/grub.scm (grub-configuration-file): Add support for chain-loader. --- It is no different from v3 patch. gnu/bootloader/grub.scm | 73 ++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 4f18c9b518..7283257354 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -374,44 +374,57 @@ (define* (grub-configuration-file config entries (let ((label (menu-entry-label entry)) (linux (menu-entry-linux entry)) (device (menu-entry-device entry)) - (device-mount-point (menu-entry-device-mount-point entry))) - (if linux - (let ((arguments (menu-entry-linux-arguments entry)) - (linux (normalize-file linux - device-mount-point - store-directory-prefix)) - (initrd (normalize-file (menu-entry-initrd entry) - device-mount-point - store-directory-prefix))) - ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point. - ;; Use the right file names for LINUX and INITRD in case - ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a - ;; separate partition. - - ;; When BTRFS-SUBVOLUME-FILE-NAME is defined, prepend it the linux and - ;; initrd paths, to allow booting from a Btrfs subvolume. - #~(format port "menuentry ~s { + (device-mount-point (menu-entry-device-mount-point entry)) + (multiboot-kernel (menu-entry-multiboot-kernel entry)) + (chain-loader (menu-entry-chain-loader entry))) + (cond + (linux + (let ((arguments (menu-entry-linux-arguments entry)) + (linux (normalize-file linux + device-mount-point + store-directory-prefix)) + (initrd (normalize-file (menu-entry-initrd entry) + device-mount-point + store-directory-prefix))) + ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point. + ;; Use the right file names for LINUX and INITRD in case + ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a + ;; separate partition. + + ;; When BTRFS-SUBVOLUME-FILE-NAME is defined, prepend it the linux and + ;; initrd paths, to allow booting from a Btrfs subvolume. + #~(format port "menuentry ~s { ~a linux ~a ~a initrd ~a }~%" - #$label - #$(grub-root-search device linux) - #$linux (string-join (list #$@arguments)) - #$initrd)) - (let ((kernel (menu-entry-multiboot-kernel entry)) - (arguments (menu-entry-multiboot-arguments entry)) - (modules (menu-entry-multiboot-modules entry)) - (root-index 1)) ; XXX EFI will need root-index 2 - #~(format port " + #$label + #$(grub-root-search device linux) + #$linux (string-join (list #$@arguments)) + #$initrd))) + (multiboot-kernel + (let ((kernel (menu-entry-multiboot-kernel entry)) + (arguments (menu-entry-multiboot-arguments entry)) + (modules (menu-entry-multiboot-modules entry)) + (root-index 1)) ; XXX EFI will need root-index 2 + #~(format port " menuentry ~s { multiboot ~a root=device:hd0s~a~a~a +}~%" + #$label + #$kernel + #$root-index (string-join (list #$@arguments) " " 'prefix) + (string-join (map string-join '#$modules) + "\n module " 'prefix)))) + (chain-loader + #~(format port " +menuentry ~s { + ~a + chainloader ~a }~%" #$label - #$kernel - #$root-index (string-join (list #$@arguments) " " 'prefix) - (string-join (map string-join '#$modules) - "\n module " 'prefix)))))) + #$(grub-root-search device chain-loader) + #$chain-loader))))) (define (crypto-devices) (define (crypto-device->cryptomount dev) From patchwork Sun Sep 4 17:25:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42214 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0A10227BBEA; Sun, 4 Sep 2022 18:30:14 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A64EB27BBE9 for ; Sun, 4 Sep 2022 18:30:13 +0100 (BST) Received: from localhost ([::1]:47554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUtRk-0001tH-Sv for patchwork@mira.cbaines.net; Sun, 04 Sep 2022 13:30:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUtRb-0001t2-6l for guix-patches@gnu.org; Sun, 04 Sep 2022 13:30:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUtRa-0004Xa-UI for guix-patches@gnu.org; Sun, 04 Sep 2022 13:30:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUtRa-0007Eu-J9 for guix-patches@gnu.org; Sun, 04 Sep 2022 13:30:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH v4 3/3] gnu: bootloader: Add a friendly error message of menu-entry. Resent-From: typ22@foxmail.com Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Sep 2022 17:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57496 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 57496@debbugs.gnu.org Cc: julien@lepiller.eu, tiantian Received: via spool by 57496-submit@debbugs.gnu.org id=B57496.166231256827767 (code B ref 57496); Sun, 04 Sep 2022 17:30:02 +0000 Received: (at 57496) by debbugs.gnu.org; 4 Sep 2022 17:29:28 +0000 Received: from localhost ([127.0.0.1]:45614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUtR2-0007Dm-28 for submit@debbugs.gnu.org; Sun, 04 Sep 2022 13:29:28 -0400 Received: from out162-62-57-210.mail.qq.com ([162.62.57.210]:56531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUtQz-0007DX-Es for 57496@debbugs.gnu.org; Sun, 04 Sep 2022 13:29:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1662312557; bh=y5FL3/YpA00By7lLx1rsn4VGNNfjdzZGgiu+KWPet1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=emjDoKk5LKmj8dJZV3adXWe4zEpKOsoPSk3DHTJa6LmqIj+jXpMArGvb4ENlmNn3T gPia3YNSRHz7Iv5fSrmTgstqewNXCKGdXc27s/3mtUly9A6Mxd8TC/1fZAaVXMXqea UtW9laWBg+iwu4jF1N8t3pk1GnDjAJlHzb2WtyAs= Received: from localhost.localdomain ([240e:398:28a4:3121:5ae1:85dd:ab7b:103f]) by newxmesmtplogicsvrsza31.qq.com (NewEsmtp) with SMTP id 6A38201E; Mon, 05 Sep 2022 01:26:35 +0800 X-QQ-mid: x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CpW1idC2RkA From: typ22@foxmail.com Date: Mon, 5 Sep 2022 01:25:42 +0800 X-OQ-MSGID: <7741d6aa61a1dc699ec7dbbe36065e65fc2d473e.1662308919.git.typ22@foxmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com> References: <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches From: tiantian * gnu/bootloader.scm (report-menu-entry-error): New procedure. (menu-entry->sexp): Add a call to `report-menu-entry-error'. Co-Authored-By: Julien Lepiller --- v3: The error message like so: guix system: error: invalid menu-entry: #< label: "test" device: # device-mount-point: #f linux: #f linux-arguments: () initrd: #f multiboot-kernel: #f multiboot-arguments: () multiboot-modules: () chain-loader: #f> hint: Please chose only one of: 1. direct boot by specifying fields `linux', `linux-arguments' and `linux-modules', 2. multiboot by specifying fields `multiboot-kernel', `multiboot-arguments' and `multiboot-modules', 3. chain-loader by specifying field `chain-loader'. The code of `report-menu-entry-error' is quoted from Julien Lepiller. Thanks the help from Julien Lepiller. v4: The checks of the lists are cancelled and the check of initrd is moved to the first patch. gnu/bootloader.scm | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 9fe6b65212..da65b9d5d5 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -34,6 +34,8 @@ (define-module (gnu bootloader) #:use-module (guix diagnostics) #:use-module (guix i18n) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-34) + #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:export (menu-entry menu-entry? @@ -110,6 +112,23 @@ (define-record-type* (chain-loader menu-entry-chain-loader (default #f))) ; string, path of efi file +(define (report-menu-entry-error menu-entry) + (raise + (condition + (&message + (message + (format #f (G_ "invalid menu-entry: ~a") menu-entry))) + (&fix-hint + (hint + (G_ "Please chose only one of: +@enumerate +@item direct boot by specifying fields @code{linux}, +@code{linux-arguments} and @code{linux-modules}, +@item multiboot by specifying fields @code{multiboot-kernel}, +@code{multiboot-arguments} and @code{multiboot-modules}, +@item chain-loader by specifying field @code{chain-loader}. +@end enumerate")))))) + (define (menu-entry->sexp entry) "Return ENTRY serialized as an sexp." (define (device->sexp device) @@ -146,7 +165,8 @@ (define (menu-entry->sexp entry) (label ,label) (device ,(device->sexp device)) (device-mount-point ,mount-point) - (chain-loader ,chain-loader))))) + (chain-loader ,chain-loader))) + (_ (report-menu-entry-error entry)))) (define (sexp->menu-entry sexp) "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a