From 1ff2619bc114aface6b7b9d818f7208f9af677df Mon Sep 17 00:00:00 2001 From: Eric Bavier Date: Thu, 8 Jan 2015 14:38:54 -0600 Subject: import: Factorize utility functions. * guix/import/pypi.scm (hash-table->alist, flatten, assoc-ref*, url-fetch, json-fetch): Pull procedures from here into... * guix/import/utils.scm: Here and... * guix/import/json.scm: Here. New file. * Makefile.am (MODULE)[HAVE_GUILE_JSON]: Add it. * guix/import/gnu.scm (file-sha256): Move from here to... * guix/hash.scm: Here. * tests/pypi.scm (pypi->guix-package): Update mock module reference. --- guix/hash.scm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'guix/hash.scm') diff --git a/guix/hash.scm b/guix/hash.scm index fb85f47586..593c2e1aee 100644 --- a/guix/hash.scm +++ b/guix/hash.scm @@ -26,6 +26,7 @@ #:export (sha256 open-sha256-port port-sha256 + file-sha256 open-sha256-input-port)) ;;; Commentary: @@ -129,6 +130,10 @@ output port." (close-port out) (get))) +(define (file-sha256 file) + "Return the SHA256 hash (a bytevector) of FILE." + (call-with-input-file file port-sha256)) + (define (open-sha256-input-port port) "Return an input port that wraps PORT and a thunk to get the hash of all the data read from PORT. The thunk always returns the same value." -- cgit v1.2.3