Use port-sha256' and open-sha256-port'.

* guix/derivations.scm (derivation-hash): Add comment as to why we keep
  the plain `sha256' call.
* guix/scripts/download.scm (guix-download): Use `port-sha256' instead
  of (compose sha256 get-bytevector-all).
* guix/scripts/refresh.scm (update-package): Likewise.
This commit is contained in:
Ludovic Courtès 2013-07-03 01:17:11 +02:00
parent 69927e78de
commit b0fad8a2d4
3 changed files with 6 additions and 2 deletions

View file

@ -469,6 +469,10 @@ (define derivation-hash ; `hashDerivationModulo' in derivations.cc
inputs)) inputs))
(drv (make-derivation outputs inputs sources (drv (make-derivation outputs inputs sources
system builder args env-vars))) system builder args env-vars)))
;; XXX: At this point this remains faster than `port-sha256', because
;; the SHA256 port's `write' method gets called for every single
;; character.
(sha256 (sha256
(with-fluids ((%default-port-encoding "UTF-8")) (with-fluids ((%default-port-encoding "UTF-8"))
(string->utf8 (call-with-output-string (string->utf8 (call-with-output-string

View file

@ -116,7 +116,7 @@ (define (parse-options)
(or path (or path
(leave (_ "~a: download failed~%") (leave (_ "~a: download failed~%")
arg)) arg))
(compose sha256 get-bytevector-all))) port-sha256))
(fmt (assq-ref opts 'format))) (fmt (assq-ref opts 'format)))
(format #t "~a~%~a~%" path (fmt hash)) (format #t "~a~%~a~%" path (fmt hash))
#t))) #t)))

View file

@ -137,7 +137,7 @@ (define* (update-package store package #:key (key-download 'interactive))
(package-name package) (package-name package)
(package-version package) version) (package-version package) version)
(let ((hash (call-with-input-file tarball (let ((hash (call-with-input-file tarball
(compose sha256 get-bytevector-all)))) port-sha256)))
(update-package-source package version hash))) (update-package-source package version hash)))
(warning (_ "~a: version ~a could not be \ (warning (_ "~a: version ~a could not be \
downloaded and authenticated; not updating") downloaded and authenticated; not updating")