From patchwork Sun Sep 4 14:04:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42205 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 A7F5427BBE9; Sun, 4 Sep 2022 15:12:20 +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 47D9027BBEA for ; Sun, 4 Sep 2022 15:12:16 +0100 (BST) Received: from localhost ([::1]:37914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUqMB-0005SG-CG for patchwork@mira.cbaines.net; Sun, 04 Sep 2022 10:12:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUqLy-0005QP-Di for guix-patches@gnu.org; Sun, 04 Sep 2022 10:12:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUqLy-00030e-5h 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 1oUqLx-00028A-Lg for guix-patches@gnu.org; Sun, 04 Sep 2022 10:12:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH v3 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 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.16623006658111 (code B ref 57496); Sun, 04 Sep 2022 14:12:01 +0000 Received: (at 57496) by debbugs.gnu.org; 4 Sep 2022 14:11:05 +0000 Received: from localhost ([127.0.0.1]:45350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUqL3-00026l-DQ for submit@debbugs.gnu.org; Sun, 04 Sep 2022 10:11:05 -0400 Received: from out203-205-251-59.mail.qq.com ([203.205.251.59]:35468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUqKw-000267-RW for 57496@debbugs.gnu.org; Sun, 04 Sep 2022 10:11:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1662300648; bh=G4FEa442sPdPuGY1IG3f0JLxBXg7O63LNy2nI3xq674=; h=From:To:Cc:Subject:Date; b=w/d+0rC/VkUcMdowtRjPogbwAd5iaTuBnyn0RJYiKwD7rRjpLjKSW9Hx5hJiyeS3p rgGJ8sDjPco5J4VZ6OP9CrSuiGb6GDPf3AgirLTUtPDgcIl7Ye+mKOQfDbbdH2aYxX MIP29ye80XC4ndxzby425w3g5TL0AFm8qjkfqyAU= 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: xmsmtpt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0800 X-OQ-MSGID: <849b9ddea2a18dc4b2fd05450f0c90e3e5a05421.1662298270.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. 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..9e8b545d10 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 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))))) ;;;