[PATCH 0/2] Display 1 line instead of 3 for each substitute download

  • Done
  • quality assurance status badge
Details
One participant
  • Ludovic Courtès
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
normal
L
L
Ludovic Courtès wrote on 21 Mar 2021 17:33
(address . guix-patches@gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20210321163357.5786-1-ludo@gnu.org
Hi!

This change brings the number of lines printed for each substitute
from 3 lines to 1, when using ‘-v1’:

Toggle snippet (8 lines)
$ ./pre-inst-env guix build -v1 vim-full poezio elixir ocaml --no-grafts
84.9 MB will be downloaded
elixir-1.11.4 3.7MiB 6.8MiB/s 00:01 [##################] 100.0%
ocaml-4.11.1 147.1MiB 19.7MiB/s 00:07 [##################] 100.0%
poezio-0.13.1 967KiB 7.0MiB/s 00:00 [##################] 100.0%
vim-full-8.2.2632 9.9MiB/s 00:01 | 12.7MiB transferred

‘-v2’ gives the equivalent of the current ‘-v1’, and ‘-v3’ gives
the equivalent of the current ‘-v2’ (full build output).

This change has been suggested multiple times in the past. I guess
I was gently preventing it on the grounds that I like to see which
substitute server I’m fetching from and whether it’s gzip/lzip/zstd.

But let’s face it: not everyone is interested in those details, even
I don’t care at time. ;-) It took me a while to realize, but I keep
learning!

Thoughts?

Ludo’.

Ludovic Courtès (2):
substitute: Emit a single newline upon completion.
status: Don't display download URLs for '--verbosity=1'.

doc/guix.texi | 7 ++++---
guix/scripts/substitute.scm | 7 +++++--
guix/status.scm | 23 +++++++++++++++++++----
3 files changed, 28 insertions(+), 9 deletions(-)

--
2.31.0
L
L
Ludovic Courtès wrote on 21 Mar 2021 17:56
[PATCH 1/2] substitute: Emit a single newline upon completion.
(address . 47295@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20210321165604.6426-1-ludo@gnu.org
The immediate effect is that, with '--verbosity=1', only two lines are
displayed for each substitute, instead of two lines followed by an empty
line.

* guix/scripts/substitute.scm (process-substitution): Emit a single
newline upon completion when PRINT-BUILD-TRACE? is true.
---
guix/scripts/substitute.scm | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

Toggle diff (20 lines)
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index f4042906c8..d0b4ef9fc2 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -551,8 +551,11 @@ the current output port."
(every (compose zero? cdr waitpid) pids)
;; Skip a line after what 'progress-reporter/file' printed, and another
- ;; one to visually separate substitutions.
- (display "\n\n" (current-error-port))
+ ;; one to visually separate substitutions. When PRINT-BUILD-TRACE? is
+ ;; true, leave it up to (guix status) to prettify things.
+ (newline (current-error-port))
+ (unless print-build-trace?
+ (newline (current-error-port)))
;; Check whether we got the data announced in NARINFO.
(let ((actual (get-hash)))
--
2.31.0
L
L
Ludovic Courtès wrote on 21 Mar 2021 17:56
[PATCH 2/2] status: Don't display download URLs for '--verbosity=1'.
(address . 47295@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20210321165604.6426-2-ludo@gnu.org
With this change, each substitute occupies a single line of
output (instead of two) when using '-v1', the default for 'guix package'
& co.

* guix/status.scm (print-build-event): Add #:print-urls? and honor it.
(print-build-event/quiet): Pass #:print-urls? #f.
(print-build-event/quiet-with-urls): New procedure.
(logger-for-level): Add case for LEVEL 2.
* doc/guix.texi (Common Build Options): Adjust '--verbosity'
documentation.
---
doc/guix.texi | 7 ++++---
guix/status.scm | 23 +++++++++++++++++++----
2 files changed, 23 insertions(+), 7 deletions(-)

Toggle diff (78 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 94ecd2c247..8c6550e733 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10253,9 +10253,10 @@ guix-daemon, @option{--timeout}}).
@cindex build logs, verbosity
@item -v @var{level}
@itemx --verbosity=@var{level}
-Use the given verbosity @var{level}, an integer. Choosing 0 means that no
-output is produced, 1 is for quiet output, and 2 shows all the build log
-output on standard error.
+Use the given verbosity @var{level}, an integer. Choosing 0 means that
+no output is produced, 1 is for quiet output; 2 is similar to 1 but it
+additionally displays download URLs; 3 shows all the build log output on
+standard error.
@item --cores=@var{n}
@itemx -c @var{n}
diff --git a/guix/status.scm b/guix/status.scm
index d47bf1700c..362ae2882c 100644
--- a/guix/status.scm
+++ b/guix/status.scm
@@ -403,10 +403,12 @@ the current build phase."
#:optional (port (current-error-port))
#:key
(colorize? (color-output? port))
+ (print-urls? #t)
(print-log? #t))
"Print information about EVENT and STATUS to PORT. When COLORIZE? is true,
produce colorful output. When PRINT-LOG? is true, display the build log in
-addition to build events."
+addition to build events. When PRINT-URLS? is true, display the URL of
+substitutes being downloaded."
(define info
(if colorize?
(cute colorize-string <> (color BOLD))
@@ -526,9 +528,10 @@ addition to build events."
(format port (info (G_ "substituting ~a...")) item)
(newline port)))
(('download-started item uri _ ...)
- (erase-current-line*)
- (format port (info (G_ "downloading from ~a ...")) uri)
- (newline port))
+ (when print-urls?
+ (erase-current-line*)
+ (format port (info (G_ "downloading from ~a ...")) uri)
+ (newline port)))
(('download-progress item uri
(= string->number size)
(= string->number transferred))
@@ -602,6 +605,17 @@ addition to build events."
(colorize? (color-output? port)))
(print-build-event event old-status status port
#:colorize? colorize?
+ #:print-urls? #f
+ #:print-log? #f))
+
+(define* (print-build-event/quiet-with-urls event old-status status
+ #:optional
+ (port (current-error-port))
+ #:key
+ (colorize? (color-output? port)))
+ (print-build-event event old-status status port
+ #:colorize? colorize?
+ #:print-urls? #t ;show download URLs
#:print-log? #f))
(define* (build-status-updater #:optional (on-change (const #t)))
@@ -787,6 +801,7 @@ evaluate EXP... in that context."
"Return the logging procedure that corresponds to LEVEL."
(cond ((<= level 0) (const #t))
((= level 1) print-build-event/quiet)
+ ((= level 2) print-build-event/quiet-with-urls)
(else print-build-event)))
(define (call-with-status-verbosity level thunk)
--
2.31.0
L
L
Ludovic Courtès wrote on 31 Mar 2021 16:05
Re: bug#47295: [PATCH 0/2] Display 1 line instead of 3 for each substitute download
(address . 47295-done@debbugs.gnu.org)
87wntn8lly.fsf@gnu.org
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (13 lines)
> This change brings the number of lines printed for each substitute
> from 3 lines to 1, when using ‘-v1’:
>
> $ ./pre-inst-env guix build -v1 vim-full poezio elixir ocaml --no-grafts
> 84.9 MB will be downloaded
> elixir-1.11.4 3.7MiB 6.8MiB/s 00:01 [##################] 100.0%
> ocaml-4.11.1 147.1MiB 19.7MiB/s 00:07 [##################] 100.0%
> poezio-0.13.1 967KiB 7.0MiB/s 00:00 [##################] 100.0%
> vim-full-8.2.2632 9.9MiB/s 00:01 | 12.7MiB transferred
>
> ‘-v2’ gives the equivalent of the current ‘-v1’, and ‘-v3’ gives
> the equivalent of the current ‘-v2’ (full build output).

Pushed as e45ef9a648c155c35b51e6b15049a1bd5416f0a1.

I’ll follow up with an update of the ‘guix’ package for the (guix
scripts substitute) part.

Thanks,
Ludo’.
Closed
?