aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-11-03 21:43:30 +0100
committerLudovic Courtès <ludo@gnu.org>2012-11-03 21:49:54 +0100
commitd388c2c435395aee61dc074023b1f218e6037545 (patch)
tree9b9016d2dea7bb708a20a571f5d48a3ec17bc3fb /guix
parent1275baeba7bbee85a28766eb7307cf1690ec08d2 (diff)
downloadguix-d388c2c435395aee61dc074023b1f218e6037545.tar
guix-d388c2c435395aee61dc074023b1f218e6037545.tar.gz
build: Require GNU libgcrypt.
* guix/utils.scm (sha256): Remove Coreutils- and libchop-based implementations. * README: Update accordingly. * m4/guix.m4: New file. * configure.ac: Use `GUIX_ASSERT_LIBGCRYPT_USABLE'. Set and substitute `LIBGCRYPT_PREFIX'. * Makefile.am (AM_DISTCHECK_CONFIGURE_FLAGS): Pass `--with-libgcrypt-prefix=$(LIBGCRYPT_PREFIX)'.
Diffstat (limited to 'guix')
-rw-r--r--guix/utils.scm59
1 files changed, 9 insertions, 50 deletions
diff --git a/guix/utils.scm b/guix/utils.scm
index 10b0c15fad..345ed374cd 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -394,58 +394,17 @@ starting from the right of S."
;;;
(define sha256
- (cond
- ((compile-time-value
- (false-if-exception (dynamic-link %libgcrypt)))
- ;; Using libgcrypt.
- (let ((hash (pointer->procedure void
- (dynamic-func "gcry_md_hash_buffer"
- (dynamic-link %libgcrypt))
- `(,int * * ,size_t)))
- (sha256 8)) ; GCRY_MD_SHA256, as of 1.5.0
- (lambda (bv)
- "Return the SHA256 of BV as a bytevector."
- (let ((digest (make-bytevector (/ 256 8))))
- (hash sha256 (bytevector->pointer digest)
- (bytevector->pointer bv) (bytevector-length bv))
- digest))))
-
- ((compile-time-value
- (false-if-exception (resolve-interface '(chop hash))))
- ;; Using libchop.
- (let ((bytevector-hash (@ (chop hash) bytevector-hash))
- (hash-method/sha256 (@ (chop hash) hash-method/sha256)))
- (lambda (bv)
- "Return the SHA256 of BV as a bytevector."
- (bytevector-hash hash-method/sha256 bv))))
-
- (else
- ;; Slow, poor programmer's implementation that uses Coreutils.
+ (let ((hash (pointer->procedure void
+ (dynamic-func "gcry_md_hash_buffer"
+ (dynamic-link %libgcrypt))
+ `(,int * * ,size_t)))
+ (sha256 8)) ; GCRY_MD_SHA256, as of 1.5.0
(lambda (bv)
"Return the SHA256 of BV as a bytevector."
- (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?)
- (base16-string->bytevector line))))))))))
-
+ (let ((digest (make-bytevector (/ 256 8))))
+ (hash sha256 (bytevector->pointer digest)
+ (bytevector->pointer bv) (bytevector-length bv))
+ digest))))
;;;