GNU bug report logs - #58824
[PATCH 0/1] scripts: refresh: Support --list-dependent=packages.

Previous Next

Package: guix-patches;

Reported by: "(" <paren <at> disroot.org>

Date: Thu, 27 Oct 2022 21:28:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 58824 AT debbugs.gnu.org.

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#58824; Package guix-patches. (Thu, 27 Oct 2022 21:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "(" <paren <at> disroot.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 27 Oct 2022 21:28:02 GMT) Full text and rfc822 format available.

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

From: "(" <paren <at> disroot.org>
To: guix-patches <at> gnu.org
Cc: Vagrant Cascadian <vagrant <at> debian.org>, "\(" <paren <at> disroot.org>
Subject: [PATCH 0/1] scripts: refresh: Support --list-dependent=packages.
Date: Thu, 27 Oct 2022 22:27:06 +0100
Heya Guix,

This patch adds support for passing the string "packages" to
``guix refresh'''s ``--list-dependent'' argument, which displays only
the packages, with no "XXX packages will be rebuilt:" header. This
allows us to perform substitutions like this:

  guix build $(guix refresh --list-dependent=packages gtk)

to, for example, build all the dependents of ``gtk''.

( (1):
  scripts: refresh: Support --list-dependent=packages.

 guix/scripts/refresh.scm | 61 ++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 24 deletions(-)


base-commit: f928abac369f699f425ddee925d0d0c2dc0a635d
-- 
2.38.0





Information forwarded to guix-patches <at> gnu.org:
bug#58824; Package guix-patches. (Thu, 27 Oct 2022 21:30:02 GMT) Full text and rfc822 format available.

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

From: "(" <paren <at> disroot.org>
To: 58824 <at> debbugs.gnu.org
Cc: "\(" <paren <at> disroot.org>
Subject: [PATCH 1/1] scripts: refresh: Support --list-dependent=packages.
Date: Thu, 27 Oct 2022 22:28:59 +0100
* guix/scripts/refresh.scm (%options)[list-dependent]: Allow an
  optional argument.  Set 'LIST-DEPENDENT-MACHINE-READABLE? to
  #T in RESULT if the argument is "packages".
(list-dependents): Support #:MACHINE-READABLE?.
(guix-refresh): Pass #:MACHINE-READABLE? #T to LIST-DEPENDENTS if
'LIST-DEPENDENT-MACHINE-READABLE? is #T.
---
 guix/scripts/refresh.scm | 61 ++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 24 deletions(-)

diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 14329751f8..9040f4d83d 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -93,9 +93,12 @@ (define %options
         (option '(#\e "expression") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'expression arg result)))
-        (option '(#\l "list-dependent") #f #f
+        (option '(#\l "list-dependent") #f #t
                 (lambda (opt name arg result)
-                  (alist-cons 'list-dependent? #t result)))
+                  (append `((list-dependent? . #t)
+                            (list-dependent-machine-readable?
+                             . ,(and arg (string=? arg "packages"))))
+                          result)))
         (option '(#\r "recursive") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'recursive? #t result)))
@@ -417,8 +420,10 @@ (define (all-packages)
                  '()
                  #:select? (const #t)))           ;include hidden packages
 
-(define (list-dependents packages)
-  "List all the things that would need to be rebuilt if PACKAGES are changed."
+(define* (list-dependents packages #:key (machine-readable? #f))
+  "List all the things that would need to be rebuilt if PACKAGES are
+changed.  If MACHINE-READABLE? is #T, display only a list of packages,
+with no human-friendly extra text."
   ;; Using %BAG-NODE-TYPE is more accurate than using %PACKAGE-NODE-TYPE
   ;; because it includes implicit dependencies.
   (define (full-name package)
@@ -431,27 +436,31 @@ (define (full-name package)
            (covering   (filter (lambda (node)
                                  (null? (edges node)))
                                dependents)))
-      (match dependents
-        (()
-         (format (current-output-port)
-                 (N_ "No dependents other than itself: ~{~a~}~%"
-                     "No dependents other than themselves: ~{~a~^ ~}~%"
-                     (length packages))
-                 (map full-name packages)))
-
-        ((x)
-         (format (current-output-port)
-                 (G_ "A single dependent package: ~a~%")
-                 (full-name x)))
-        (lst
-         (format (current-output-port)
-                 (N_ "Building the following ~d package would ensure ~d \
+      (if machine-readable?
+          (format (current-output-port)
+                  (G_ "~{~a~^ ~}~%")
+                  (map full-name covering))
+          (match dependents
+            (()
+             (format (current-output-port)
+                     (N_ "No dependents other than itself: ~{~a~}~%"
+                         "No dependents other than themselves: ~{~a~^ ~}~%"
+                         (length packages))
+                     (map full-name packages)))
+            ((x)
+             (format (current-output-port)
+                     (G_ "A single dependent package: ~a~%")
+                     (full-name x)))
+            (lst
+             (format (current-output-port)
+                     (N_ "Building the following ~d package would ensure ~d \
 dependent packages are rebuilt: ~{~a~^ ~}~%"
-                     "Building the following ~d packages would ensure ~d \
+                         "Building the following ~d packages would ensure ~d \
 dependent packages are rebuilt: ~{~a~^ ~}~%"
-                     (length covering))
-                 (length covering) (length dependents)
-                 (map full-name covering))))
+                         (length covering))
+                     (length covering) (length dependents)
+                     (map full-name covering)))))
+      
       (return #t))))
 
 (define (list-transitive packages)
@@ -528,6 +537,8 @@ (define (options->updaters opts)
          (updaters        (options->updaters opts))
          (recursive?      (assoc-ref opts 'recursive?))
          (list-dependent? (assoc-ref opts 'list-dependent?))
+         (list-dependent-machine-readable?
+          (assoc-ref opts 'list-dependent-machine-readable?))
          (list-transitive? (assoc-ref opts 'list-transitive?))
          (key-download    (assoc-ref opts 'key-download))
 
@@ -543,7 +554,9 @@ (define (options->updaters opts)
           (mlet %store-monad ((packages (options->packages opts)))
             (cond
              (list-dependent?
-              (list-dependents packages))
+              (list-dependents packages
+                               #:machine-readable?
+                               list-dependent-machine-readable?))
              (list-transitive?
               (list-transitive packages))
              (update?
-- 
2.38.0





Information forwarded to guix-patches <at> gnu.org:
bug#58824; Package guix-patches. (Fri, 28 Oct 2022 15:40:01 GMT) Full text and rfc822 format available.

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

From: "(" <paren <at> disroot.org>
To: 58824 <at> debbugs.gnu.org
Cc: "\(" <paren <at> disroot.org>
Subject: [PATCH v2] scripts: refresh: Support --list-dependent=packages.
Date: Fri, 28 Oct 2022 16:30:52 +0100
* guix/scripts/refresh.scm (%options)[list-dependent]: Allow an
  optional argument.  Set 'LIST-DEPENDENT-MACHINE-READABLE? to
  #T in RESULT if the argument is "packages".
(list-dependents): Support #:MACHINE-READABLE?.
(guix-refresh): Pass #:MACHINE-READABLE? #T to LIST-DEPENDENTS if
'LIST-DEPENDENT-MACHINE-READABLE? is #T.
* doc/guix.texi: Document 'guix refresh --list-dependent=packages'.
---
 doc/guix.texi            | 13 +++++++--
 guix/scripts/refresh.scm | 62 ++++++++++++++++++++++++----------------
 2 files changed, 49 insertions(+), 26 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3bfb89bc33..9800307888 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -14095,11 +14095,20 @@ be used when passing @command{guix refresh} one or more package names:
 
 @table @code
 
-@item --list-dependent
-@itemx -l
+@item --list-dependent[=packages]
+@itemx -l [packages]
 List top-level dependent packages that would need to be rebuilt as a
 result of upgrading one or more packages.
 
+If the option is called with the optional @code{packages} argument, it
+will display only the list of packages, without the header stating the
+number of packages that will be rebuilt.  This can be used to run
+commands such as this, which builds all the dependents of @code{gtk}:
+
+@example
+$ guix build $(guix refresh gtk -l packages)
+@end example
+
 @xref{Invoking guix graph, the @code{reverse-package} type of
 @command{guix graph}}, for information on how to visualize the list of
 dependents of a package.
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 14329751f8..7c3f392a96 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2019 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
+;;; Copyright © 2022 ( <paren <at> disroot.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -93,9 +94,12 @@ (define %options
         (option '(#\e "expression") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'expression arg result)))
-        (option '(#\l "list-dependent") #f #f
+        (option '(#\l "list-dependent") #f #t
                 (lambda (opt name arg result)
-                  (alist-cons 'list-dependent? #t result)))
+                  (append `((list-dependent? . #t)
+                            (list-dependent-machine-readable?
+                             . ,(and arg (string=? arg "packages"))))
+                          result)))
         (option '(#\r "recursive") #f #f
                 (lambda (opt name arg result)
                   (alist-cons 'recursive? #t result)))
@@ -417,8 +421,10 @@ (define (all-packages)
                  '()
                  #:select? (const #t)))           ;include hidden packages
 
-(define (list-dependents packages)
-  "List all the things that would need to be rebuilt if PACKAGES are changed."
+(define* (list-dependents packages #:key (machine-readable? #f))
+  "List all the things that would need to be rebuilt if PACKAGES are
+changed.  If MACHINE-READABLE? is #T, display only a list of packages,
+with no human-friendly extra text."
   ;; Using %BAG-NODE-TYPE is more accurate than using %PACKAGE-NODE-TYPE
   ;; because it includes implicit dependencies.
   (define (full-name package)
@@ -431,27 +437,31 @@ (define (full-name package)
            (covering   (filter (lambda (node)
                                  (null? (edges node)))
                                dependents)))
-      (match dependents
-        (()
-         (format (current-output-port)
-                 (N_ "No dependents other than itself: ~{~a~}~%"
-                     "No dependents other than themselves: ~{~a~^ ~}~%"
-                     (length packages))
-                 (map full-name packages)))
-
-        ((x)
-         (format (current-output-port)
-                 (G_ "A single dependent package: ~a~%")
-                 (full-name x)))
-        (lst
-         (format (current-output-port)
-                 (N_ "Building the following ~d package would ensure ~d \
+      (if machine-readable?
+          (format (current-output-port)
+                  (G_ "~{~a~^ ~}~%")
+                  (map full-name covering))
+          (match dependents
+            (()
+             (format (current-output-port)
+                     (N_ "No dependents other than itself: ~{~a~}~%"
+                         "No dependents other than themselves: ~{~a~^ ~}~%"
+                         (length packages))
+                     (map full-name packages)))
+            ((x)
+             (format (current-output-port)
+                     (G_ "A single dependent package: ~a~%")
+                     (full-name x)))
+            (lst
+             (format (current-output-port)
+                     (N_ "Building the following ~d package would ensure ~d \
 dependent packages are rebuilt: ~{~a~^ ~}~%"
-                     "Building the following ~d packages would ensure ~d \
+                         "Building the following ~d packages would ensure ~d \
 dependent packages are rebuilt: ~{~a~^ ~}~%"
-                     (length covering))
-                 (length covering) (length dependents)
-                 (map full-name covering))))
+                         (length covering))
+                     (length covering) (length dependents)
+                     (map full-name covering)))))
+      
       (return #t))))
 
 (define (list-transitive packages)
@@ -528,6 +538,8 @@ (define (options->updaters opts)
          (updaters        (options->updaters opts))
          (recursive?      (assoc-ref opts 'recursive?))
          (list-dependent? (assoc-ref opts 'list-dependent?))
+         (list-dependent-machine-readable?
+          (assoc-ref opts 'list-dependent-machine-readable?))
          (list-transitive? (assoc-ref opts 'list-transitive?))
          (key-download    (assoc-ref opts 'key-download))
 
@@ -543,7 +555,9 @@ (define (options->updaters opts)
           (mlet %store-monad ((packages (options->packages opts)))
             (cond
              (list-dependent?
-              (list-dependents packages))
+              (list-dependents packages
+                               #:machine-readable?
+                               list-dependent-machine-readable?))
              (list-transitive?
               (list-transitive packages))
              (update?

base-commit: f928abac369f699f425ddee925d0d0c2dc0a635d
-- 
2.38.0





Information forwarded to guix-patches <at> gnu.org:
bug#58824; Package guix-patches. (Fri, 25 Nov 2022 09:31:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: "( via Guix-patches via" <guix-patches <at> gnu.org>, 58824 <at> debbugs.gnu.org
Cc: "\(" <paren <at> disroot.org>
Subject: Re: [bug#58824] [PATCH 1/1] scripts: refresh: Support
 --list-dependent=packages.
Date: Fri, 25 Nov 2022 10:21:26 +0100
Hi,

On Thu, 27 Oct 2022 at 22:28, "\( via Guix-patches" via <guix-patches <at> gnu.org> wrote:

> -        (option '(#\l "list-dependent") #f #f
> +        (option '(#\l "list-dependent") #f #t

For what it is worth, I think it is a bad idea to have optional argument
with short-name, well IMHO; see [1].

1: <http://issues.guix.gnu.org/issue/50472>

Cheers,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#58824; Package guix-patches. (Fri, 25 Nov 2022 09:31:03 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#58824; Package guix-patches. (Fri, 25 Nov 2022 16:26:02 GMT) Full text and rfc822 format available.

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

From: "(" <paren <at> disroot.org>
To: "zimoun" <zimon.toutoune <at> gmail.com>, "( via Guix-patches via"
 <guix-patches <at> gnu.org>, <58824 <at> debbugs.gnu.org>
Subject: Re: [bug#58824] [PATCH 1/1] scripts: refresh: Support
 --list-dependent=packages.
Date: Fri, 25 Nov 2022 16:25:11 +0000
On Fri Nov 25, 2022 at 9:21 AM GMT, zimoun wrote:
> For what it is worth, I think it is a bad idea to have optional argument
> with short-name, well IMHO; see [1].
>
> 1: <http://issues.guix.gnu.org/issue/50472>

Hmm. Perhaps we could replace this with a whole new

  -D, --list-dependent-packages

flag?

    -- (




Information forwarded to guix-patches <at> gnu.org:
bug#58824; Package guix-patches. (Fri, 25 Nov 2022 16:26:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#58824; Package guix-patches. (Mon, 28 Nov 2022 12:54:01 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: "(" <paren <at> disroot.org>, 58824 <at> debbugs.gnu.org
Subject: Re: [bug#58824] [PATCH 1/1] scripts: refresh: Support
 --list-dependent=packages.
Date: Fri, 25 Nov 2022 19:01:06 +0100
Hi,
On Fri, 25 Nov 2022 at 16:25, "\( via Guix-patches" via <guix-patches <at> gnu.org> wrote:

> Hmm. Perhaps we could replace this with a whole new
>
>   -D, --list-dependent-packages
>
> flag?

Vagrant proposed [1] to add a flag as --machine-readable, quoting:

        I vaguely recall discussing on irc not long ago the desire for "guix
        refresh --list-dependent --machine-readable" (e.g. drop the "Building
        the following X packages would ensure 10 dependent packages are
        rebuilt:") or something similar. Would save having to pipe to cut, awk,
        sed, perl, etc. ...

Well, there is also the annoyance that hidden packages are shown so it
becomes cumbersome for piping with “guix build” for instance.  Maybe,
this patch could be tweaked to have something like,

    guix refresh --list-build-dependent PACKAGE

returning a list accepted by “guix build”.


1: <https://yhetil.org/guix/87ilj69380.fsf <at> contorta>

Cheers,
simon




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

Previous Next


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