GNU bug report logs - #41260
[PATCH 0/1] Support multiple profiles with '--list-installed'.

Previous Next

Package: guix-patches;

Reported by: zimoun <zimon.toutoune <at> gmail.com>

Date: Thu, 14 May 2020 14:15:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

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 41260 in the body.
You can then email your comments to 41260 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 guix-patches <at> gnu.org:
bug#41260; Package guix-patches. (Thu, 14 May 2020 14:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to zimoun <zimon.toutoune <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 14 May 2020 14:15:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH 0/1] Support multiple profiles with '--list-installed'.
Date: Thu, 14 May 2020 16:13:50 +0200
Dear,

As reported [1],

   guix package -p profile1 -p profile2 -I
and
   guix package -p profile2 -p profile2 -I

return different list; the one of the first profile actually.

This patch fixes this unexpected behaviour.


Last, I have failed to add a test in 'tests/guix-package.sh'.  I am not sure
to understand how the store is handled when running the test suite.


All the best,
simon

[1] http://issues.guix.gnu.org/40549#21


zimoun (1):
  guix package: Support multiple profiles with '--list-installed'.

 guix/scripts/package.scm | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

-- 
2.26.1





Information forwarded to guix-patches <at> gnu.org:
bug#41260; Package guix-patches. (Thu, 14 May 2020 14:19:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: 41260 <at> debbugs.gnu.org
Cc: zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH 1/1] guix package: Support multiple profiles with
 '--list-installed'.
Date: Thu, 14 May 2020 16:17:59 +0200
* guix/scripts/package.scm (process-query): List installed multiple profiles.
---
 guix/scripts/package.scm | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index a69efa365e..a4a6100a33 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -717,20 +717,23 @@ processed, #f otherwise."
        #t)
 
       (('list-installed regexp)
-       (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
-              (manifest  (profile-manifest profile))
-              (installed (manifest-entries manifest)))
-         (leave-on-EPIPE
-          (for-each (match-lambda
-                      (($ <manifest-entry> name version output path _)
-                       (when (or (not regexp)
-                                 (regexp-exec regexp name))
-                         (format #t "~a\t~a\t~a\t~a~%"
-                                 name (or version "?") output path))))
-
-                    ;; Show most recently installed packages last.
-                    (reverse installed)))
-         #t))
+       (for-each
+        (lambda (profile)
+          (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
+                 (manifest  (profile-manifest profile))
+                 (installed (manifest-entries manifest)))
+            (leave-on-EPIPE
+             (for-each (match-lambda
+                         (($ <manifest-entry> name version output path _)
+                          (when (or (not regexp)
+                                    (regexp-exec regexp name))
+                            (format #t "~a\t~a\t~a\t~a~%"
+                                    name (or version "?") output path))))
+
+                       ;; Show most recently installed packages last.
+                       (reverse installed)))))
+        profiles)
+       #t)
 
       (('list-available regexp)
        (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
-- 
2.26.1





Information forwarded to guix-patches <at> gnu.org:
bug#41260; Package guix-patches. (Sat, 16 May 2020 17:35:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 41260 <at> debbugs.gnu.org
Subject: Re: [bug#41260] [PATCH 1/1] guix package: Support multiple profiles
 with '--list-installed'.
Date: Sat, 16 May 2020 19:33:58 +0200
Hi!

zimoun <zimon.toutoune <at> gmail.com> skribis:

> * guix/scripts/package.scm (process-query): List installed multiple profiles.

[...]

> +       (for-each
> +        (lambda (profile)
> +          (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
> +                 (manifest  (profile-manifest profile))
> +                 (installed (manifest-entries manifest)))
> +            (leave-on-EPIPE
> +             (for-each (match-lambda
> +                         (($ <manifest-entry> name version output path _)
> +                          (when (or (not regexp)
> +                                    (regexp-exec regexp name))
> +                            (format #t "~a\t~a\t~a\t~a~%"
> +                                    name (or version "?") output path))))
> +
> +                       ;; Show most recently installed packages last.
> +                       (reverse installed)))))
> +        profiles)

How about instead loading all the manifests, merging them with
‘concatenate-manifests’, and operating on that?  That would avoid
special-casing.

Bonus point if you can add a test case for that, similar to
‘--search-paths’ with multiple profiles.  :-)

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#41260; Package guix-patches. (Thu, 21 May 2020 21:44:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: 41260 <at> debbugs.gnu.org
Cc: zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH v2] guix package: Support multiple profiles with
 '--list-installed'.
Date: Thu, 21 May 2020 23:43:06 +0200
* guix/scripts/package.scm (process-query): List installed multiple profiles.
* tests/guix-package-net.sh: Test it.
---
 guix/scripts/package.scm  | 20 +++++++++++---------
 tests/guix-package-net.sh | 12 ++++++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index a69efa365e..1246147798 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -675,12 +675,13 @@ doesn't need it."
 (define (process-query opts)
   "Process any query specified by OPTS.  Return #t when a query was actually
 processed, #f otherwise."
-  (let* ((profiles (match (filter-map (match-lambda
-                                        (('profile . p) p)
-                                        (_              #f))
-                                      opts)
-                     (() (list %current-profile))
-                     (lst (reverse lst))))
+  (let* ((profiles (delete-duplicates
+                    (match (filter-map (match-lambda
+                                         (('profile . p) p)
+                                         (_              #f))
+                                       opts)
+                      (() (list %current-profile))
+                      (lst (reverse lst)))))
          (profile  (match profiles
                      ((head tail ...) head))))
     (match (assoc-ref opts 'query)
@@ -718,7 +719,8 @@ processed, #f otherwise."
 
       (('list-installed regexp)
        (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
-              (manifest  (profile-manifest profile))
+              (manifest  (concatenate-manifests
+                          (map profile-manifest profiles)))
               (installed (manifest-entries manifest)))
          (leave-on-EPIPE
           (for-each (match-lambda
@@ -729,8 +731,8 @@ processed, #f otherwise."
                                  name (or version "?") output path))))
 
                     ;; Show most recently installed packages last.
-                    (reverse installed)))
-         #t))
+                    (reverse installed))))
+       #t)
 
       (('list-available regexp)
        (let* ((regexp    (and regexp (make-regexp* regexp regexp/icase)))
diff --git a/tests/guix-package-net.sh b/tests/guix-package-net.sh
index 48a94865e1..3876701fa2 100644
--- a/tests/guix-package-net.sh
+++ b/tests/guix-package-net.sh
@@ -1,6 +1,7 @@
 # GNU Guix --- Functional package management for GNU
 # Copyright © 2012, 2013, 2014, 2015, 2017, 2019 Ludovic Courtès <ludo <at> gnu.org>
 # Copyright © 2013 Nikita Karetnikov <nikita <at> karetnikov.org>
+# Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com>
 #
 # This file is part of GNU Guix.
 #
@@ -78,6 +79,17 @@ esac
 
 test "`guix package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
 
+guix package --bootstrap -p "$profile_alt" -i gcc-bootstrap
+installed="`guix package -p "$profile" -p "$profile_alt" -I | cut -f1 | xargs echo | sort`"
+case "x$installed" in
+    "gcc-bootstrap guile-bootstrap make-boot0")
+        true;;
+    "*")
+        false;;
+esac
+test "`guix package -p "$profile_alt" -p "$profile" -I | wc -l`" = "3"
+rm "$profile_alt"
+
 # List generations.
 test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \
      = "  guile-bootstrap"
-- 
2.26.2





Information forwarded to guix-patches <at> gnu.org:
bug#41260; Package guix-patches. (Thu, 21 May 2020 21:45:01 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 41260 <at> debbugs.gnu.org
Subject: Re: [bug#41260] [PATCH 1/1] guix package: Support multiple profiles
 with '--list-installed'.
Date: Thu, 21 May 2020 23:43:50 +0200
Hi Ludo,

Sorry for the delay.

On Sat, 16 May 2020 at 19:34, Ludovic Courtès <ludo <at> gnu.org> wrote:

> How about instead loading all the manifests, merging them with
> ‘concatenate-manifests’, and operating on that?  That would avoid
> special-casing.

See v2.


> Bonus point if you can add a test case for that, similar to
> ‘--search-paths’ with multiple profiles.  :-)

Done in 'tests/guix-packages-net.sh'.  See v2.


BTW, I added a 'delete-duplicates' on profiles.  And I was tempted to
also add 'sort' to always process in the same order.  And personally,
I prefer the alphanumerical order than the order of installation
because it is more reliable and easier to find what I am looking for
-- otherwise I always do the extra step of pipe: |cut -f1| xargs echo|
sort which is "ugly".  The order of installation seems redundant with
--list-generation.  WDYT?


Cheers,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#41260; Package guix-patches. (Fri, 22 May 2020 20:32:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 41260 <at> debbugs.gnu.org
Subject: Re: [bug#41260] [PATCH 1/1] guix package: Support multiple profiles
 with '--list-installed'.
Date: Fri, 22 May 2020 22:31:22 +0200
Hi,

zimoun <zimon.toutoune <at> gmail.com> skribis:

> BTW, I added a 'delete-duplicates' on profiles.  And I was tempted to
> also add 'sort' to always process in the same order.  And personally,
> I prefer the alphanumerical order than the order of installation
> because it is more reliable and easier to find what I am looking for
> -- otherwise I always do the extra step of pipe: |cut -f1| xargs echo|
> sort which is "ugly".  The order of installation seems redundant with
> --list-generation.  WDYT?

I’m not sure about ‘sort’ because the order (unfortunately) does make a
difference when there are file-level collisions.  If we were starting
today, we could forcefully sort things, but I’m tempted to think that
it’d break someone’s workflow if we did it now¹.

Ludo’.

¹ Obligatory reference: <https://xkcd.com/1172/>.




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sat, 23 May 2020 13:55:02 GMT) Full text and rfc822 format available.

Notification sent to zimoun <zimon.toutoune <at> gmail.com>:
bug acknowledged by developer. (Sat, 23 May 2020 13:55:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 41260-done <at> debbugs.gnu.org
Subject: Re: [bug#41260] [PATCH v2] guix package: Support multiple profiles
 with '--list-installed'.
Date: Sat, 23 May 2020 15:54:05 +0200
Hi,

zimoun <zimon.toutoune <at> gmail.com> skribis:

> * guix/scripts/package.scm (process-query): List installed multiple profiles.
> * tests/guix-package-net.sh: Test it.

Applied, thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#41260; Package guix-patches. (Mon, 25 May 2020 09:33:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 41260 <at> debbugs.gnu.org
Subject: Re: [bug#41260] [PATCH 1/1] guix package: Support multiple profiles
 with '--list-installed'.
Date: Mon, 25 May 2020 11:32:08 +0200
Hi Ludo,

On Fri, 22 May 2020 at 22:31, Ludovic Courtès <ludo <at> gnu.org> wrote:

> ¹ Obligatory reference: <https://xkcd.com/1172/>.

Yeah! Exactly! :-)
But I feel one "formatter" to "pretty" display is lacking.  It should
be an elegant solution for the recent discussion, a bit as "git log
--pretty=oneline|full|etc." does.
For example, I remember an old (rejected) patch by Robert Vollmer [1].

[1] https://lists.gnu.org/archive/html/guix-devel/2019-07/msg00304.html

Anyway, another topic. :-)


Thank you for the review.
All the best,
simon




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 22 Jun 2020 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 22 days ago.

Previous Next


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