From: "\( via Guix-patches" via <guix-patches@gnu.org>
To: 58824@debbugs.gnu.org
Cc: "\(" <paren@disroot.org>
Subject: [bug#58824] [PATCH 1/1] scripts: refresh: Support --list-dependent=packages.
Date: Thu, 27 Oct 2022 22:28:59 +0100 [thread overview]
Message-ID: <20221027212859.21755-1-paren@disroot.org> (raw)
In-Reply-To: <20221027212706.21680-1-paren@disroot.org>
* 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
next prev parent reply other threads:[~2022-10-27 21:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 21:27 [bug#58824] [PATCH 0/1] scripts: refresh: Support --list-dependent=packages ( via Guix-patches via
2022-10-27 21:28 ` ( via Guix-patches via [this message]
2022-11-25 9:21 ` [bug#58824] [PATCH 1/1] " zimoun
2022-11-25 16:25 ` ( via Guix-patches via
2022-11-25 18:01 ` zimoun
2022-10-28 15:30 ` [bug#58824] [PATCH v2] " ( via Guix-patches via
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221027212859.21755-1-paren@disroot.org \
--to=guix-patches@gnu.org \
--cc=58824@debbugs.gnu.org \
--cc=paren@disroot.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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.