diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-07-01 23:28:21 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-07-01 23:28:21 +0200 |
commit | 72626a71a96b02fccb2281713c1fdcd09aa194c4 (patch) | |
tree | f24a4f73ee47d6478b5ef3a48ddb16e6403b7275 /guix | |
parent | 82323a80850a205866c83a9399cc76336e30847d (diff) | |
download | gnu-guix-72626a71a96b02fccb2281713c1fdcd09aa194c4.tar gnu-guix-72626a71a96b02fccb2281713c1fdcd09aa194c4.tar.gz |
Move `sha256' to (guix hash).
* guix/utils.scm (sha256): Move to...
* guix/hash.scm: ... here. New file.
* Makefile.am (MODULES): Add it.
* guix/derivations.scm, guix/scripts/download.scm,
guix/scripts/hash.scm, guix/scripts/refresh.scm, tests/base32.scm,
tests/derivations.scm, tests/store.scm: Use (guix hash).
Diffstat (limited to 'guix')
-rw-r--r-- | guix/derivations.scm | 1 | ||||
-rw-r--r-- | guix/hash.scm | 49 | ||||
-rw-r--r-- | guix/scripts/download.scm | 1 | ||||
-rw-r--r-- | guix/scripts/hash.scm | 21 | ||||
-rw-r--r-- | guix/scripts/refresh.scm | 1 | ||||
-rw-r--r-- | guix/utils.scm | 18 |
6 files changed, 63 insertions, 28 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm index 3c433a2685..b7ab07c061 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -26,6 +26,7 @@ #:use-module (ice-9 rdelim) #:use-module (guix store) #:use-module (guix utils) + #:use-module (guix hash) #:use-module (guix base32) #:export (<derivation> derivation? diff --git a/guix/hash.scm b/guix/hash.scm new file mode 100644 index 0000000000..1c7e342803 --- /dev/null +++ b/guix/hash.scm @@ -0,0 +1,49 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (guix hash) + #:use-module (guix config) + #:use-module (rnrs bytevectors) + #:use-module (system foreign) + #:export (sha256)) + +;;; Commentary: +;;; +;;; Cryptographic hashes. +;;; +;;; Code: + + +;;; +;;; Hash. +;;; + +(define sha256 + (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)))) + +;;; hash.scm ends here diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm index da5fa5be9e..3fbda034f5 100644 --- a/guix/scripts/download.scm +++ b/guix/scripts/download.scm @@ -19,6 +19,7 @@ (define-module (guix scripts download) #:use-module (guix ui) #:use-module (guix store) + #:use-module (guix hash) #:use-module (guix utils) #:use-module (guix base32) #:use-module (guix download) diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm index 1b14aaadd0..ca3928b8e3 100644 --- a/guix/scripts/hash.scm +++ b/guix/scripts/hash.scm @@ -18,16 +18,17 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (guix scripts hash) - #:use-module (guix base32) - #:use-module (guix ui) - #:use-module (guix utils) - #:use-module (rnrs io ports) - #:use-module (rnrs files) - #:use-module (ice-9 match) - #:use-module (srfi srfi-1) - #:use-module (srfi srfi-26) - #:use-module (srfi srfi-37) - #:export (guix-hash)) + #:use-module (guix base32) + #:use-module (guix hash) + #:use-module (guix ui) + #:use-module (guix utils) + #:use-module (rnrs io ports) + #:use-module (rnrs files) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-37) + #:export (guix-hash)) ;;; diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index b8d4efd204..aa74d6306b 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -19,6 +19,7 @@ (define-module (guix scripts refresh) #:use-module (guix ui) + #:use-module (guix hash) #:use-module (guix store) #:use-module (guix utils) #:use-module (guix packages) diff --git a/guix/utils.scm b/guix/utils.scm index 2478fb6939..4187efde41 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -36,7 +36,6 @@ #:autoload (system foreign) (pointer->procedure) #:export (bytevector->base16-string base16-string->bytevector - sha256 %nixpkgs-directory nixpkgs-derivation @@ -138,23 +137,6 @@ evaluate to a simple datum." s) bv))) - -;;; -;;; Hash. -;;; - -(define sha256 - (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)))) ;;; |