mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
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)'.
This commit is contained in:
parent
1275baeba7
commit
d388c2c435
5 changed files with 52 additions and 51 deletions
|
@ -172,4 +172,5 @@ EXTRA_DIST += doc/fdl-1.3.texi
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
AM_DISTCHECK_CONFIGURE_FLAGS = \
|
AM_DISTCHECK_CONFIGURE_FLAGS = \
|
||||||
|
--with-libgcrypt-prefix="$(LIBGCRYPT_PREFIX)" \
|
||||||
--with-nix-prefix="$(NIX_PREFIX)"
|
--with-nix-prefix="$(NIX_PREFIX)"
|
||||||
|
|
2
README
2
README
|
@ -17,7 +17,7 @@ Guix currently depends on the following packages:
|
||||||
|
|
||||||
- [[http://gnu.org/software/guile/][GNU Guile 2.0.x]]
|
- [[http://gnu.org/software/guile/][GNU Guile 2.0.x]]
|
||||||
- [[http://nixos.org/nix/][Nix]]
|
- [[http://nixos.org/nix/][Nix]]
|
||||||
- [[http://gnupg.org/][GNU libgcrypt]], or [[http://nongnu.org/libchop/][libchop]]
|
- [[http://gnupg.org/][GNU libgcrypt]]
|
||||||
|
|
||||||
Optionally, packages from Nixpkgs may be transparently reused from Guix.
|
Optionally, packages from Nixpkgs may be transparently reused from Guix.
|
||||||
For this to work, you need to have a checkout of the Nixpkgs repository;
|
For this to work, you need to have a checkout of the Nixpkgs repository;
|
||||||
|
|
|
@ -65,9 +65,11 @@ AC_ARG_WITH([libgcrypt-prefix],
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
LIBGCRYPT="libgcrypt"
|
LIBGCRYPT="libgcrypt"
|
||||||
|
LIBGCRYPT_PREFIX="no"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
LIBGCRYPT="$withval/lib/libgcrypt"
|
LIBGCRYPT="$withval/lib/libgcrypt"
|
||||||
|
LIBGCRYPT_PREFIX="$withval"
|
||||||
;;
|
;;
|
||||||
esac],
|
esac],
|
||||||
[LIBGCRYPT="libgcrypt"])
|
[LIBGCRYPT="libgcrypt"])
|
||||||
|
@ -76,6 +78,10 @@ dnl Library name suitable for `dynamic-link'.
|
||||||
AC_MSG_CHECKING([for libgcrypt shared library name])
|
AC_MSG_CHECKING([for libgcrypt shared library name])
|
||||||
AC_MSG_RESULT([$LIBGCRYPT])
|
AC_MSG_RESULT([$LIBGCRYPT])
|
||||||
AC_SUBST([LIBGCRYPT])
|
AC_SUBST([LIBGCRYPT])
|
||||||
|
AC_SUBST([LIBGCRYPT_PREFIX])
|
||||||
|
|
||||||
|
GUIX_ASSERT_LIBGCRYPT_USABLE
|
||||||
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
|
|
|
@ -394,58 +394,17 @@ (define bv
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define sha256
|
(define sha256
|
||||||
(cond
|
(let ((hash (pointer->procedure void
|
||||||
((compile-time-value
|
(dynamic-func "gcry_md_hash_buffer"
|
||||||
(false-if-exception (dynamic-link %libgcrypt)))
|
(dynamic-link %libgcrypt))
|
||||||
;; Using libgcrypt.
|
`(,int * * ,size_t)))
|
||||||
(let ((hash (pointer->procedure void
|
(sha256 8)) ; GCRY_MD_SHA256, as of 1.5.0
|
||||||
(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.
|
|
||||||
(lambda (bv)
|
(lambda (bv)
|
||||||
"Return the SHA256 of BV as a bytevector."
|
"Return the SHA256 of BV as a bytevector."
|
||||||
(let ((in (pipe))
|
(let ((digest (make-bytevector (/ 256 8))))
|
||||||
(out (pipe))
|
(hash sha256 (bytevector->pointer digest)
|
||||||
(pid (primitive-fork)))
|
(bytevector->pointer bv) (bytevector-length bv))
|
||||||
(if (= 0 pid)
|
digest))))
|
||||||
(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))))))))))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
35
m4/guix.m4
Normal file
35
m4/guix.m4
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
dnl Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
|
||||||
|
dnl Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
dnl
|
||||||
|
dnl This file is part of Guix.
|
||||||
|
dnl
|
||||||
|
dnl Guix is free software; you can redistribute it and/or modify it
|
||||||
|
dnl under the terms of the GNU General Public License as published by
|
||||||
|
dnl the Free Software Foundation; either version 3 of the License, or (at
|
||||||
|
dnl your option) any later version.
|
||||||
|
dnl
|
||||||
|
dnl Guix is distributed in the hope that it will be useful, but
|
||||||
|
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
dnl GNU General Public License for more details.
|
||||||
|
dnl
|
||||||
|
dnl You should have received a copy of the GNU General Public License
|
||||||
|
dnl along with Guix. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
dnl GUIX_ASSERT_LIBGCRYPT_USABLE
|
||||||
|
dnl
|
||||||
|
dnl Assert that GNU libgcrypt is usable from Guile.
|
||||||
|
AC_DEFUN([GUIX_ASSERT_LIBGCRYPT_USABLE],
|
||||||
|
[AC_CACHE_CHECK([whether $LIBGCRYPT can be dynamically loaded],
|
||||||
|
[guix_cv_libgcrypt_usable_p],
|
||||||
|
[GUILE_CHECK([retval],
|
||||||
|
[(dynamic-func \"gcry_md_hash_buffer\" (dynamic-link \"$LIBGCRYPT\"))])
|
||||||
|
if test "$retval" = 0; then
|
||||||
|
guix_cv_libgcrypt_usable_p="yes"
|
||||||
|
else
|
||||||
|
guix_cv_libgcrypt_usable_p="no"
|
||||||
|
fi])
|
||||||
|
|
||||||
|
if test "x$guix_cv_libgcrypt_usable_p" != "xyes"; then
|
||||||
|
AC_MSG_ERROR([GNU libgcrypt does not appear to be usable; see `--with-libgcrypt-prefix' and `README'.])
|
||||||
|
fi])
|
Loading…
Reference in a new issue