From: typ22@foxmail.com
To: 57496@debbugs.gnu.org
Cc: julien@lepiller.eu, tiantian <typ22@foxmail.com>
Subject: [bug#57496] [PATCH v4 3/3] gnu: bootloader: Add a friendly error message of menu-entry.
Date: Mon, 5 Sep 2022 01:25:42 +0800 [thread overview]
Message-ID: <tencent_9DEF0F6F42438CADF1F81828161D06093508@qq.com> (raw)
In-Reply-To: <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com>
From: tiantian <typ22@foxmail.com>
* gnu/bootloader.scm (report-menu-entry-error): New procedure.
(menu-entry->sexp): Add a call to `report-menu-entry-error'.
Co-Authored-By: Julien Lepiller <julien@lepiller.eu>
---
v3:
The error message like so:
guix system: error: invalid menu-entry: #<<menu-entry> label: "test" device: #<file-system-label "guix-root"> device-mount-point: #f linux: #f linux-arguments: () initrd: #f multiboot-kernel: #f multiboot-arguments: () multiboot-modules: () chain-loader: #f>
hint: Please chose only one of:
1. direct boot by specifying fields `linux', `linux-arguments' and `linux-modules',
2. multiboot by specifying fields `multiboot-kernel', `multiboot-arguments' and `multiboot-modules',
3. chain-loader by specifying field `chain-loader'.
The code of `report-menu-entry-error' is quoted from Julien Lepiller.
Thanks the help from Julien Lepiller.
v4:
The checks of the lists are cancelled and the check of initrd is moved
to the first patch.
gnu/bootloader.scm | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm
index 9fe6b65212..da65b9d5d5 100644
--- a/gnu/bootloader.scm
+++ b/gnu/bootloader.scm
@@ -34,6 +34,8 @@ (define-module (gnu bootloader)
#:use-module (guix diagnostics)
#:use-module (guix i18n)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-34)
+ #:use-module (srfi srfi-35)
#:use-module (ice-9 match)
#:export (menu-entry
menu-entry?
@@ -110,6 +112,23 @@ (define-record-type* <menu-entry>
(chain-loader menu-entry-chain-loader
(default #f))) ; string, path of efi file
+(define (report-menu-entry-error menu-entry)
+ (raise
+ (condition
+ (&message
+ (message
+ (format #f (G_ "invalid menu-entry: ~a") menu-entry)))
+ (&fix-hint
+ (hint
+ (G_ "Please chose only one of:
+@enumerate
+@item direct boot by specifying fields @code{linux},
+@code{linux-arguments} and @code{linux-modules},
+@item multiboot by specifying fields @code{multiboot-kernel},
+@code{multiboot-arguments} and @code{multiboot-modules},
+@item chain-loader by specifying field @code{chain-loader}.
+@end enumerate"))))))
+
(define (menu-entry->sexp entry)
"Return ENTRY serialized as an sexp."
(define (device->sexp device)
@@ -146,7 +165,8 @@ (define (menu-entry->sexp entry)
(label ,label)
(device ,(device->sexp device))
(device-mount-point ,mount-point)
- (chain-loader ,chain-loader)))))
+ (chain-loader ,chain-loader)))
+ (_ (report-menu-entry-error entry))))
(define (sexp->menu-entry sexp)
"Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry>
--
2.37.2
next prev parent reply other threads:[~2022-09-04 17:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com>
2022-09-04 17:25 ` [bug#57496] [PATCH v4 2/3] gnu: bootloader: grub: Add support for chain-loader typ22
2022-09-04 17:25 ` typ22 [this message]
2022-09-08 20:33 ` bug#57496: [PATCH v4 3/3] gnu: bootloader: Add a friendly error message of menu-entry Julien Lepiller
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=tencent_9DEF0F6F42438CADF1F81828161D06093508@qq.com \
--to=typ22@foxmail.com \
--cc=57496@debbugs.gnu.org \
--cc=julien@lepiller.eu \
/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).