From patchwork Tue Feb 7 06:35:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Karrmann X-Patchwork-Id: 46722 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 3D36827BBED; Tue, 7 Feb 2023 06:36:33 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS autolearn=ham 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 48D4C27BBE9 for ; Tue, 7 Feb 2023 06:36:31 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPHaJ-0005vo-Oa; Tue, 07 Feb 2023 01:36:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPHaF-0005v7-6Z for guix-patches@gnu.org; Tue, 07 Feb 2023 01:36:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pPHaE-00027l-Uk for guix-patches@gnu.org; Tue, 07 Feb 2023 01:36:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pPHaE-00043k-HH for guix-patches@gnu.org; Tue, 07 Feb 2023 01:36:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59619] [PATCH] grub-configfile References: In-Reply-To: Resent-From: Stefan Karrmann Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 07 Feb 2023 06:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59619 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59619@debbugs.gnu.org Received: via spool by 59619-submit@debbugs.gnu.org id=B59619.167575172815559 (code B ref 59619); Tue, 07 Feb 2023 06:36:02 +0000 Received: (at 59619) by debbugs.gnu.org; 7 Feb 2023 06:35:28 +0000 Received: from localhost ([127.0.0.1]:50841 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPHZf-00042s-7o for submit@debbugs.gnu.org; Tue, 07 Feb 2023 01:35:28 -0500 Received: from mout.web.de ([212.227.15.4]:33587) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pPHZc-00042f-Ff for 59619@debbugs.gnu.org; Tue, 07 Feb 2023 01:35:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1675751718; bh=XDDlfh+WFcQhqhKgL8Kt3ugZbrt4oxgTr8HWgNzjqSc=; h=X-UI-Sender-Class:Date:From:To:Subject; b=BQ5GoaEQZQYNd26QK1moJ9bhSq36NcwI5qv54WvqWk5g8JNYP3oK5Ikgwu+C99YkT OoCmArYNagoJV5bitMFTL5nMAuvYnylskJ0k2mk2fhir8p12HUu0rAPgqNJAZ/wqWo X+RZxzRIBhiAfQlvxdZC/KBTug/EYuY7qICBLwl4fKTMUDV3rrYzxV/0Gm+NL63pKW RA0vtW2EV8z/ST8aG3LrJN8+YFYJT/MXlE1V0f2K+oMQFrTPqPrglzis+6/3M+a5Uw cNtej5JUUuQILfJUvel6Nx7Z8VE4Wf94Jfy4TU6uAMh4cz6TU7c8RBUUmMu5YVVYNg 3JCqysrdhepAA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from localhost ([188.98.113.37]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N79RI-1oX8qg0GJY-017YLE for <59619@debbugs.gnu.org>; Tue, 07 Feb 2023 07:35:18 +0100 Date: Tue, 7 Feb 2023 07:35:15 +0100 From: Stefan Karrmann Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Provags-ID: V03:K1:ofvCQ/zn1Ei+5HiI2EqMB4p8H/fkI4S34YktZML/MKig+biU37G 8myIgCGXg7ow0aNjpBOG0Ot1XXnBJFkeSPqEuWJb95kDS9wlM87HMG5MNXpv1stchM4Q7YL zFF4nZlsadBoewsaPue40VyHipke9iMNAk1GxSsEr/h454Phujf+iTyNcG39VpasUsN7p13 sctzBGQ4r+rvyHIoZJahA== UI-OutboundReport: notjunk:1;M01:P0:bX1GspFPB30=;e2Kxpn+4BsMnF+MX7K5W2pPyZUT JLDv8m1P75RgYFdNemOQdteKD4coTojmHWGzpOxq/jDxrWK8TUvTXHbM+k+L1CSGHlk2RZ6+5 JzucKt0Cg5pBXRwxjblN1lxpwD9azk0S968SFfai3jV3mKThCkjMTR9XhzK6U16vxZAZfGqhM oVQl/tZNkbCNtObfnpA3pWr6d1Xt2fHoENGAAUiYaN72hwfYUIr3k3aWA2l5EnGYVtqL/oxXI 0MHRs87oyJBbFE21+aORLaWO2/ty/AarhNRkSFjBD454ygRSoUDDcL3HqqldWWWYjb7+4B6ZG g+HPq8ExfZDUdYUljaTxdQDWfe/8EFTooD/eZjHSxKabkEp6NbhmSxI1c4ZLK6ynSK/OK/kcZ a3M9kiM1rUQHtgTOOsqyAyH0EFY0xJ5oznhXw8BTx07WEcBuqpLYO4Sg3KvGl428AR2kI9XkM sREKjyBYDZA3lSTABoRu+/JFnMR8BHvjGs3hKF0VjtqqTChDwIRYomttwcot8A0xBWYP61/4c S8KDHVzx2SwOlzNcyw5HrYusG8U0yddsQCidusoa/pIJR507cLvqK0RdiuklM2sy3/5QLC1up 3Caz1yoqBbNIe2vt8gGo3unGgex0jrYg1InmISiH7cZjGmPiZIqj37MkIFOy2kzfLkBVt/tL+ 85CPdN7qKYVQo/tu1AWvRz+43em8kaarGNxbeOqBsFuSIZQZD4MQD5SyHHpAETLwZ72r4LIQg Ow42mNPNgMQM/+OMqw8g8NZ2vopQsVIHSVnjA3Ox3mnG7rCKRnea9iNWzov8sLpV1vhCKsR30 bNPRHRDqZ0fnRXRuxMzrZ2GW8c1vMnNr9kI/wVWDGKCZknTWnafl5ECEVYaCUXthdClIvVA08 5yVMvnU/K7IUFNtlCj9L88BfV0OJZEWmU3S6wWJ03aFZU10mQ05SbwiVKhU7Ui/H9OmB/2hSB cLOIlQ== 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Dear Julien, now I generated the diff by ~git diff > configfile.diff-patch~ and tested it on commit ~a582d863465990642d331bc05bf073f47fb80908~ by ~git apply configfile.diff-patch~. I hope you can apply it now, even on an updated origin. Kind regards, Stefan diff --git a/doc/guix.texi b/doc/guix.texi index 359c9b7a47..8fb5e0eaa3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -113,6 +113,7 @@ Copyright @copyright{} 2022 Bruno Victal@* Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@* Copyright @copyright{} 2023 Giacomo Leidi@* Copyright @copyright{} 2022 Antero Mejr@* +Copyright @copyright{} 2023 Dr. Stefan Karrmann@* Copyright @copyright{} 2022 Bruno Victal@* Permission is granted to copy, distribute and/or modify this document @@ -6161,7 +6162,7 @@ Transformation Options}) so it should be lossless. @item --profile=@var{profile} @itemx -p @var{profile} -Create an environment containing the packages installed in @var{profile}. +Create an environment containing the packages installed in @var{profile}. Use @command{guix package} (@pxref{Invoking guix package}) to create and manage profiles. @@ -6607,7 +6608,7 @@ interpreted as packages that will be added to the environment directly. @item --profile=@var{profile} @itemx -p @var{profile} -Create an environment containing the packages installed in @var{profile}. +Create an environment containing the packages installed in @var{profile}. Use @command{guix package} (@pxref{Invoking guix package}) to create and manage profiles. @@ -12566,7 +12567,7 @@ candidates, and even to test their impact on packages that depend on them: @example -guix build elogind --with-source=@dots{}/shepherd-0.9.0rc1.tar.gz +guix build elogind --with-source=@dots{}/shepherd-0.9.0rc1.tar.gz @end example @dots{} or to build from a checkout in a pristine environment: @@ -23484,7 +23485,7 @@ created for. Restricts all controllers to the specified transport. @code{'dual} means both BR/EDR and LE are enabled (if supported by the hardware). -Possible values are: +Possible values are: @itemize @bullet @item @@ -38946,6 +38947,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 @@ -40833,7 +40852,7 @@ A clause can have one of the following forms: (@var{field-name} (@var{type} @var{default-value}) @var{documentation}) - + (@var{field-name} (@var{type} @var{default-value}) @var{documentation} @@ -40882,7 +40901,7 @@ A simple serializer procedure could look like this: (define (serialize-boolean field-name value) (let ((value (if value "true" "false"))) #~(string-append #$field-name #$value))) -@end lisp +@end lisp In some cases multiple different configuration records might be defined in the same file, but their serializers for the same type might have to @@ -40900,7 +40919,7 @@ manually specify a custom @var{serializer} for every field. (define (bar-serialize-string field-name value) @dots{}) - + (define-configuration foo-configuration (label (string) @@ -40932,7 +40951,7 @@ macro which is a shorthand of this. (field (string "test") "Some documentation.")) -@end lisp +@end lisp @end deffn @deffn {Scheme Syntax} define-maybe @var{type} @@ -43463,7 +43482,7 @@ down in its dependency graph. As it turns out, GLib does not have a from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0 #1 0x00007ffff608a7d6 in gobject_init_ctor () from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0 -#2 0x00007ffff7fe275a in call_init (l=, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8, +#2 0x00007ffff7fe275a in call_init (l=, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8, env=env@@entry=0x7fffffffcfe8) at dl-init.c:72 #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=) at dl-init.c:118 @@ -43492,7 +43511,7 @@ Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252 #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380 #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493 -#3 0x00007ffff7fe275a in call_init (l=, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088, +#3 0x00007ffff7fe275a in call_init (l=, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088, env=env@@entry=0x7fffffffd0a8) at dl-init.c:72 @dots{} @end example 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 ;;; Copyright © 2022 Josselin Poiret ;;; Copyright © 2022 Reza Alizadeh Majd +;;; Copyright © 2022 Dr. Stefan Karrmann ;;; ;;; 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* (multiboot-modules menu-entry-multiboot-modules (default '())) ; list of multiboot commands, where ; a command is a list of + (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 (($ 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))) (($ 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))) - (($ label device mount-point #f () #f #f () () + (($ 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))) + (($ 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 ;;; Copyright © 2022 Karl Hallsby ;;; Copyright © 2022 Denis 'GNUtoo' Carikli +;;; Copyright © 2022 Dr. Stefan Karrmann ;;; ;;; 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 ;;; Copyright © 2022 Josselin Poiret +;;; Copyright © 2022 Dr. Stefan Karrmann ;;; ;;; 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")