From: "S.Karrmann" <S.Karrmann@web.de>
To: 59619@debbugs.gnu.org
Subject: [bug#59619] [PATCH] grub-configfile tested
Date: Thu, 2 Feb 2023 20:04:21 +0100 [thread overview]
Message-ID: <Y9wJNbyrnrf6ZibV@web.de> (raw)
In-Reply-To: <Y4KBVnUW27vLnYqX@web.de>
now I generated this patch by:
git pull
git format-patch -o patches --ignore-space-at-eol origin/master..HEAD
My Emacs deletes intentionally all space at eol. Therefore, the other patch
may work with:
git apply --whitespace=warn grub-configfile.patch
---
doc/guix.texi | 19 +++++++++++++++++++
gnu/bootloader.scm | 29 +++++++++++++++++++++++++----
gnu/bootloader/grub.scm | 11 +++++++++++
tests/boot-parameters.scm | 11 +++++++++++
4 files changed, 66 insertions(+), 4 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 64873db00b..937f7c54cb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -112,6 +112,7 @@ Copyright @copyright{} 2022 John Kehayias@*
Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
Copyright @copyright{} 2023 Giacomo Leidi@*
Copyright @copyright{} 2022 Antero Mejr@*
+Copyright @copyright{} 2023 Dr. Stefan Karrmann@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -38666,6 +38667,24 @@ The list of commands for loading Multiboot modules. For example:
@dots{}))
@end lisp
+@item @code{config-file} (default: @code{#f})
+A string that can be accepted by @code{grub}'s @code{configfile}
+directive. This has no effect if either @code{linux} or
+@code{multiboot-kernel} fields are specified. The following is an
+example of switching to a different GNU/GRUB menu.
+
+@lisp
+(bootloader
+ (bootloader-configuration
+ ;; @dots{}
+ (menu-entries
+ (list
+ (menu-entry
+ (label "GNU/Linux")
+ (device (uuid "5cbb9a70-a3c8-4384-a085-9e6896058343"))
+ (config-file "/boot/grub/grub.cfg"))))))
+@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
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 2c36d8c6cf..7c24fd2ebf 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2022 Josselin Poiret <dev@jpoiret.xyz>
;;; Copyright © 2022 Reza Alizadeh Majd <r.majd@pantherx.org>
+;;; Copyright © 2022 Dr. Stefan Karrmann <S.Karrmann@web.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -49,6 +50,7 @@ (define-module (gnu bootloader)
menu-entry-multiboot-arguments
menu-entry-multiboot-modules
menu-entry-chain-loader
+ menu-entry-config-file
menu-entry->sexp
sexp->menu-entry
@@ -109,8 +111,10 @@ (define-record-type* <menu-entry>
(multiboot-modules menu-entry-multiboot-modules
(default '())) ; list of multiboot commands, where
; a command is a list of <string>
+ (config-file menu-entry-config-file
+ (default #f)) ; string, path of grub.cfg file
(chain-loader menu-entry-chain-loader
- (default #f))) ; string, path of efi file
+ (default #f))) ; string, path of efi file
(define (report-menu-entry-error menu-entry)
(raise
@@ -126,6 +130,7 @@ (define (report-menu-entry-error menu-entry)
@code{linux-arguments} and @code{linux-modules},
@item multiboot by specifying fields @code{multiboot-kernel},
@code{multiboot-arguments} and @code{multiboot-modules},
+@item config-file by specifying field @code{config-file}.
@item chain-loader by specifying field @code{chain-loader}.
@end enumerate"))))))
@@ -141,7 +146,7 @@ (define (device->sexp device)
(match entry
(($ <menu-entry> label device mount-point
(? identity linux) linux-arguments (? identity initrd)
- #f () () #f)
+ #f () () #f #f)
`(menu-entry (version 0)
(label ,label)
(device ,(device->sexp device))
@@ -151,7 +156,7 @@ (define (device->sexp device)
(initrd ,initrd)))
(($ <menu-entry> label device mount-point #f () #f
(? identity multiboot-kernel) multiboot-arguments
- multiboot-modules #f)
+ multiboot-modules #f #f)
`(menu-entry (version 0)
(label ,label)
(device ,(device->sexp device))
@@ -159,13 +164,20 @@ (define (device->sexp device)
(multiboot-kernel ,multiboot-kernel)
(multiboot-arguments ,multiboot-arguments)
(multiboot-modules ,multiboot-modules)))
- (($ <menu-entry> label device mount-point #f () #f #f () ()
+ (($ <menu-entry> label device mount-point #f () #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)))
+ (($ <menu-entry> label device mount-point #f () #f #f () ()
+ (? identity config-file) #f)
+ `(menu-entry (version 0)
+ (label ,label)
+ (device ,(device->sexp device))
+ (device-mount-point ,mount-point)
+ (config-file ,config-file)))
(_ (report-menu-entry-error entry))))
(define (sexp->menu-entry sexp)
@@ -204,6 +216,15 @@ (define (sexp->device device-sexp)
(multiboot-kernel multiboot-kernel)
(multiboot-arguments multiboot-arguments)
(multiboot-modules multiboot-modules)))
+ (('menu-entry ('version 0)
+ ('label label) ('device device)
+ ('device-mount-point mount-point)
+ ('config-file config-file) _ ...)
+ (menu-entry
+ (label label)
+ (device (sexp->device device))
+ (device-mount-point mount-point)
+ (config-file config-file)))
(('menu-entry ('version 0)
('label label) ('device device)
('device-mount-point mount-point)
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index ecd44e7f3c..7ed0d155d8 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -9,6 +9,7 @@
;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de>
;;; Copyright © 2022 Karl Hallsby <karl@hallsby.com>
;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+;;; Copyright © 2022 Dr. Stefan Karrmann <S.Karrmann@web.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -377,6 +378,7 @@ (define (menu-entry->gexp entry)
(device (menu-entry-device entry))
(device-mount-point (menu-entry-device-mount-point entry))
(multiboot-kernel (menu-entry-multiboot-kernel entry))
+ (config-file (menu-entry-config-file entry))
(chain-loader (menu-entry-chain-loader entry)))
(cond
(linux
@@ -417,6 +419,15 @@ (define (menu-entry->gexp entry)
#$root-index (string-join (list #$@arguments) " " 'prefix)
(string-join (map string-join '#$modules)
"\n module " 'prefix))))
+ (config-file
+ #~(format port "
+menuentry ~s {
+ ~a
+ config-file ~a
+}~%"
+ #$label
+ #$(grub-root-search device config-file)
+ #$config-file))
(chain-loader
#~(format port "
menuentry ~s {
diff --git a/tests/boot-parameters.scm b/tests/boot-parameters.scm
index 03a1d01aff..f2d1453b2c 100644
--- a/tests/boot-parameters.scm
+++ b/tests/boot-parameters.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
;;; Copyright © 2022 Josselin Poiret <dev@jpoiret.xyz>
+;;; Copyright © 2022 Dr. Stefan Karrmann <S.Karrmann@web.de>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -318,6 +319,12 @@ (define %file-system-label-menu-entry
(linux "/boot/bzImage")
(initrd "/boot/initrd.cpio.gz")))
+(define %config-file-menu-entry
+ (menu-entry
+ (label "test-config-file")
+ (device (uuid "6d5b13d4-6092-46d0-8be4-073dc07413cc"))
+ (config-file "/boot/grub/grub.cfg")))
+
(test-equal "menu-entry roundtrip, uuid"
%uuid-menu-entry
(sexp->menu-entry (menu-entry->sexp %uuid-menu-entry)))
@@ -326,4 +333,8 @@ (define %file-system-label-menu-entry
%file-system-label-menu-entry
(sexp->menu-entry (menu-entry->sexp %file-system-label-menu-entry)))
+(test-equal "menu-entry roundtrip, config-file"
+ %config-file-menu-entry
+ (sexp->menu-entry (menu-entry->sexp %config-file-menu-entry)))
+
(test-end "boot-parameters")
--
2.39.1
next prev parent reply other threads:[~2023-02-02 19:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-26 21:12 [bug#59619] [PATCH] grub-configfile Stefan Karrmann
2022-11-26 21:14 ` ( via Guix-patches via
[not found] ` <handler.59619.B.166949718928090.ack@debbugs.gnu.org>
2022-11-26 21:23 ` [bug#59619] Acknowledgement ([PATCH] grub-configfile) Stefan Karrmann
2022-11-26 21:25 ` ( via Guix-patches via
2022-11-26 21:32 ` [bug#59619] [PATCH] grub-configfile Julien Lepiller
2023-01-29 18:33 ` [bug#59619] [PATCH] grub-configfile - guix shell ... ./pre-inst-env Stefan Karrmann
2023-01-31 17:33 ` [bug#59619] [PATCH] grub-configfile tested successfully S.Karrmann
2023-02-02 13:38 ` Julien Lepiller
2023-02-02 19:04 ` S.Karrmann [this message]
2023-02-07 6:35 ` [bug#59619] [PATCH] grub-configfile Stefan Karrmann
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y9wJNbyrnrf6ZibV@web.de \
--to=s.karrmann@web.de \
--cc=59619@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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).