From patchwork Wed Aug 31 05:27:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42085 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 CFB0827BBEA; Wed, 31 Aug 2022 06:30:49 +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 3CD0A27BBE9 for ; Wed, 31 Aug 2022 06:30:49 +0100 (BST) Received: from localhost ([::1]:52596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTGJM-0000bg-DX for patchwork@mira.cbaines.net; Wed, 31 Aug 2022 01:30:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTGId-0000a7-0u for guix-patches@gnu.org; Wed, 31 Aug 2022 01:30:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTGIc-0005N2-OF for guix-patches@gnu.org; Wed, 31 Aug 2022 01:30:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oTGIc-0004Oo-KL for guix-patches@gnu.org; Wed, 31 Aug 2022 01:30:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH 1/2] gnu: bootloader: Extend `' for chain-loader. Resent-From: typ22@foxmail.com Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 31 Aug 2022 05: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: tiantian Received: via spool by 57496-submit@debbugs.gnu.org id=B57496.166192376616823 (code B ref 57496); Wed, 31 Aug 2022 05:30:02 +0000 Received: (at 57496) by debbugs.gnu.org; 31 Aug 2022 05:29:26 +0000 Received: from localhost ([127.0.0.1]:37964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oTGI2-0004NC-8s for submit@debbugs.gnu.org; Wed, 31 Aug 2022 01:29:26 -0400 Received: from out203-205-251-53.mail.qq.com ([203.205.251.53]:44151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oTGHy-0004Ml-On for 57496@debbugs.gnu.org; Wed, 31 Aug 2022 01:29:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1661923753; bh=YvBUoWlPOQpN6m/Zs0gmk08A/wr8imaac6gY2QgvJFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pbLOFxGjw+msaB3gRNa8tuymN4+hVjBsw8lFQZ1IxWp1B4BiyTYpqijOaEnjVunpb +BCIKNy41zoXiONzpuKsRkJ30ysiURsk2LO6FATqNpACPOz09jYA4MksovKD9XVSJw yUjxPwx6GDdaAeQc0KcL4jbcflnx1BkiF+HFH4FY= Received: from localhost.localdomain ([240e:398:28aa:8901:2e5d:53be:47ef:3da]) by newxmesmtplogicsvrszc13.qq.com (NewEsmtp) with SMTP id 74C1A441; Wed, 31 Aug 2022 13:29:12 +0800 X-QQ-mid: xmsmtpt1661923752t6meqwzqw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 X-OQ-MSGID: <1216b5f648977e9fdc39f94215d4d8226d2b42df.1661918557.git.typ22@foxmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: 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. --- doc/guix.texi | 15 +++++++++++++++ gnu/bootloader.scm | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 957b9a668e..69dcd9e7b9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -37536,6 +37536,21 @@ Bootloader Configuration @dots{})) @end lisp +@item @code{chain-loader} (default: @code{#f}) +A string that any accepted by @code{chainloader}. If there are items +other than @code{label} and @code{device}, it will have no effect. + +@lisp +(bootloader + (bootloader-configuration + ;; @dots{} + (menu-entries + (list + (menu-entry + (label "GNU/Linux") + (chain-loader "(hd0,gpt1)/EFI/GNULinux/grubx64.efi")))))) +@end lisp + @end table @end deftp diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 77c05e8946..41f690a4dc 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,11 @@ (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 +121,15 @@ (define (menu-entry->sexp entry) `(label ,(file-system-label->string label))) (_ device))) (match entry - (($ label device mount-point linux linux-arguments initrd #f - ()) + ;; Fields of in the patterns is incomplete, + ;; resulting in menu-entry with chain-loader incorrectly + ;; matching the first. + ;; To keep pattern is short and keep matching order, + ;; judge an important field in each pattern. + ;; Such as kernel. + (($ label device mount-point + (? identity linux) linux-arguments initrd + #f ()) `(menu-entry (version 0) (label ,label) (device ,(device->sexp device)) @@ -127,14 +138,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) `(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 +190,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))))) ;;;