From patchwork Sun Sep 4 17:25:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tiantian X-Patchwork-Id: 42214 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 0A10227BBEA; Sun, 4 Sep 2022 18:30:14 +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 A64EB27BBE9 for ; Sun, 4 Sep 2022 18:30:13 +0100 (BST) Received: from localhost ([::1]:47554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUtRk-0001tH-Sv for patchwork@mira.cbaines.net; Sun, 04 Sep 2022 13:30:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUtRb-0001t2-6l for guix-patches@gnu.org; Sun, 04 Sep 2022 13:30:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUtRa-0004Xa-UI for guix-patches@gnu.org; Sun, 04 Sep 2022 13:30:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oUtRa-0007Eu-J9 for guix-patches@gnu.org; Sun, 04 Sep 2022 13:30:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57496] [PATCH v4 3/3] gnu: bootloader: Add a friendly error message of menu-entry. Resent-From: typ22@foxmail.com Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Sep 2022 17: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: julien@lepiller.eu, tiantian Received: via spool by 57496-submit@debbugs.gnu.org id=B57496.166231256827767 (code B ref 57496); Sun, 04 Sep 2022 17:30:02 +0000 Received: (at 57496) by debbugs.gnu.org; 4 Sep 2022 17:29:28 +0000 Received: from localhost ([127.0.0.1]:45614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUtR2-0007Dm-28 for submit@debbugs.gnu.org; Sun, 04 Sep 2022 13:29:28 -0400 Received: from out162-62-57-210.mail.qq.com ([162.62.57.210]:56531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUtQz-0007DX-Es for 57496@debbugs.gnu.org; Sun, 04 Sep 2022 13:29:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1662312557; bh=y5FL3/YpA00By7lLx1rsn4VGNNfjdzZGgiu+KWPet1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=emjDoKk5LKmj8dJZV3adXWe4zEpKOsoPSk3DHTJa6LmqIj+jXpMArGvb4ENlmNn3T gPia3YNSRHz7Iv5fSrmTgstqewNXCKGdXc27s/3mtUly9A6Mxd8TC/1fZAaVXMXqea UtW9laWBg+iwu4jF1N8t3pk1GnDjAJlHzb2WtyAs= Received: from localhost.localdomain ([240e:398:28a4:3121:5ae1:85dd:ab7b:103f]) by newxmesmtplogicsvrsza31.qq.com (NewEsmtp) with SMTP id 6A38201E; Mon, 05 Sep 2022 01:26:35 +0800 X-QQ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e6oGyvCpW1idC2RkA From: typ22@foxmail.com Date: Mon, 5 Sep 2022 01:25:42 +0800 X-OQ-MSGID: <7741d6aa61a1dc699ec7dbbe36065e65fc2d473e.1662308919.git.typ22@foxmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com> References: <09eabac17314272dcb5a8d2dbbbcfb55a05ecea2.1662308919.git.typ22@foxmail.com> 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 (report-menu-entry-error): New procedure. (menu-entry->sexp): Add a call to `report-menu-entry-error'. Co-Authored-By: Julien Lepiller --- v3: The error message like so: guix system: error: invalid menu-entry: #< label: "test" device: # 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* (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