unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo Prikler <leo.prikler@student.tugraz.at>
To: Mark H Weaver <mhw@netris.org>, 23874@debbugs.gnu.org
Subject: bug#23874: [PATCH 1/2] profiles: Remove duplicates in manifest transactions.
Date: Wed, 02 Dec 2020 23:25:01 +0100	[thread overview]
Message-ID: <b9e9701b14ef7759c2f0518f2ab31323f7073bc7.camel@student.tugraz.at> (raw)
In-Reply-To: <87ft4oeyyl.fsf@netris.org>

[-- Attachment #1: Type: text/plain, Size: 1509 bytes --]

Hi Mark,

Am Mittwoch, den 02.12.2020, 15:26 -0500 schrieb Mark H Weaver:
> Hi,
> 
> Leo Prikler <leo.prikler@student.tugraz.at> writes:
> 
> > * guix/profiles.scm (manifest-transaction-effects): Delete
> > duplicates in
> > install and remove.  Let multiple upgrades and downgrades shadow
> > previous
> > transactions of the same kind.
> > ---
> >  guix/profiles.scm | 11 +++++++----
> >  1 file changed, 7 insertions(+), 4 deletions(-)
> > 
> > diff --git a/guix/profiles.scm b/guix/profiles.scm
> > index 1b15257210..99b7dbf299 100644
> > --- a/guix/profiles.scm
> > +++ b/guix/profiles.scm
> [...]
> > @@ -740,10 +743,10 @@ replace it."
> >           (loop rest
> >                 (if previous install (cons entry install))
> >                 (if (and previous newer?)
> > -                   (alist-cons previous entry upgrade)
> > +                   (assoc-set! upgrade previous entry)
> >                     upgrade)
> >                 (if (and previous (not newer?))
> > -                   (alist-cons previous entry downgrade)
> > +                   (assoc-set! downgrade previous entry)
> >                     downgrade)))))))
> 
> We should avoid mutating existing list structure, as done above with
> 'assoc-set!'.
In this case the bug is not with mutating existing structures (as those
are allocated only for this loop), but in not checking, whether the
entries are the same.  Either way, I've now implemented a version, that
should fix both wrong-doings (see attachment).

Regards, Leo

[-- Attachment #2: 0001-profiles-Remove-duplicates-in-manifest-transactions.patch --]
[-- Type: text/x-patch, Size: 1952 bytes --]

From 67ae06895b0d6f2f31410cc32d733bfa098102d6 Mon Sep 17 00:00:00 2001
From: Leo Prikler <leo.prikler@student.tugraz.at>
Date: Wed, 2 Dec 2020 14:06:52 +0100
Subject: [PATCH 1/2] profiles: Remove duplicates in manifest transactions.

* guix/profiles.scm (manifest-transaction-effects): Delete duplicates in
install and remove.  Let multiple upgrades and downgrades shadow previous
transactions of the same kind.
---
 guix/profiles.scm | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/guix/profiles.scm b/guix/profiles.scm
index 1b15257210..034591eb79 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -716,6 +716,12 @@ replace it."
     (manifest-pattern
       (name   (manifest-entry-name entry))
       (output (manifest-entry-output entry))))
+  (define manifest-entry-pair=?
+    (match-lambda*
+      (((m1a . m2a) (m1b . m2b))
+       (and (manifest-entry=? m1a m1b)
+            (manifest-entry=? m2a m2b)))
+      (_ #f)))
 
   (let loop ((input     (manifest-transaction-install transaction))
              (install   '())
@@ -724,8 +730,16 @@ replace it."
     (match input
       (()
        (let ((remove (manifest-transaction-remove transaction)))
-         (values (manifest-matching-entries manifest remove)
-                 (reverse install) (reverse upgrade) (reverse downgrade))))
+         (values (delete-duplicates
+                  (manifest-matching-entries manifest remove)
+                  manifest-entry=?)
+                 (delete-duplicates (reverse install) manifest-entry=?)
+                 (delete-duplicates
+                  (reverse upgrade)
+                  manifest-entry-pair=?)
+                 (delete-duplicates
+                  (reverse downgrade)
+                  manifest-entry-pair=?))))
       ((entry rest ...)
        ;; Check whether installing ENTRY corresponds to the installation of a
        ;; new package or to an upgrade.
-- 
2.29.2


  reply	other threads:[~2020-12-02 22:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30 13:59 bug#23874: duplicates in manifests are “installed” more than once Ricardo Wurmus
2016-06-30 21:14 ` Ludovic Courtès
2020-09-14 18:15   ` zimoun
2020-12-02 13:22 ` bug#23874: [PATCH 1/2] profiles: Remove duplicates in manifest transactions Leo Prikler
2020-12-02 13:22   ` bug#23874: [PATCH 2/2] profiles: Delete duplicate manifest entries in packages->manifest Leo Prikler
2020-12-02 20:26   ` bug#23874: [PATCH 1/2] profiles: Remove duplicates in manifest transactions Mark H Weaver
2020-12-02 22:25     ` Leo Prikler [this message]
2020-12-02 23:24       ` zimoun
2020-12-05 15:38       ` Ludovic Courtès
2020-12-05 16:29         ` Leo Prikler
2020-12-07  9:16           ` Ludovic Courtès
2020-12-07 15:28             ` zimoun
2020-12-02 23:39 ` bug#23874: [PATCH v2 " Leo Prikler
2020-12-02 23:39   ` bug#23874: [PATCH v2 2/2] profiles: Delete duplicate manifest entries in packages->manifest Leo Prikler
2020-12-05 16:20 ` bug#23874: [PATCH v3 1/2] profiles: Remove duplicates in manifest transactions Leo Prikler
2020-12-05 16:20   ` bug#23874: [PATCH v3 2/2] profiles: Delete duplicate manifest entries in packages->manifest Leo Prikler

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=b9e9701b14ef7759c2f0518f2ab31323f7073bc7.camel@student.tugraz.at \
    --to=leo.prikler@student.tugraz.at \
    --cc=23874@debbugs.gnu.org \
    --cc=mhw@netris.org \
    /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).