From patchwork Sun Sep 4 14:04:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42204 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 1555427BBEC; Sun, 4 Sep 2022 15:12:17 +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,RCVD_IN_DNSWL_BLOCKED, 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 E589327BBE9 for ; Sun, 4 Sep 2022 15:12:15 +0100 (BST) Received: from localhost ([::1]:37916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUqMB-0005T3-2h for patchwork@mira.cbaines.net; Sun, 04 Sep 2022 10:12:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUqLy-0005QT-Hm for guix-patches@gnu.org; Sun, 04 Sep 2022 10:12:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56656) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUqLy-00030f-9b for guix-patches@gnu.org; Sun, 04 Sep 2022 10:12:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUqLy-00028I-0q for guix-patches@gnu.org; Sun, 04 Sep 2022 10:12:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH v3 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 14:12:01 +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.16623006748133 (code B ref 57496); Sun, 04 Sep 2022 14:12:01 +0000 Received: (at 57496) by debbugs.gnu.org; 4 Sep 2022 14:11:14 +0000 Received: from localhost ([127.0.0.1]:45353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUqLB-000277-TO for submit@debbugs.gnu.org; Sun, 04 Sep 2022 10:11:14 -0400 Received: from out162-62-57-87.mail.qq.com ([162.62.57.87]:46507) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUqL9-00026d-Fd for 57496@debbugs.gnu.org; Sun, 04 Sep 2022 10:11:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1662300662; bh=/38v54AvXd9X7OuutWCFaOGhyI/aaDiJEgK2pAlddnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=v2F53S2S8EOy8ck7A2FGtQ+kVkjaS/gr78q0pDMlZgDAStExc1pNerh95Ms3u4Dqt a4PqjeLIktSbwGcLh9WdbyVdC4nWhOsWExQxJbXTpZDmrEzZtZQ9T7l8nnVEJGJnvP tmyszcWoBPHlr52JjEcqp+iNYAM1EkMN0DVKy9AY= Received: from localhost.localdomain ([240e:398:28a4:3121:5ae1:85dd:ab7b:103f]) by newxmesmtplogicsvrsza7.qq.com (NewEsmtp) with SMTP id 2AE98672; Sun, 04 Sep 2022 22:10:46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un, 4 Sep 2022 22:04:28 +0800 X-OQ-MSGID: <47c28682c4fe87a8ec53bf3c9687c1cf011d880c.1662298270.git.typ22@foxmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <849b9ddea2a18dc4b2fd05450f0c90e3e5a05421.1662298270.git.typ22@foxmail.com> References: <849b9ddea2a18dc4b2fd05450f0c90e3e5a05421.1662298270.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 v2 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 14:04:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42206 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 EC99C27BBEA; Sun, 4 Sep 2022 15:14:13 +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,RCVD_IN_DNSWL_BLOCKED, 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 566AD27BBE9 for ; Sun, 4 Sep 2022 15:14:13 +0100 (BST) Received: from localhost ([::1]:37650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUqO4-0006O4-Hp for patchwork@mira.cbaines.net; Sun, 04 Sep 2022 10:14:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUqNu-0006Nv-Pa for guix-patches@gnu.org; Sun, 04 Sep 2022 10:14:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUqNu-0003Fc-Fb for guix-patches@gnu.org; Sun, 04 Sep 2022 10:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUqNu-0002BF-3S for guix-patches@gnu.org; Sun, 04 Sep 2022 10:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH v3 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 14:14: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.16623008068331 (code B ref 57496); Sun, 04 Sep 2022 14:14:02 +0000 Received: (at 57496) by debbugs.gnu.org; 4 Sep 2022 14:13:26 +0000 Received: from localhost ([127.0.0.1]:45359 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUqNJ-0002AJ-H8 for submit@debbugs.gnu.org; Sun, 04 Sep 2022 10:13:26 -0400 Received: from out162-62-57-64.mail.qq.com ([162.62.57.64]:36331) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUqNF-0002A0-Vm for 57496@debbugs.gnu.org; Sun, 04 Sep 2022 10:13:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1662300791; bh=+hv/+969LXAcQQ5jo+zvptqiwt6JiG5YCxy5zn3y0LY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wEZYSlo/Y60x1hmGpfHOvscMbzv71UrqqlPTdU550EUFSTug5XTtEaMAP8uNiA/W+ t21xclcp3OUifKTXaylNQMVukWjXTubdMToL+YSLe53YT7JEl67j+rk5nLhyzDRcKT ldMtEL9NBxV1QGM+BOw9WlNTETgY8X+PEgW9na6g= Received: from localhost.localdomain ([240e:398:28a4:3121:5ae1:85dd:ab7b:103f]) by newxmesmtplogicsvrsza7.qq.com (NewEsmtp) with SMTP id 2AE98672; Sun, 04 Sep 2022 22:10:46 +0800 X-QQ-mid: xmsmtpt1662300662t6jskf6yh Message-ID: X-QQ-XMAILINFO: OLnGMPzD2sDVHQYTkUhd4dmoQHxhEg7CBxGKgzj+fEHsWRaW9IuUvw5PxsrjrN MoGc4eukysMzsSxEUq4A6ijPRXtHJuAM/9qVdIE/2AQG1Z3Px7DuKz8nLdvDkUrPGCcr482Scdzo zH6TPbiPwFSgH16euJ4cz3/s7YPFr4VMkezccZODsYTKa4u46dSy6Y2gqaQzQL1PXlcRqOKEB26s sdJ3/8njOXpWv7LS0QxMSzOnTyu8fvm6AbYzYbEo/q+4OfwAYMxy5NagbvU7CThR6HChzsoUZGxm ljzoATApQBZbvARi+KVivUy1Hm8YR1+ayhEoFQDCpsQhCFjKuO7bvlL8C8QgEaM5e/clzzpUV+b7 dL3Q4+bIoRTCxLhkrAfDIwMfCow9Bc+kaEmvmEIM/jNmPXayHLvqezLAV8OkGW3VxAKKlssGCCfJ NY+xIos1+Oj6R0v/RWIZJaitvPvIvgG2wBbhmvAj4j6bSGjAU8XaSawY2iQO81ZEaaNtJ2EU4akl XzUvyPLiWZ2CeznaR30kvWdGLRbsrcOKcXw8dK2/4XJOsL+HID5iIK8iRfmFmeTXvXht6CCkaFrW eh1Tlp8/ofbP9Z3nDGR0TNZR4tNZmevV+2XdhjF2N7RVogb62/klEdny7A9cuYj/zotdyZhW2yJX rQ10yO7BTOwamCHT0eIDbYUuqhUkuCr+DHmREPaZ1gMhZ65cLC9ZHcpHDbqtNI7rbvtwLKkZyG6K cnj9d1GlNvgbmUXkZlqHFHApeHTzIz/Z+ij+bpLmAUPxqjgbik0Dsiwk69esbUbdR8JLgS+3t/gF TB0ynrBbjm3VidIx6BoA5CKjCupMb87LXi1FV1y3pKUVeYG8q9Rg1PSWzSU5Fyc0t8cZPSNpx093 OLWqkupEr5o3pR4pz40yo00IkOt2W69jTpdO3E7htIeV/WLBCA7cGlgqcJmhJc6B8zEe5m0uZIPQ FagDL/FqXs5977omdKDQ== From: typ22@foxmail.com Date: Sun, 4 Sep 2022 22:04:31 +0800 X-OQ-MSGID: <35555a74cdf7ec6038b2f37aa1831edcace04c21.1662298270.git.typ22@foxmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <849b9ddea2a18dc4b2fd05450f0c90e3e5a05421.1662298270.git.typ22@foxmail.com> References: <849b9ddea2a18dc4b2fd05450f0c90e3e5a05421.1662298270.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): Modify the pattern and add `else' to call `report-menu-entry-error'. Co-Authored-By: Julien Lepiller --- 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. gnu/bootloader.scm | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 9e8b545d10..d4fe460570 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) @@ -119,9 +138,21 @@ (define (menu-entry->sexp entry) ((? file-system-label? label) `(label ,(file-system-label->string label))) (_ device))) + (define (set-field? field) + "If the field is the default value, return #f." + (and field ; not default value #f + (not (null? field)))) ; not default value '() (match entry + ;; Modify the pattern to achieve more strict matching and prevent + ;; wrong matching, which ensures the output of error information + ;; when menu-entry is wrong. + + ;; The linux-arguments is optional and the test code for boot-parameters + ;; does not set it, so don't check it here. (($ label device mount-point - (? identity linux) linux-arguments initrd + (? set-field? linux) + linux-arguments + (? set-field? initrd) #f () () #f) `(menu-entry (version 0) (label ,label) @@ -131,8 +162,10 @@ (define (menu-entry->sexp entry) (linux-arguments ,linux-arguments) (initrd ,initrd))) (($ label device mount-point #f () #f - (? identity multiboot-kernel) multiboot-arguments - multiboot-modules #f) + (? set-field? multiboot-kernel) + (? set-field? multiboot-arguments) + (? set-field? multiboot-modules) + #f) `(menu-entry (version 0) (label ,label) (device ,(device->sexp device)) @@ -141,12 +174,13 @@ (define (menu-entry->sexp entry) (multiboot-arguments ,multiboot-arguments) (multiboot-modules ,multiboot-modules))) (($ label device mount-point #f () #f #f () () - (? identity chain-loader)) + (? set-field? chain-loader)) `(menu-entry (version 0) (label ,label) (device ,(device->sexp device)) (device-mount-point ,mount-point) - (chain-loader ,chain-loader))))) + (chain-loader ,chain-loader))) + (else (report-menu-entry-error entry)))) (define (sexp->menu-entry sexp) "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a