[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
10/10: substitute: Honor the number of columns of the client terminal.
From: |
Ludovic Courtès |
Subject: |
10/10: substitute: Honor the number of columns of the client terminal. |
Date: |
Thu, 14 Apr 2016 22:32:45 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit b0a6a9713076347c14ee2dd0ea494ab086df2a82
Author: Ludovic Courtès <address@hidden>
Date: Fri Apr 15 00:10:22 2016 +0200
substitute: Honor the number of columns of the client terminal.
* guix/store.scm (set-build-options): Add #:terminal-columns parameter
and honor it.
* guix/scripts/substitute.scm (client-terminal-columns): New procedure.
(guix-substitute): Use it to parameterize 'current-terminal-columns'.
---
guix/scripts/substitute.scm | 20 ++++++++++++++++----
guix/store.scm | 10 +++++++++-
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index 82ce069..db0416b 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -31,7 +31,8 @@
#:use-module (guix pki)
#:use-module ((guix build utils) #:select (mkdir-p dump-port))
#:use-module ((guix build download)
- #:select (progress-proc uri-abbreviation
+ #:select (current-terminal-columns
+ progress-proc uri-abbreviation
open-connection-for-uri
close-connection
store-path-abbreviation byte-count->string))
@@ -973,6 +974,14 @@ found."
;; daemon.
'("http://hydra.gnu.org"))))
+(define (client-terminal-columns)
+ "Return the number of columns in the client's terminal, if it is known, or a
+default value."
+ (or (and=> (or (find-daemon-option "untrusted-terminal-columns")
+ (find-daemon-option "terminal-columns"))
+ string->number)
+ 80))
+
(define (guix-substitute . args)
"Implement the build daemon's substituter protocol."
(mkdir-p %narinfo-cache-directory)
@@ -1003,9 +1012,12 @@ found."
(loop (read-line)))))))
(("--substitute" store-path destination)
;; Download STORE-PATH and add store it as a Nar in file DESTINATION.
- (process-substitution store-path destination
- #:cache-urls %cache-urls
- #:acl (current-acl)))
+ ;; Specify the number of columns of the terminal so the progress
+ ;; report displays nicely.
+ (parameterize ((current-terminal-columns (client-terminal-columns)))
+ (process-substitution store-path destination
+ #:cache-urls %cache-urls
+ #:acl (current-acl))))
(("--version")
(show-version-and-exit "guix substitute"))
(("--help")
diff --git a/guix/store.scm b/guix/store.scm
index 9066116..af311a0 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -22,6 +22,7 @@
#:use-module (guix serialization)
#:use-module (guix monads)
#:autoload (guix base32) (bytevector->base32-string)
+ #:autoload (guix build syscalls) (terminal-columns)
#:use-module (rnrs bytevectors)
#:use-module (rnrs io ports)
#:use-module (srfi srfi-1)
@@ -530,7 +531,10 @@ encoding conversion errors."
;; the daemon's settings are used. Otherwise, it
;; overrides the daemons settings; see 'guix
;; substitute'.
- (substitute-urls #f))
+ (substitute-urls #f)
+
+ ;; Number of columns in the client's terminal.
+ (terminal-columns (terminal-columns)))
;; Must be called after `open-connection'.
(define socket
@@ -565,6 +569,10 @@ encoding conversion errors."
,@(if rounds
`(("build-repeat"
. ,(number->string (max 0 (1- rounds)))))
+ '())
+ ,@(if terminal-columns
+ `(("terminal-columns"
+ . ,(number->string terminal-columns)))
'()))))
(send (string-pairs pairs))))
(let loop ((done? (process-stderr server)))
- branch master updated (85c7e8e -> b0a6a97), Ludovic Courtès, 2016/04/14
- 04/10: download: Send an ANSI erase-in-line sequence in addition to CR., Ludovic Courtès, 2016/04/14
- 02/10: gnu-maintenance: Recognize source tarball with "-src" in their name., Ludovic Courtès, 2016/04/14
- 09/10: guix download: Honor the number of columns of the terminal., Ludovic Courtès, 2016/04/14
- 08/10: ui: Use 'terminal-columns'., Ludovic Courtès, 2016/04/14
- 05/10: download: Add 'current-terminal-columns' parameter., Ludovic Courtès, 2016/04/14
- 10/10: substitute: Honor the number of columns of the client terminal.,
Ludovic Courtès <=
- 07/10: ui: 'package->recutils' accurately honors the number of columns., Ludovic Courtès, 2016/04/14
- 03/10: gnu-maintenance: Move FTP directory info to 'properties' fields., Ludovic Courtès, 2016/04/14
- 06/10: syscalls: Add TIOCGWINSZ bindings., Ludovic Courtès, 2016/04/14
- 01/10: upstream: Pass a package object to updaters., Ludovic Courtès, 2016/04/14