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))))) ;;; From patchwork Wed Aug 31 05:27:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42084 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 0370927BBEA; Wed, 31 Aug 2022 06:30:36 +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 736B427BBE9 for ; Wed, 31 Aug 2022 06:30:35 +0100 (BST) Received: from localhost ([::1]:52594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTGJ5-0000aL-1a for patchwork@mira.cbaines.net; Wed, 31 Aug 2022 01:30:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTGIc-0000Zz-OS for guix-patches@gnu.org; Wed, 31 Aug 2022 01:30:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48215) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oTGIc-0005Mv-AF 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-0004Og-73 for guix-patches@gnu.org; Wed, 31 Aug 2022 01:30:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH 2/2] 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: 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.166192376616817 (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]:37962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oTGI1-0004NA-PI for submit@debbugs.gnu.org; Wed, 31 Aug 2022 01:29:26 -0400 Received: from out203-205-221-245.mail.qq.com ([203.205.221.245]:57648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oTGHy-0004Mn-LF for 57496@debbugs.gnu.org; Wed, 31 Aug 2022 01:29:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1661923754; bh=l3WqtlHsmlayI/r65QJVGOTW9ezhMw6hDkM+AZZ4syM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TB+/I5q1IDcROpeQq5aOH/yNY+ntO8eQEumnBWYWdAMuYAEMLYUZcFVvrortq/uN+ +TyGQS7YBU40JUIU46aVmXphziPoREs+HPyxszCACMwu8y/VHNYFTXGRYK2E6mmA+N fi/bKlCwI2apWX9NTP0ZWVUoOHsVGXiEsRpbwROU= 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: xmsmtpt1661923753txl4feeyn Message-ID: X-QQ-XMAILINFO: NY/MPejODIJVVFZ/t8blm1PLwF0iPCE+SkP0q+o55nayHjDtADX6DB6OEodvg/ 22Zo7iqTABouUWg/pFSskBYZnXgTJUFv3Jk3Dm6+T5+ZCq6RfseVK9BWITVcYFZGuLnP1r10iou0 YoLYPQXtLNSCiikRWcRY4k1lwlfoIMB09sERf7XXNiZzjdZ7VQgrSqe7MJDxURLUngJUJ0h1IsCV Tzil+uOSbOePnclLFUvOLE3EBtMLUokCF7a7HlI5gRphblOgb5x5b+GAeFuDTb0kPzJjHQ1IsgWh 5o/x/RiTXABImIhKUi0uem3ewxF0KaqEL3W330SlUI5voslZ1K4ZldtH56/iDwuXn33I6ml44ca2 iZupPgf1IeOwauhXeO4F7QdWyT1w/bG2J64tYjAItS9rCF+OrpX4nhjVspzE5J1NR0tLpdVtvU7z ZIsOpL3OF6Q2RXYC0dFXS/EcTUS+wmjAUBsYnDjjQQrKhDCCeYKnrZp1RTc5dKYQagkGIV60uDeY 2xs2YaQFasdORcHXaArPhuKPt1DTUnS3Sg9WKxYJ/Fjde9tDBrj/TATUWfKjYMaNlfThVnRCMprB McHt9vWzRdLvPwjOI8icUL9GpSOS0kfh9kJqnGJop/lewyzsy93psg2cAgsk+MFxVunWfE2gdM4r f+an404k3sZyMkXVaPHzUvrQGnsNa9nnLlsCEXV8RjWMNp8GJgg/NqP6MESHXZro9ufma4vzRkib gg86sQVDz+RUfLvZEZxzKLI3Elr3G7mi3ZQaQwCJTI2pAsPvbmoicFiKvxQX0Sjdn2ZQF3tSXUE7 50/LcMopCUOGuPiaGg3EDYA3xXRYTWNrqikSKdAJgvN6rEmhY9vZz3ewpLwXH2PJFRZCkKZXkx5u xsbmedcvYkVod7RzYtvOeZXUyqK0QzEz8XkU+lc9aaLtifrlZktNDNCexuwpLj05VBcIVE+Bw8Pa 10V0+TgXc= From: typ22@foxmail.com Date: Wed, 31 Aug 2022 13:27:49 +0800 X-OQ-MSGID: <24b02b2230f2eeebebbd86ac2048587178e48953.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/grub.scm (grub-configuration-file): Add support for chain-loader. --- 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)