From debbugs-submit-bounces@debbugs.gnu.org Sat May 21 00:17:34 2022 Received: (at 55407-done) by debbugs.gnu.org; 21 May 2022 04:17:34 +0000 Received: from localhost ([127.0.0.1]:40481 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nsGYX-0000sA-Rr for submit@debbugs.gnu.org; Sat, 21 May 2022 00:17:34 -0400 Received: from mail-qk1-f170.google.com ([209.85.222.170]:40953) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nsGYW-0000rv-4Z for 55407-done@debbugs.gnu.org; Sat, 21 May 2022 00:17:32 -0400 Received: by mail-qk1-f170.google.com with SMTP id b200so274795qkc.7 for <55407-done@debbugs.gnu.org>; Fri, 20 May 2022 21:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=RVqaRMtFtsI4IdS1IxJ/HRr021H4xdGlOqxl/0KQ4UM=; b=pQlBIXmE23mmKgTM3CZwMU+j46p0+qDqO44BHX7g6Slu5epvwd8nJIQm1mH5YGkIXE Q/2q+5U2ihERNmQFJKXc+0Nv8wF7q2bS2GHRESW6yaEIAbAXpP5rH05X1Bstbrb/cLtQ C2U+BM+BcoS6jzIARSflCLRE3jm9r/pJEHFE+aV0J5yqWWezyK94cE11VCKAnSYaizXB bLyGImPyKBEZFfqEVJsjK7yOWF3jciUj67Xd/sKwQURKDip5jZFx0Vshgh6QbS3Y3qct zvvLh5FXAMZe7zJSDogVP8JCknkf+xG/mWdqSV2YvcoG68rXoDUVS8HTwKDqBu0HTKAk 5oOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=RVqaRMtFtsI4IdS1IxJ/HRr021H4xdGlOqxl/0KQ4UM=; b=4wZveZr4husNReJgjlgX7TFi/X7myzyU7CnglsYeVlRD7rju7aWQssqs/pd0uZ84TH Y0A5Me3YCvT5NcBJWFbmh0Qa3TeF380Guw6Y0qckGBO6uGqVg9hsVtc1t71FaefvxNkN rvecLBP5A5Ed8ymVVuIUWTEa/ISPdd0CGPKm9V10lh4jnC8/x/kjHRfJGzsjwzsCPdw0 UdqF2kirukIDotkOd4A3E5dRgk/w0KdxwN9nDVUFzVa67KJko+81Bk78scsxe2Z9UUAS RDgDLV9WObe1Ot+IG2I6bfMTCo+Cwf+d0jCTXKQ2OzS35lU+E0VjpOb+QUaDthsPiPoD 98xQ== X-Gm-Message-State: AOAM531krHR3LUdU2b4AOqHkem9dfZDOacnBr09Nv4tK5ENv4etRwwb+ +UUG4OgcP42qdC7Ma18rfOD/7iJ5Ntl56A== X-Google-Smtp-Source: ABdhPJzqUltjnguWfBq8rBeqJNgMrjk8KgqWCZgS2GgX5UnIzcR9zkSdWFhyvAJ8ssc5bgnD+mufRw== X-Received: by 2002:a05:620a:400b:b0:6a0:fe03:8053 with SMTP id h11-20020a05620a400b00b006a0fe038053mr8429633qko.674.1653106646326; Fri, 20 May 2022 21:17:26 -0700 (PDT) Received: from hurd (dsl-10-148-238.b2b2c.ca. [72.10.148.238]) by smtp.gmail.com with ESMTPSA id f194-20020a379ccb000000b006a349bfcb02sm846682qke.41.2022.05.20.21.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 21:17:25 -0700 (PDT) From: Maxim Cournoyer To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#55407: [PATCH] system: Improve warning when using LUKS mapped devices without UUIDs. References: <20220514060532.1011-1-maxim.cournoyer@gmail.com> <87ee0q1sfq.fsf@gnu.org> Date: Sat, 21 May 2022 00:17:25 -0400 In-Reply-To: <87ee0q1sfq.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Wed, 18 May 2022 22:44:57 +0200") Message-ID: <87o7zrbju2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 55407-done Cc: 55407-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Ludovic Court=C3=A8s writes: > Hi! > > Maxim Cournoyer skribis: > >> This corrects two problems with the previous mapped devices warning: >> >> 1. It wasn't clear how to correct the situation. >> 2. The output would be repeated twice, as the procedure is called >> twice during a system reconfigure. >> >> * gnu/system.scm (operating-system-bootloader-crypto-devices): Memoize >> procedure. Produce a single message for the combined problematic device= s. >> Add a hint to help users fix the warning. > > [...] > >> +(define operating-system-bootloader-crypto-devices >> + (mlambda (os) ;to avoid duplicated output > > Should be =E2=80=98mlambdaq=E2=80=99 so that OS is compared with =E2=80= =98eq?=E2=80=99, which is cheaper > and better corresponds to what we want to achieve here. Done. >> + (receive (uuid-crypto-devices non-uuid-crypto-devices) >> + (partition (compose uuid? mapped-device-source) luks-devices) > > I suggest using =E2=80=98let=E2=80=99 from (srfi srfi-71) for consistency. Done. >> + (when (not (null? non-uuid-crypto-devices)) >> + (warning (N_ "\ >> +the following mapped device may not be mounted by the bootloader: ~s >> +hint: specify the mapped device source via its LUKS UUID.~%" >> + "\ >> +the following mapped devices may not be mounted by the bootloader: ~s >> +hint: specify the mapped device sources via their LUKS UUID.~%" >> + (length non-uuid-crypto-devices)) >> + (map mapped-device-source non-uuid-crypto-devices))) > > By convention, warnings should fit on a single line and not be full > sentences. This is a Guix-specific convention, right? I couldn't find a reference to it in the GNU Standards (info standards) document. I'd be more of the thinking that warnings directed at *users* should be as human readable as possible; the motivation for my fix was because that for more than a year, I read that warning without having clue about what it really meant and had to review the source to get the answer. > If we emit one warning per mapped device, we can report the source > location using: > > (warning (mapped-device-location dev) (G_ "mapped device =E2=80=A6")) > > Given that we have location info, it might be better to report one > warning per device? Done! > Last, hints should be reported either with =E2=80=98display-hint=E2=80=99= or with a > =E2=80=98&fix-hint=E2=80=99 exception. The hint itself can be one or two= paragraphs > using Texinfo markup. > > All this should ensure consistent diagnostic reporting. > > I hope this makes sense! It does. I didn't know about warning accepting the location like that, and I thought hints were only usable via conditions, so I've learned a couple new things here. With the following changes: --8<---------------cut here---------------start------------->8--- modified gnu/system.scm @@ -43,6 +43,7 @@ (define-module (gnu system) #:use-module ((guix utils) #:select (substitute-keyword-arguments)) #:use-module (guix i18n) #:use-module (guix diagnostics) + #:use-module (guix ui) #:use-module (gnu packages admin) #:use-module (gnu packages base) #:use-module (gnu packages bash) @@ -81,11 +82,11 @@ (define-module (gnu system) #:use-module (gnu system mapped-devices) #:use-module (ice-9 format) #:use-module (ice-9 match) - #:use-module (ice-9 receive) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) + #:use-module (srfi srfi-71) #:use-module (rnrs bytevectors) #:export (operating-system operating-system? @@ -604,25 +605,25 @@ (define (operating-system-boot-mapped-devices os) devices))) (define operating-system-bootloader-crypto-devices - (mlambda (os) ;to avoid duplicated output + (mlambdaq (os) ;to avoid duplicated output "Return the sources of the LUKS mapped devices specified by UUID." ;; XXX: Device ordering is important, we trust the returned one. - (let ((luks-devices (filter (lambda (m) - (eq? luks-device-mapping - (mapped-device-type m))) - (operating-system-boot-mapped-devices os))= )) - (receive (uuid-crypto-devices non-uuid-crypto-devices) - (partition (compose uuid? mapped-device-source) luks-devices) - (when (not (null? non-uuid-crypto-devices)) - (warning (N_ "\ -the following mapped device may not be mounted by the bootloader: ~s -hint: specify the mapped device source via its LUKS UUID.~%" - "\ -the following mapped devices may not be mounted by the bootloader: ~s -hint: specify the mapped device sources via their LUKS UUID.~%" - (length non-uuid-crypto-devices)) - (map mapped-device-source non-uuid-crypto-devices))) - (map mapped-device-source uuid-crypto-devices))))) + (let* ((luks-devices (filter (lambda (m) + (eq? luks-device-mapping + (mapped-device-type m))) + (operating-system-boot-mapped-devices os)= )) + (uuid-crypto-devices non-uuid-crypto-devices + (partition (compose uuid? mapped-device-so= urce) + luks-devices))) + (when (not (null? non-uuid-crypto-devices)) + (for-each (lambda (dev) + (warning + (source-properties->location (mapped-device-location = dev)) + (G_ "mapped device '~a' may be ignored by bootloader~= %") + (mapped-device-source dev))) + non-uuid-crypto-devices) + (display-hint "Specify mapped device sources via their LUKS UUID."= )) + (map mapped-device-source uuid-crypto-devices)))) (define (device-mapping-services os) "Return the list of device-mapping services for OS as a list." --8<---------------cut here---------------end--------------->8--- It produced this output: --8<---------------cut here---------------start------------->8--- /home/maxim/stow/guix/hurd.scm:109:8: warning: mapped device '/dev/sda2' ma= y be ignored by bootloader /home/maxim/stow/guix/hurd.scm:113:8: warning: mapped device '/dev/sdb2' ma= y be ignored by bootloader /home/maxim/stow/guix/hurd.scm:117:8: warning: mapped device '/dev/sdc2' ma= y be ignored by bootloader hint: Specify mapped device sources via their LUKS UUID. updating checkout of 'file:///home/maxim/src/mcron'... retrieved commit a233aab1b6770bece7538cda8381df824b7560b6 --8<---------------cut here---------------end--------------->8--- which compares favorably to before the change: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix system reconfigure ~/stow/guix/hurd.scm guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. updating checkout of 'file:///home/maxim/src/mcron'... retrieved commit a233aab1b6770bece7538cda8381df824b7560b6 guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. updating checkout of 'file:///home/maxim/src/mcron'... retrieved commit a233aab1b6770bece7538cda8381df824b7560b6 substitute: updating substitutes from 'http://127.0.0.1:8181'... 100.0% [...] activating system... guix system: warning: mapped-device '/dev/sda2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdb2' may not be mounted by the b= ootloader. guix system: warning: mapped-device '/dev/sdc2' may not be mounted by the b= ootloader. [...] --8<---------------cut here---------------end--------------->8--- Pushed as 39a9404c99. Thanks for the useful comments! Maxim