ui: Add #:verbosity to 'show-what-to-build'.
* guix/ui.scm (%default-verbosity): New variable. (show-what-to-build): Add #:verbosity and honor it. (build-notifier): Add #:verbosity and pass it to 'show-what-to-build'.
This commit is contained in:
parent
c471d4733f
commit
a55d83b546
1 changed files with 109 additions and 66 deletions
175
guix/ui.scm
175
guix/ui.scm
|
@ -951,17 +951,25 @@ that the rest."
|
||||||
(color DARK))
|
(color DARK))
|
||||||
(string-drop file prefix)))))
|
(string-drop file prefix)))))
|
||||||
|
|
||||||
|
(define %default-verbosity
|
||||||
|
;; Default verbosity level for 'show-what-to-build'.
|
||||||
|
2)
|
||||||
|
|
||||||
(define* (show-what-to-build store drv
|
(define* (show-what-to-build store drv
|
||||||
#:key dry-run? (use-substitutes? #t)
|
#:key dry-run? (use-substitutes? #t)
|
||||||
|
(verbosity %default-verbosity)
|
||||||
(mode (build-mode normal)))
|
(mode (build-mode normal)))
|
||||||
"Show what will or would (depending on DRY-RUN?) be built in realizing the
|
"Show what will or would (depending on DRY-RUN?) be built in realizing the
|
||||||
derivations listed in DRV using MODE, a 'build-mode' value. The elements of
|
derivations listed in DRV using MODE, a 'build-mode' value. The elements of
|
||||||
DRV can be either derivations or derivation inputs.
|
DRV can be either derivations or derivation inputs.
|
||||||
|
|
||||||
Return two values: a Boolean indicating whether there's something to build,
|
Return two values: a Boolean indicating whether there's something to build,
|
||||||
and a Boolean indicating whether there's something to download. When
|
and a Boolean indicating whether there's something to download.
|
||||||
USE-SUBSTITUTES?, check and report what is prerequisites are available for
|
|
||||||
download."
|
When USE-SUBSTITUTES?, check and report what is prerequisites are available
|
||||||
|
for download. VERBOSITY is an integer indicating the level of details to be
|
||||||
|
shown: level 2 and higher provide all the details, level 1 shows a high-level
|
||||||
|
summary, and level 0 shows nothing."
|
||||||
(define inputs
|
(define inputs
|
||||||
(map (match-lambda
|
(map (match-lambda
|
||||||
((? derivation? drv) (derivation-input drv))
|
((? derivation? drv) (derivation-input drv))
|
||||||
|
@ -1020,71 +1028,104 @@ download."
|
||||||
;; display when we have information for all of DOWNLOAD.
|
;; display when we have information for all of DOWNLOAD.
|
||||||
(not (any (compose zero? substitutable-download-size) download)))
|
(not (any (compose zero? substitutable-download-size) download)))
|
||||||
|
|
||||||
|
;; Combinatorial explosion ahead along two axes: DRY-RUN? and VERBOSITY.
|
||||||
|
;; Unfortunately, this is hardly avoidable for proper i18n.
|
||||||
(if dry-run?
|
(if dry-run?
|
||||||
(begin
|
(begin
|
||||||
(format (current-error-port)
|
(unless (zero? verbosity)
|
||||||
(N_ "~:[The following derivation would be built:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
"~:[The following derivations would be built:~%~{ ~a~%~}~;~]"
|
(N_ "~:[The following derivation would be built:~%~{ ~a~%~}~;~]"
|
||||||
(length build))
|
"~:[The following derivations would be built:~%~{ ~a~%~}~;~]"
|
||||||
(null? build) (map colorized-store-item build))
|
(length build))
|
||||||
(if display-download-size?
|
(null? build) (map colorized-store-item build)))
|
||||||
(format (current-error-port)
|
(cond ((>= verbosity 2)
|
||||||
;; TRANSLATORS: "MB" is for "megabyte"; it should be
|
(if display-download-size?
|
||||||
;; translated to the corresponding abbreviation.
|
(format (current-error-port)
|
||||||
(G_ "~:[~,1h MB would be downloaded:~%~{ ~a~%~}~;~]")
|
;; TRANSLATORS: "MB" is for "megabyte"; it should be
|
||||||
(null? download)
|
;; translated to the corresponding abbreviation.
|
||||||
download-size
|
(G_ "~:[~,1h MB would be downloaded:~%~{ ~a~%~}~;~]")
|
||||||
(map (compose colorized-store-item substitutable-path)
|
(null? download)
|
||||||
download))
|
download-size
|
||||||
(format (current-error-port)
|
(map (compose colorized-store-item substitutable-path)
|
||||||
(N_ "~:[The following file would be downloaded:~%~{ ~a~%~}~;~]"
|
download))
|
||||||
"~:[The following files would be downloaded:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
(length download))
|
(N_ "~:[The following file would be downloaded:~%~{ ~a~%~}~;~]"
|
||||||
(null? download)
|
"~:[The following files would be downloaded:~%~{ ~a~%~}~;~]"
|
||||||
(map (compose colorized-store-item substitutable-path)
|
(length download))
|
||||||
download)))
|
(null? download)
|
||||||
(format (current-error-port)
|
(map (compose colorized-store-item substitutable-path)
|
||||||
(N_ "~:[The following graft would be made:~%~{ ~a~%~}~;~]"
|
download)))
|
||||||
"~:[The following grafts would be made:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
(length graft))
|
(N_ "~:[The following graft would be made:~%~{ ~a~%~}~;~]"
|
||||||
(null? graft) (map colorized-store-item graft))
|
"~:[The following grafts would be made:~%~{ ~a~%~}~;~]"
|
||||||
(format (current-error-port)
|
(length graft))
|
||||||
(N_ "~:[The following profile hook would be built:~%~{ ~a~%~}~;~]"
|
(null? graft) (map colorized-store-item graft))
|
||||||
"~:[The following profile hooks would be built:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
(length hook))
|
(N_ "~:[The following profile hook would be built:~%~{ ~a~%~}~;~]"
|
||||||
(null? hook) (map colorized-store-item hook)))
|
"~:[The following profile hooks would be built:~%~{ ~a~%~}~;~]"
|
||||||
|
(length hook))
|
||||||
|
(null? hook) (map colorized-store-item hook)))
|
||||||
|
((= verbosity 1)
|
||||||
|
;; Display the bare minimum; don't mention grafts and hooks.
|
||||||
|
(if display-download-size?
|
||||||
|
(format (current-error-port)
|
||||||
|
;; TRANSLATORS: "MB" is for "megabyte"; it should be
|
||||||
|
;; translated to the corresponding abbreviation.
|
||||||
|
(G_ "~:[~,1h MB would be downloaded~%~;~]")
|
||||||
|
(null? download) download-size)
|
||||||
|
(format (current-error-port)
|
||||||
|
(N_ "~:[~h item would be downloaded~%~;~]"
|
||||||
|
"~:[~h items would be downloaded~%~;~]"
|
||||||
|
(length download))
|
||||||
|
(null? download) (length download))))))
|
||||||
|
|
||||||
(begin
|
(begin
|
||||||
(format (current-error-port)
|
(unless (zero? verbosity)
|
||||||
(N_ "~:[The following derivation will be built:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
"~:[The following derivations will be built:~%~{ ~a~%~}~;~]"
|
(N_ "~:[The following derivation will be built:~%~{ ~a~%~}~;~]"
|
||||||
(length build))
|
"~:[The following derivations will be built:~%~{ ~a~%~}~;~]"
|
||||||
(null? build) (map colorized-store-item build))
|
(length build))
|
||||||
(if display-download-size?
|
(null? build) (map colorized-store-item build)))
|
||||||
(format (current-error-port)
|
(cond ((>= verbosity 2)
|
||||||
;; TRANSLATORS: "MB" is for "megabyte"; it should be
|
(if display-download-size?
|
||||||
;; translated to the corresponding abbreviation.
|
(format (current-error-port)
|
||||||
(G_ "~:[~,1h MB will be downloaded:~%~{ ~a~%~}~;~]")
|
;; TRANSLATORS: "MB" is for "megabyte"; it should be
|
||||||
(null? download)
|
;; translated to the corresponding abbreviation.
|
||||||
download-size
|
(G_ "~:[~,1h MB will be downloaded:~%~{ ~a~%~}~;~]")
|
||||||
(map (compose colorized-store-item substitutable-path)
|
(null? download)
|
||||||
download))
|
download-size
|
||||||
(format (current-error-port)
|
(map (compose colorized-store-item substitutable-path)
|
||||||
(N_ "~:[The following file will be downloaded:~%~{ ~a~%~}~;~]"
|
download))
|
||||||
"~:[The following files will be downloaded:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
(length download))
|
(N_ "~:[The following file will be downloaded:~%~{ ~a~%~}~;~]"
|
||||||
(null? download)
|
"~:[The following files will be downloaded:~%~{ ~a~%~}~;~]"
|
||||||
(map (compose colorized-store-item substitutable-path)
|
(length download))
|
||||||
download)))
|
(null? download)
|
||||||
(format (current-error-port)
|
(map (compose colorized-store-item substitutable-path)
|
||||||
(N_ "~:[The following graft will be made:~%~{ ~a~%~}~;~]"
|
download)))
|
||||||
"~:[The following grafts will be made:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
(length graft))
|
(N_ "~:[The following graft will be made:~%~{ ~a~%~}~;~]"
|
||||||
(null? graft) (map colorized-store-item graft))
|
"~:[The following grafts will be made:~%~{ ~a~%~}~;~]"
|
||||||
(format (current-error-port)
|
(length graft))
|
||||||
(N_ "~:[The following profile hook will be built:~%~{ ~a~%~}~;~]"
|
(null? graft) (map colorized-store-item graft))
|
||||||
"~:[The following profile hooks will be built:~%~{ ~a~%~}~;~]"
|
(format (current-error-port)
|
||||||
(length hook))
|
(N_ "~:[The following profile hook will be built:~%~{ ~a~%~}~;~]"
|
||||||
(null? hook) (map colorized-store-item hook))))
|
"~:[The following profile hooks will be built:~%~{ ~a~%~}~;~]"
|
||||||
|
(length hook))
|
||||||
|
(null? hook) (map colorized-store-item hook)))
|
||||||
|
((= verbosity 1)
|
||||||
|
;; Display the bare minimum; don't mention grafts and hooks.
|
||||||
|
(if display-download-size?
|
||||||
|
(format (current-error-port)
|
||||||
|
;; TRANSLATORS: "MB" is for "megabyte"; it should be
|
||||||
|
;; translated to the corresponding abbreviation.
|
||||||
|
(G_ "~:[~,1h MB will be downloaded~%~;~]")
|
||||||
|
(null? download) download-size)
|
||||||
|
(format (current-error-port)
|
||||||
|
(N_ "~:[~h item will be downloaded~%~;~]"
|
||||||
|
"~:[~h items will be downloaded~%~;~]"
|
||||||
|
(length download))
|
||||||
|
(null? download) (length download)))))))
|
||||||
|
|
||||||
(check-available-space installed-size)
|
(check-available-space installed-size)
|
||||||
|
|
||||||
|
@ -1093,7 +1134,8 @@ download."
|
||||||
(define show-what-to-build*
|
(define show-what-to-build*
|
||||||
(store-lift show-what-to-build))
|
(store-lift show-what-to-build))
|
||||||
|
|
||||||
(define* (build-notifier #:key (dry-run? #f) (use-substitutes? #t))
|
(define* (build-notifier #:key (dry-run? #f) (use-substitutes? #t)
|
||||||
|
(verbosity %default-verbosity))
|
||||||
"Return a procedure suitable for 'with-build-handler' that, when
|
"Return a procedure suitable for 'with-build-handler' that, when
|
||||||
'build-things' is called, invokes 'show-what-to-build' to display the build
|
'build-things' is called, invokes 'show-what-to-build' to display the build
|
||||||
plan. When DRY-RUN? is true, the 'with-build-handler' form returns without
|
plan. When DRY-RUN? is true, the 'with-build-handler' form returns without
|
||||||
|
@ -1127,6 +1169,7 @@ any build happening."
|
||||||
(show-what-to-build store inputs
|
(show-what-to-build store inputs
|
||||||
#:dry-run? dry-run?
|
#:dry-run? dry-run?
|
||||||
#:use-substitutes? use-substitutes?
|
#:use-substitutes? use-substitutes?
|
||||||
|
#:verbosity verbosity
|
||||||
#:mode mode)))
|
#:mode mode)))
|
||||||
|
|
||||||
(unless (and (or build? download?)
|
(unless (and (or build? download?)
|
||||||
|
|
Reference in a new issue