diff options
Diffstat (limited to 'guix/scripts/substitute.scm')
-rwxr-xr-x | guix/scripts/substitute.scm | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 82ce069598..1cfab81dbd 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 nar-uri-abbreviation open-connection-for-uri close-connection store-path-abbreviation byte-count->string)) @@ -399,8 +400,10 @@ or is signed by an unauthorized key." (when verbose? ;; Visually separate substitutions with a newline. (format (current-error-port) - "~%Found valid signature for ~a~%From ~a~%" - (narinfo-path narinfo) + (_ "~%Found valid signature for ~a~%") + (narinfo-path narinfo)) + (format (current-error-port) + (_ "From ~a~%") (uri->string (narinfo-uri narinfo))))) narinfo)))) @@ -895,11 +898,11 @@ DESTINATION as a nar file. Verify the substitute against ACL." (dl-size (or download-size (and (equal? comp "none") (narinfo-size narinfo)))) - (progress (progress-proc (uri-abbreviation uri) + (progress (progress-proc (uri->string uri) dl-size (current-error-port) #:abbreviation - store-path-abbreviation))) + nar-uri-abbreviation))) (progress-report-port progress raw))) ((input pids) (decompressed-port (and=> (narinfo-compression narinfo) @@ -973,6 +976,16 @@ 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")) + (lambda (str) + (let ((number (string->number str))) + (and number (max 20 (- number 1)))))) + 80)) + (define (guix-substitute . args) "Implement the build daemon's substituter protocol." (mkdir-p %narinfo-cache-directory) @@ -989,6 +1002,13 @@ found." (newline) (force-output (current-output-port)) + ;; Attempt to install the client's locale, mostly so that messages are + ;; suitably translated. + (match (or (find-daemon-option "untrusted-locale") + (find-daemon-option "locale")) + (#f #f) + (locale (false-if-exception (setlocale LC_ALL locale)))) + (with-networking (with-error-handling ; for signature errors (match args @@ -1003,9 +1023,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") |