Use `port-sha256' and `open-sha256-port'.
authorLudovic Courtès <ludo@gnu.org>
Tue, 2 Jul 2013 23:17:11 +0000 (01:17 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 2 Jul 2013 23:18:24 +0000 (01:18 +0200)
* 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.

guix/derivations.scm
guix/scripts/download.scm
guix/scripts/refresh.scm

index b7ab07c..8ddef11 100644 (file)
@@ -469,6 +469,10 @@ in SIZE bytes."
                            inputs))
               (drv    (make-derivation outputs inputs sources
                                        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
           (with-fluids ((%default-port-encoding "UTF-8"))
             (string->utf8 (call-with-output-string
index 3fbda03..87b4204 100644 (file)
@@ -116,7 +116,7 @@ Supported formats: 'nix-base32' (default), 'base32', and 'base16'
                       (or path
                           (leave (_ "~a: download failed~%")
                                  arg))
-                    (compose sha256 get-bytevector-all)))
+                    port-sha256))
            (fmt   (assq-ref opts 'format)))
       (format #t "~a~%~a~%" path (fmt hash))
       #t)))
index aa74d63..c75ec4f 100644 (file)
@@ -137,7 +137,7 @@ values: 'interactive' (default), 'always', and 'never'."
                     (package-name package)
                     (package-version package) version)
             (let ((hash (call-with-input-file tarball
-                          (compose sha256 get-bytevector-all))))
+                          port-sha256)))
               (update-package-source package version hash)))
           (warning (_ "~a: version ~a could not be \
 downloaded and authenticated; not updating")