After a successful download, we'd erase the download-progress line, and
the end result would be two empty lines following the "downloading …"
line.
Reported by Ricardo Wurmus <rekado@elephly.net> at
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=33470#27>.
* guix/status.scm (print-build-event)[erase-current-line*]: Set to a
no-op when PRINT-LOG? is true.
Move calls to 'erase-current-line*' to the 'build-succeeded' and
'build-failed' events.
* guix/status.scm (<build>)[phase]: New field.
(%phase-start-rx): New variable.
(update-build): Add clause to match %PHASE-START-RX and adjust the
'phase' field accordingly.
* tests/status.scm ("compute-status, build phase"): Add test
* guix/status.scm (<build>): Define using
'define-immutable-record-type', and add 'set-build-completion' binding.
(update-build)[set-completion]: Remove.
Use 'set-build-completion' instead.
Previously the progress bar wouldn't be erased by the time the next
"building foo" line would be printed.
* guix/status.scm (print-build-event)[erase-current-line*]: New
procedure.
Call it instead of (display "\r").
* guix/status.scm (print-build-event)[report-build-progress]: New
procedure.
[print-log-line]: Add ID parameter. Call 'report-build-progress' when
appropriate.
Adjust callers.
* guix/status.scm (<build>): New record type.
(build, matching-build): New procedures.
(compute-status): Adjust to manipulate <build> records instead of
derivation file names in 'build-status-builds-completed' and
'build-status-building'.
(build-event-output-port)[process-line]: Use 'string-split' to preserve
spaces.
* tests/status.scm ("compute-status, builds + substitutes")
("compute-status, missing events"): Adjust to expect <build> records.
Produce complete "build-started" events.
("compute-status, multiplexed build output"): Likewise, and remove
"bar.drv" from 'builds-completed'.
* guix/status.scm (build-event-output-port)[guile@2.0]: Do not call 'setvbuf'
on custom binary port.
* tests/status.scm (current-build-output-port, UTF-8 + garbage)[guile@2.0]:
Use "?" in place of REPLACEMENT CHARACTER.
This allows for more accurate status tracking and parsing of extended
build traces.
* guix/status.scm (multiplexed-output-supported?): New procedure.
(print-build-event): Don't print \r when PRINT-LOG? is true.
Adjust 'build-log' handling for when 'multiplexed-output-supported?'
returns true.
(bytevector-index, split-lines): New procedures.
(build-event-output-port)[%build-output-pid, %build-output]
[%build-output-left]: New variables.
[process-line]: Handle "@ build-output" traces.
[process-build-output]: New procedure.
[write!]: Add case for when %BUILD-OUTPUT-PID is true. Use
'bytevector-index' rather than 'string-index'.
(compute-status): Add #:derivation-path->output-path. Use it.
* tests/status.scm ("compute-status, multiplexed build output"):
New test.
("build-output-port, UTF-8")
("current-build-output-port, UTF-8 + garbage"): Adjust to new
'build-log' output.
* guix/scripts/build.scm (set-build-options-from-command-line):
Pass #:multiplexed-build-output?.
(%default-options): Add 'multiplexed-build-output?'.
* guix/scripts/environment.scm (%default-options): Likewise.
* guix/scripts/pack.scm (%default-options): Likewise.
* guix/scripts/package.scm (%default-options): Likewise.
* guix/scripts/pull.scm (%default-options): Likewise.
* guix/scripts/system.scm (%default-options): Likewise.
* guix/status.scm (maybe-utf8->string): New procedure.
(build-event-output-port): Use it in lieu of 'utf8->string'.
* tests/status.scm ("build-output-port, UTF-8")
("current-build-output-port, UTF-8 + garbage"): New tests.
* guix/store.scm (derivation-log-file): New procedure.o
(log-file): Use it.
* guix/status.scm (print-build-event): Use 'derivation-log-file' instead
of 'log-file'. Check wheter the return value is #f.