GNU bug report logs - #65184
(modify-services … (delete …)) should delete all matching service types

Previous Next

Package: guix;

Reported by: Tobias Geerinckx-Rice <me <at> tobias.gr>

Date: Wed, 9 Aug 2023 17:41:02 UTC

Severity: important

Merged with 64106

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 65184 in the body.
You can then email your comments to 65184 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#65184; Package guix. (Wed, 09 Aug 2023 17:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tobias Geerinckx-Rice <me <at> tobias.gr>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Wed, 09 Aug 2023 17:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: bug-guix <at> gnu.org
Subject: (modify-services … (delete …)) should delete all matching service types
Date: Wed, 09 Aug 2023 19:40:42 +0200
TODO: the snippet

  (modify-services %base-services
    (delete mingetty-service-type))

deletes only the first (tty1) instance of the mingetty service.  I can't 
think of a scenario where this is likely to reflect the user's 
intention.  It should delete all matching services.

A delete-first variant could be added iff there's demand.

Kind regards,

T G-R

Sent from a Web browser.  Excuse or enjoy my brevity.




Severity set to 'important' from 'normal' Request was from Tobias Geerinckx-Rice <me <at> tobias.gr> to control <at> debbugs.gnu.org. (Wed, 09 Aug 2023 17:50:02 GMT) Full text and rfc822 format available.

Merged 64106 65184. Request was from Tobias Geerinckx-Rice <me <at> tobias.gr> to control <at> debbugs.gnu.org. (Wed, 09 Aug 2023 17:50:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#65184; Package guix. (Fri, 01 Sep 2023 03:51:03 GMT) Full text and rfc822 format available.

Message #12 received at 65184-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Brian Cully <bjc <at> spork.org>
Cc: ludo <at> gnu.org, me <at> tobias.gr, david <at> daviwil.com, felix.lechner <at> lease-up.com,
 65184-done <at> debbugs.gnu.org, 64106-done <at> debbugs.gnu.org
Subject: Re: bug#65184: (modify-services … (delete
 …)) should delete all matching service types
Date: Thu, 31 Aug 2023 23:49:52 -0400
Hi Brian!

Brian Cully <bjc <at> spork.org> writes:

> This patch reverts the behavior introduced in
> 181951207339508789b28ba7cb914f983319920f which caused ‘modify-services’
> clauses to only match a single instance of a service.
>
> We will now match all service instances when doing a deletion or update, while
> still raising an exception when trying to match against a service that does
> not exist in the services list, or which was deleted explicitly by a ‘delete’
> clause (or an update clause that returns ‘#f’ for the service).
>
> Fixes: #64106
>
> * gnu/services.scm (%modify-services): New procedure.
> (modify-services): Use it.
> (apply-clauses): Add DELETED-SERVICES argument, change to modify one service
> at a time.
> * tests/services.scm
> ("modify-services: delete then modify"),
> ("modify-services: modify then delete"),
> ("modify-services: delete multiple services of the same type"),
> ("modify-services: modify multiple services of the same type"): New tests.

[...]

I've applied the following cosmetic changes:

--8<---------------cut here---------------start------------->8---
1 file changed, 20 insertions(+), 18 deletions(-)
gnu/services.scm | 38 ++++++++++++++++++++------------------

modified   gnu/services.scm
@@ -325,11 +325,13 @@ (define-syntax clause-alist
      '())))
 
 (define (apply-clauses clauses service deleted-services)
+  "Apply CLAUSES, an alist as returned by 'clause-alist', to SERVICE.  An
+exception is raised if a clause attempts to modify a service
+present in DELETED-SERVICES."
   (define (raise-if-deleted kind properties)
-    (match (find (lambda (deleted)
-                   (match deleted
-                     ((deleted-kind _)
-                      (eq? kind deleted-kind))))
+    (match (find (match-lambda
+                   ((deleted-kind _)
+                    (eq? kind deleted-kind)))
                  deleted-services)
       ((_ deleted-properties)
        (raise (make-compound-condition
@@ -344,27 +346,27 @@ (define (apply-clauses clauses service deleted-services)
 
   (match clauses
     (((kind proc properties) . rest)
-     (begin
-       (raise-if-deleted kind properties)
-       (if (eq? (and service (service-kind service))
-                kind)
-           (let ((new-service (proc service)))
-             (apply-clauses rest new-service
-                            (if new-service
-                                deleted-services
-                                (cons (list kind properties)
-                                      deleted-services))))
-           (apply-clauses rest service deleted-services))))
+     (raise-if-deleted kind properties)
+     (if (eq? (and service (service-kind service)) kind)
+         (let ((new-service (proc service)))
+           (apply-clauses rest new-service
+                          (if new-service
+                              deleted-services
+                              (cons (list kind properties)
+                                    deleted-services))))
+         (apply-clauses rest service deleted-services)))
     (()
      service)))
 
 (define (%modify-services services clauses)
+  "Apply CLAUSES, an alist as returned by 'clause-alist', to SERVICES.  An
+exception is raised if a clause attempts to modify a missing service."
   (define (raise-if-not-found clause)
     (match clause
       ((kind _ properties)
-       (when (not (find (lambda (service)
-                          (eq? kind (service-kind service)))
-                        services))
+       (unless (find (lambda (service)
+                       (eq? kind (service-kind service)))
+                     services)
          (raise (make-compound-condition
                  (condition
                   (&error-location
--8<---------------cut here---------------end--------------->8---

and installed it.  Thanks for contributing to Guix!

-- 
Thanks,
Maxim




Information forwarded to bug-guix <at> gnu.org:
bug#65184; Package guix. (Fri, 01 Sep 2023 04:02:02 GMT) Full text and rfc822 format available.

Message #15 received at 65184 <at> debbugs.gnu.org (full text, mbox):

From: Felix Lechner <felix.lechner <at> lease-up.com>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>, Brian Cully <bjc <at> spork.org>,
 ludo <at> gnu.org, me <at> tobias.gr,
 "pelzflorian \(Florian Pelz\)" <pelzflorian <at> pelzflorian.de>,
 65184 <at> debbugs.gnu.org, Jelle Licht <jlicht <at> fsfe.org>, david <at> daviwil.com,
 64106 <at> debbugs.gnu.org
Subject: Re: bug#65184: (modify-services … (delete …)) should delete all matching service types
Date: Thu, 31 Aug 2023 21:00:09 -0700
Hi Maxim,

On Thu, Aug 31, 2023 at 8:49 PM Maxim Cournoyer
<maxim.cournoyer <at> gmail.com> wrote:
>
> > Fixes: #64106

Thanks for taking action. Can Bug#63921 also be closed?

Kind regards
Felix




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 29 Sep 2023 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 223 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.