all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: typ22@foxmail.com
To: 57496@debbugs.gnu.org
Cc: tiantian <typ22@foxmail.com>
Subject: [bug#57496] [PATCH 1/2] gnu: bootloader: Extend `<menu-entry>' for chain-loader.
Date: Wed, 31 Aug 2022 13:27:48 +0800	[thread overview]
Message-ID: <tencent_87604459A018DCD6E43EC8095D329EC45F0A@qq.com> (raw)
In-Reply-To: <cover.1661918556.git.typ22@foxmail.com>

From: tiantian <typ22@foxmail.com>

* gnu/bootloader.scm (<menu-entry>)[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* <menu-entry>
   (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 <string>
+  (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
-    (($ <menu-entry> label device mount-point linux linux-arguments initrd #f
-                     ())
+    ;; Fields of <menu-entry> 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.
+    (($ <menu-entry> 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)))
     (($ <menu-entry> 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)))
+    (($ <menu-entry> 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 <menu-entry>
@@ -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)))))
 
 \f
 ;;;
-- 
2.37.2





       reply	other threads:[~2022-08-31  5:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1661918556.git.typ22@foxmail.com>
2022-08-31  5:27 ` typ22 [this message]
2022-08-31  7:18   ` [bug#57496] [PATCH 1/2] gnu: bootloader: Extend `<menu-entry>' for chain-loader Julien Lepiller
2022-08-31  7:45     ` Julien Lepiller
2022-08-31  5:27 ` [bug#57496] [PATCH 2/2] gnu: bootloader: grub: Add support " typ22
     [not found] <55016216-84d9-e2e6-8bf5-0efdfa0e6ac1@foxmail.com>
     [not found] ` <tencent_5A83D61AB20735A116C68CF8008C0A0B3B07@qq.com>
2022-08-31 19:34   ` [bug#57496] [PATCH 1/2] gnu: bootloader: Extend `<menu-entry>' " Julien Lepiller
2022-09-01  2:33     ` tiantian
2022-09-01  2:33       ` tiantian
2022-09-02  1:04       ` tiantian
2022-09-02  1:04         ` tiantian
2022-09-03 20:08           ` Julien Lepiller
2022-09-04 13:09             ` tiantian
2022-09-04 13:09               ` tiantian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_87604459A018DCD6E43EC8095D329EC45F0A@qq.com \
    --to=typ22@foxmail.com \
    --cc=57496@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.