From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id aFVYF6HgFGNRxgAAbAwnHQ (envelope-from ) for ; Sun, 04 Sep 2022 19:30:09 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 8s6HFqHgFGM4EQEAG6o9tA (envelope-from ) for ; Sun, 04 Sep 2022 19:30:09 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2C59F1374 for ; Sun, 4 Sep 2022 19:30:09 +0200 (CEST) Received: from localhost ([::1]:47554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUtRg-0001tH-AS for larch@yhetil.org; Sun, 04 Sep 2022 13:30:08 -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-mid: xmsmtpt1662312455tsdo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22@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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1662312609; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=y5FL3/YpA00By7lLx1rsn4VGNNfjdzZGgiu+KWPet1Y=; b=RRTIHxnU1+bNQOIqzHndeZtfdML40tzwcV3UxTTRTZex0DArhHWA0XVnxyh8VPbUHdtLhT X0yXTOIJFWgL/M+oXKVHy2srW6F/ysp7/YM7obhiQrq7lRVk7CUIG6cZxKMp7qs7Wqm3r5 F523ibwvCFTTknPwtiMFMWXFYaFt6SUPh2KC6zQ9JHik+amGC5fLBYuytry0xhU0DLVaJE B4HuWFGmvbv5sN3FHZ2Hl5/b6sYDy17gp5W3m2RQFxuxY4HaBsx64KVtV5c71MS75zym2F Ar3xChQjrX1ppgUXKn7DxfpdXM8HRFqGIckyoKoUliWq9Ns4w/BQaH+7aXjPwg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662312609; a=rsa-sha256; cv=none; b=Uc5WNCd36dXeAJ83UNMkGmF9ydtcm1024GXv99AmRvV0cGZIi4KFt5BDv95/rLcv78P5Rm yZuVtavxODVC14WXHJEGsPkB/OXFFmsVfERkniGYnXRK6tCmeQbI33c4oN/HYoney61eOn B33bZ6y5ASS11+Atw8pnPfYpt2cQ/OeWMqYdnKlt9eRhgG0sjr61uaaz/1XMbpkrsU1USa B7826h4O+h3fss6eDFx8Noo/8me3RuN0ZUfqnRWWdXHV7yywGokkmeadzQeX4Sck/FM96M zzbGoFcWKAUaZg3BHJJ9DSHWjLRGOBd7pQDevOv3w+EJ4sWw26J5sjpTZawYxw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=foxmail.com header.s=s201512 header.b=emjDoKk5; dmarc=fail reason="SPF not aligned (relaxed)" header.from=foxmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.82 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=foxmail.com header.s=s201512 header.b=emjDoKk5; dmarc=fail reason="SPF not aligned (relaxed)" header.from=foxmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 2C59F1374 X-Spam-Score: 5.82 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6fF0j8fXR1ms 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 -- 2.37.2