GNU bug report logs - #37502
[PATCH] guix package: Add '--list-profiles'.

Previous Next

Package: guix-patches;

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

Date: Tue, 24 Sep 2019 15:53:01 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 37502 in the body.
You can then email your comments to 37502 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#37502; Package guix-patches. (Tue, 24 Sep 2019 15:53:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 24 Sep 2019 15:53:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: guix-patches <at> gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH] guix package: Add '--list-profiles'.
Date: Tue, 24 Sep 2019 17:52:24 +0200
* guix/scripts/package.scm (show-help, %options): Add '--list-profiles'.
(process-query): Honor it.
* tests/guix-package.sh: Add test.
---
 doc/guix.texi            | 13 +++++++++++++
 guix/scripts/package.scm | 21 +++++++++++++++++++++
 tests/guix-package.sh    |  6 +++++-
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 093199c63b..60187fcb1e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -2937,6 +2937,19 @@ siblings that point to specific generations:
 $ rm ~/code/my-profile ~/code/my-profile-*-link
 @end example
 
+@item --list-profiles
+List all the user's profiles:
+
+@example
+$ guix package --list-profiles
+/home/charlie/.guix-profile
+/home/charlie/code/my-profile
+/home/charlie/code/devel-profile
+/home/charlie/tmp/test
+@end example
+
+When running as root, list all the profiles of all the users.
+
 @cindex collisions, in a profile
 @cindex colliding packages in profiles
 @cindex profile collisions
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index f03741aa9e..1a58d43e5c 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -39,6 +39,7 @@
   #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:autoload   (guix describe) (package-provenance)
+  #:autoload   (guix store roots) (gc-roots)
   #:use-module ((guix build utils)
                 #:select (directory-exists? mkdir-p))
   #:use-module (ice-9 format)
@@ -359,6 +360,8 @@ Install, remove, or upgrade packages in a single transaction.\n"))
                          switch to a generation matching PATTERN"))
   (display (G_ "
   -p, --profile=PROFILE  use PROFILE instead of the user's default profile"))
+  (display (G_ "
+      --list-profiles    list the user's profiles"))
   (newline)
   (display (G_ "
       --allow-collisions do not treat collisions in the profile as an error"))
@@ -458,6 +461,11 @@ command-line option~%")
                    (values (cons `(query list-generations ,arg)
                                  result)
                            #f)))
+         (option '("list-profiles") #f #f
+                 (lambda (opt name arg result arg-handler)
+                   (values (cons `(query list-profiles #t)
+                                 result)
+                           #f)))
          (option '(#\d "delete-generations") #f #t
                  (lambda (opt name arg result arg-handler)
                    (values (alist-cons 'delete-generations arg
@@ -750,6 +758,19 @@ processed, #f otherwise."
                              (string<? name1 name2))))))
          #t))
 
+      (('list-profiles _)
+       (let ((profiles (delete-duplicates
+                        (filter-map (lambda (root)
+                                      (and (or (zero? (getuid))
+                                               (user-owned? root))
+                                           (generation-profile root)))
+                                    (gc-roots)))))
+         (leave-on-EPIPE
+          (for-each (lambda (profile)
+                      (display (user-friendly-profile profile))
+                      (newline))
+                    (sort profiles string<?)))))
+
       (('search _)
        (let* ((patterns (filter-map (match-lambda
                                       (('query 'search rx) rx)
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 79e89286f1..0de30bf6c1 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -438,7 +438,7 @@ cat > "$module_dir/foo.scm"<<EOF
     (version "dummy-version")
     (outputs '("out" "dummy-output"))
     (source #f)
-    ;; Without a real build system, the "guix pacakge -s" command will fail.
+    ;; Without a real build system, the "guix package -s" command will fail.
     (build-system trivial-build-system)
     (synopsis "dummy-synopsis")
     (description "dummy-description")
@@ -448,3 +448,7 @@ EOF
 guix package -L "$module_dir" -s dummy-output > /tmp/out
 test "`guix package -L "$module_dir" -s dummy-output | grep ^name:`" = "name: dummy-package"
 rm -rf "$module_dir"
+
+# Make sure we can see user profiles.
+guix package --list-profiles | grep "$profile"
+guix package --list-profiles | grep '\.guix-profile'
-- 
2.23.0





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Thu, 26 Sep 2019 09:51:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Thu, 26 Sep 2019 09:51:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: 37502-done <at> debbugs.gnu.org
Subject: Re: [bug#37502] [PATCH] guix package: Add '--list-profiles'.
Date: Thu, 26 Sep 2019 11:50:42 +0200
Ludovic Courtès <ludo <at> gnu.org> skribis:

> * guix/scripts/package.scm (show-help, %options): Add '--list-profiles'.
> (process-query): Honor it.
> * tests/guix-package.sh: Add test.

Pushed as 3972dc5d43ea824ee4ab78592e759f62ce90bf6a.

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 24 Oct 2019 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 185 days ago.

Previous Next


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