me
/
guix
Archived
1
0
Fork 0

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)'.
master
Ludovic Courtès 2012-11-03 21:43:30 +01:00
parent 1275baeba7
commit d388c2c435
5 changed files with 52 additions and 51 deletions

View File

@ -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
View File

@ -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;

View File

@ -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

View File

@ -394,10 +394,6 @@ starting from the right of S."
;;; ;;;
(define sha256 (define sha256
(cond
((compile-time-value
(false-if-exception (dynamic-link %libgcrypt)))
;; Using libgcrypt.
(let ((hash (pointer->procedure void (let ((hash (pointer->procedure void
(dynamic-func "gcry_md_hash_buffer" (dynamic-func "gcry_md_hash_buffer"
(dynamic-link %libgcrypt)) (dynamic-link %libgcrypt))
@ -410,43 +406,6 @@ starting from the right of S."
(bytevector->pointer bv) (bytevector-length bv)) (bytevector->pointer bv) (bytevector-length bv))
digest)))) 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)
"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))))))))))
;;; ;;;
;;; Nixpkgs. ;;; Nixpkgs.

35
m4/guix.m4 100644
View 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])