GNU bug report logs - #56541
[PATCH] system: Add -I, --list-installed option.

Previous Next

Package: guix-patches;

Reported by: Antero Mejr <antero <at> mailbox.org>

Date: Wed, 13 Jul 2022 15:02: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 56541 in the body.
You can then email your comments to 56541 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#56541; Package guix-patches. (Wed, 13 Jul 2022 15:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Antero Mejr <antero <at> mailbox.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 13 Jul 2022 15:02:02 GMT) Full text and rfc822 format available.

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

From: Antero Mejr <antero <at> mailbox.org>
To: guix-patches <at> gnu.org
Subject: [PATCH] system: Add -I, --list-installed option.
Date: Wed, 13 Jul 2022 15:01:22 +0000
* guix/scripts/system.scm: New flag -I, --list-installed.
* doc/guix.texi (Invoking Guix System): Add information for
--list-installed flag.
---
Depends on patch 56238:
https://issues.guix.gnu.org/56428

 doc/guix.texi           | 12 ++++++++
 guix/scripts/system.scm | 61 +++++++++++++++++++++++++++++------------
 2 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index fc3a2d962d..3f3b480f4e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -37647,6 +37647,13 @@ bootloader boot menu:
 Describe the running system generation: its file name, the kernel and
 bootloader used, etc., as well as provenance information when available.
 
+The @code{--list-installed} flag is available, with the same
+syntax that is used in @command{guix package --list-installed}
+(@pxref{Invoking guix package}).  When the flag is used,
+the description will include a list of packages that are currently
+installed in the system profile, with optional filtering based on a
+regular expression.
+
 @quotation Note
 The @emph{running} system generation---referred to by
 @file{/run/current-system}---is not necessarily the @emph{current}
@@ -37674,6 +37681,11 @@ generations that are up to 10 days old:
 $ guix system list-generations 10d
 @end example
 
+The @code{--list-installed} flag may also be specified, with the same
+syntax that is used in @command{guix package --list-installed}.  This
+may be helpful if trying to determine when a package was added to the
+system.
+
 @end table
 
 The @command{guix system} command has even more to offer!  The following
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index b9084a401c..91a0a5302b 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -50,7 +50,8 @@ (define-module (guix scripts system)
   #:use-module (guix channels)
   #:use-module (guix scripts build)
   #:autoload   (guix scripts package) (delete-generations
-                                       delete-matching-generations)
+                                       delete-matching-generations
+                                       list-installed)
   #:autoload   (guix scripts pull) (channel-commit-hyperlink)
   #:autoload   (guix graph) (export-graph node-type
                              graph-backend-name lookup-backend)
@@ -480,7 +481,8 @@ (define (shepherd-service-node-type services)
 ;;;
 
 (define* (display-system-generation number
-                                    #:optional (profile %system-profile))
+                                    #:optional (profile %system-profile)
+                                    #:key (list-installed-regex #f))
   "Display a summary of system generation NUMBER in a human-readable format."
   (define (display-channel channel)
     (format #t     "    ~a:~%" (channel-name channel))
@@ -544,23 +546,34 @@ (define-values (channels config-file)
         (format #t (G_ "  configuration file: ~a~%")
                 (if (supports-hyperlinks?)
                     (file-hyperlink config-file)
-                    config-file))))))
-
-(define* (list-generations pattern #:optional (profile %system-profile))
+                    config-file)))
+      (when list-installed-regex
+        (format #t (G_ "  packages:\n"))
+        (pretty-print-table (list-installed
+                             list-installed-regex
+                             (list (string-append generation "/profile")))
+                            #:left-pad 4)))))
+
+(define* (list-generations pattern #:optional (profile %system-profile)
+                           #:key (list-installed-regex #f))
   "Display in a human-readable format all the system generations matching
 PATTERN, a string.  When PATTERN is #f, display all the system generations."
   (cond ((not (file-exists? profile))             ; XXX: race condition
          (raise (condition (&profile-not-found-error
                             (profile profile)))))
         ((not pattern)
-         (for-each display-system-generation (profile-generations profile)))
+         (for-each (cut display-system-generation <>
+                        #:list-installed-regex list-installed-regex)
+                   (profile-generations profile)))
         ((matching-generations pattern profile)
          =>
          (lambda (numbers)
            (if (null-list? numbers)
                (exit 1)
                (leave-on-EPIPE
-                (for-each display-system-generation numbers)))))))
+                (for-each (cut display-system-generation <>
+                               #:list-installed-regex list-installed-regex)
+                          numbers)))))))
 
 
 ;;;
@@ -1032,6 +1045,11 @@ (define (show-help)
                          use BACKEND for 'extension-graphs' and 'shepherd-graph'"))
   (newline)
   (display (G_ "
+  -I, --list-installed[=REGEXP]
+                         for 'describe' and 'list-generations', list installed
+                         packages matching REGEXP"))
+  (newline)
+  (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
   -V, --version          display version information and exit"))
@@ -1135,6 +1153,9 @@ (define %options
          (option '("graph-backend") #t #f
                  (lambda (opt name arg result)
                    (alist-cons 'graph-backend arg result)))
+         (option '(#\I "list-installed") #f #t
+                 (lambda (opt name arg result)
+                   (alist-cons 'list-installed (or arg "") result)))
          %standard-build-options))
 
 (define %default-options
@@ -1322,25 +1343,29 @@ (define-syntax-rule (with-store* store exp ...)
     ;; The following commands do not need to use the store, and they do not need
     ;; an operating system configuration file.
     ((list-generations)
-     (let ((pattern (match args
+     (let ((list-installed-regex (assoc-ref opts 'list-installed))
+           (pattern (match args
                       (() #f)
                       ((pattern) pattern)
                       (x (leave (G_ "wrong number of arguments~%"))))))
-       (list-generations pattern)))
+       (list-generations pattern #:list-installed-regex list-installed-regex)))
     ((describe)
      ;; Describe the running system, which is not necessarily the current
      ;; generation.  /run/current-system might point to
      ;; /var/guix/profiles/system-N-link, or it might point directly to
      ;; /gnu/store/…-system.  Try both.
-     (match (generation-number "/run/current-system" %system-profile)
-       (0
-        (match (generation-number %system-profile)
-          (0
-           (leave (G_ "no system generation, nothing to describe~%")))
-          (generation
-           (display-system-generation generation))))
-       (generation
-        (display-system-generation generation))))
+     (let ((list-installed-regex (assoc-ref opts 'list-installed)))
+       (match (generation-number "/run/current-system" %system-profile)
+         (0
+          (match (generation-number %system-profile)
+            (0
+             (leave (G_ "no system generation, nothing to describe~%")))
+            (generation
+             (display-system-generation
+              generation #:list-installed-regex list-installed-regex))))
+         (generation
+          (display-system-generation
+           generation #:list-installed-regex list-installed-regex)))))
     ((search)
      (apply (resolve-subcommand "search") args))
     ((edit)
-- 
2.36.1





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Mon, 18 Jul 2022 13:32:01 GMT) Full text and rfc822 format available.

Notification sent to Antero Mejr <antero <at> mailbox.org>:
bug acknowledged by developer. (Mon, 18 Jul 2022 13:32:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Antero Mejr <antero <at> mailbox.org>
Cc: 56541-done <at> debbugs.gnu.org
Subject: Re: bug#56541: [PATCH] system: Add -I, --list-installed option.
Date: Mon, 18 Jul 2022 15:31:37 +0200
Hi,

Antero Mejr <antero <at> mailbox.org> skribis:

> * guix/scripts/system.scm: New flag -I, --list-installed.
> * doc/guix.texi (Invoking Guix System): Add information for
> --list-installed flag.

Applied with the same kind of cosmetic changes as for ‘guix home’.

Thanks,
Ludo’.




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

This bug report was last modified 2 years and 360 days ago.

Previous Next


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