aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-06-01 23:29:55 +0200
committerLudovic Courtès <ludo@gnu.org>2012-06-01 23:30:14 +0200
commit69f90f5c81419b55a4de0fd8324356f9116d9f74 (patch)
treedc3b243f8eff4004d29dcbeb7fa6f348772d4d46
parent341c6fdd824bfdaa97ea024cafc741efe9a62060 (diff)
downloadpatches-69f90f5c81419b55a4de0fd8324356f9116d9f74.tar
patches-69f90f5c81419b55a4de0fd8324356f9116d9f74.tar.gz
Use libchop for cryptographic hashes and related.
* guix/derivations.scm (sha256): Rewrite using libchop's `bytevector-hash'. (derivation-hash): Add docstring.
-rw-r--r--guix/derivations.scm31
1 files changed, 7 insertions, 24 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm
index d0e90a9952..9bdcdacf1f 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -24,6 +24,10 @@
#:use-module (rnrs bytevectors)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
+ #:use-module (guix store)
+ #:use-module ((chop hash)
+ #:select (bytevector-hash
+ hash-method/sha256))
#:export (derivation?
derivation-outputs
derivation-inputs
@@ -184,32 +188,11 @@ that form."
(display ")" port))))
(define (sha256 bv)
- "Return the SHA256 of BV as an string of hexadecimal digits."
- ;; XXX: Poor programmer's implementation that uses Coreutils.
- (let ((in (pipe))
- (out (pipe))
- (pid (primitive-fork)))
- (if (= 0 pid)
- (begin ; child
- (close (cdr in))
- (close (car out))
- (close 0)
- (close 1)
- (dup2 (fileno (car in)) 0)
- (dup2 (fileno (cdr out)) 1)
- (execlp "sha256sum" "sha256sum"))
- (begin ; parent
- (close (car in))
- (close (cdr out))
- (put-bytevector (cdr in) bv)
- (close (cdr in)) ; EOF
- (let ((line (car (string-tokenize (read-line (car out))))))
- (close (car out))
- (and (and=> (status:exit-val (cdr (waitpid pid)))
- zero?)
- line))))))
+ "Return the SHA256 of BV as a bytevector."
+ (bytevector-hash hash-method/sha256 bv))
(define (derivation-hash drv) ; `hashDerivationModulo' in derivations.cc
+ "Return the hash of DRV, modulo its fixed-output inputs, as a bytevector."
(match drv
(($ <derivation> ((_ . ($ <derivation-output> path
(? symbol? hash-algo) (? string? hash)))))