[PATCH 0/1] Switch to Guile-Gcrypt

  • Done
  • quality assurance status badge
Details
One participant
  • Ludovic Courtès
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
normal
L
L
Ludovic Courtès wrote on 2 Sep 2018 00:25
(address . guix-patches@gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20180901222502.2334-1-ludo@gnu.org
Hi!

This patch switches Guix to Guile-Gcrypt, making it a new dependency.
I tested things like “guix system vm”, “guix pack”, “make
as-derivation”, and “guix pull” from a different branch. Everything
seems to be OK.

Incidentally, the switch simplifies cases where we need, say,
(gcrypt hash) functionality on the build side since now we can simply
write:

(with-extensions (list guile-gcrypt)
#~(begin
(use-modules (gcrypt hash))
…))

(Before we had to generate a fake (guix config) with the libgcrypt
absolute file name and so on.)

Feedback welcome!

Ludo’.

Ludovic Courtès (1):
Switch to Guile-Gcrypt.

Makefile.am | 5 -
README | 3 +-
build-aux/build-self.scm | 81 ++++++-
configure.ac | 13 +-
doc/guix.texi | 4 +-
gnu/packages/bash.scm | 2 +-
gnu/system/vm.scm | 48 ++--
guix/derivations.scm | 2 +-
guix/docker.scm | 2 +-
guix/gcrypt.scm | 49 ----
guix/git.scm | 2 +-
guix/hash.scm | 184 ---------------
guix/http-client.scm | 2 +-
guix/import/cpan.scm | 2 +-
guix/import/cran.scm | 2 +-
guix/import/crate.scm | 2 +-
guix/import/elpa.scm | 2 +-
guix/import/gnu.scm | 2 +-
guix/import/hackage.scm | 2 +-
guix/import/texlive.scm | 2 +-
guix/import/utils.scm | 2 +-
guix/nar.scm | 4 +-
guix/pk-crypto.scm | 407 ----------------------------------
guix/pki.scm | 2 +-
guix/scripts/archive.scm | 2 +-
guix/scripts/authenticate.scm | 2 +-
guix/scripts/download.scm | 2 +-
guix/scripts/hash.scm | 6 +-
guix/scripts/pack.scm | 60 ++---
guix/scripts/publish.scm | 4 +-
guix/scripts/refresh.scm | 2 +-
guix/scripts/substitute.scm | 4 +-
guix/self.scm | 26 +--
guix/store.scm | 2 +-
guix/store/deduplication.scm | 2 +-
guix/tests.scm | 2 +-
m4/guix.m4 | 18 --
tests/base32.scm | 2 +-
tests/builders.scm | 2 +-
tests/challenge.scm | 2 +-
tests/cpan.scm | 2 +-
tests/crate.scm | 2 +-
tests/derivations.scm | 2 +-
tests/gem.scm | 2 +-
tests/hash.scm | 128 -----------
tests/nar.scm | 2 +-
tests/opam.scm | 2 +-
tests/packages.scm | 2 +-
tests/pk-crypto.scm | 290 ------------------------
tests/pki.scm | 4 +-
tests/publish.scm | 4 +-
tests/pypi.scm | 2 +-
tests/store-deduplication.scm | 2 +-
tests/store.scm | 2 +-
tests/substitute.scm | 4 +-
55 files changed, 175 insertions(+), 1239 deletions(-)
delete mode 100644 guix/gcrypt.scm
delete mode 100644 guix/hash.scm
delete mode 100644 guix/pk-crypto.scm
delete mode 100644 tests/hash.scm
delete mode 100644 tests/pk-crypto.scm

--
2.18.0
L
L
Ludovic Courtès wrote on 2 Sep 2018 00:26
[PATCH 1/1] Switch to Guile-Gcrypt.
(address . 32606@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
20180901222651.2418-1-ludo@gnu.org
This removes (guix hash) and (guix pk-crypto), which now live as part of
Guile-Gcrypt (version 0.1.0.)

* guix/gcrypt.scm, guix/hash.scm, guix/pk-crypto.scm,
tests/hash.scm, tests/pk-crypto.scm: Remove.
* configure.ac: Test for Guile-Gcrypt. Remove LIBGCRYPT and
LIBGCRYPT_LIBDIR assignments.
* m4/guix.m4 (GUIX_ASSERT_LIBGCRYPT_USABLE): Remove.
* README: Add Guile-Gcrypt to the dependencies; move libgcrypt as
"required unless --disable-daemon".
* doc/guix.texi (Requirements): Likewise.
* gnu/packages/bash.scm, guix/derivations.scm, guix/docker.scm,
guix/git.scm, guix/http-client.scm, guix/import/cpan.scm,
guix/import/cran.scm, guix/import/crate.scm, guix/import/elpa.scm,
guix/import/gnu.scm, guix/import/hackage.scm,
guix/import/texlive.scm, guix/import/utils.scm, guix/nar.scm,
guix/pki.scm, guix/scripts/archive.scm,
guix/scripts/authenticate.scm, guix/scripts/download.scm,
guix/scripts/hash.scm, guix/scripts/pack.scm,
guix/scripts/publish.scm, guix/scripts/refresh.scm,
guix/scripts/substitute.scm, guix/store.scm,
guix/store/deduplication.scm, guix/tests.scm, tests/base32.scm,
tests/builders.scm, tests/challenge.scm, tests/cpan.scm,
tests/crate.scm, tests/derivations.scm, tests/gem.scm,
tests/nar.scm, tests/opam.scm, tests/pki.scm,
tests/publish.scm, tests/pypi.scm, tests/store-deduplication.scm,
tests/store.scm, tests/substitute.scm: Adjust imports.
* gnu/system/vm.scm: Likewise.
(guile-sqlite3&co): Rename to...
(gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT.
(expression->derivation-in-linux-vm)[config]: Remove.
(iso9660-image)[config]: Remove.
(qemu-image)[config]: Remove.
(system-docker-image)[config]: Remove.
* guix/scripts/pack.scm: Adjust imports.
(guile-sqlite3&co): Rename to...
(gcrypt-sqlite3&co): ... this. Add GUILE-GCRYPT.
(self-contained-tarball)[build]: Call 'make-config.scm' without
#:libgcrypt argument.
(squashfs-image)[libgcrypt]: Remove.
[build]: Call 'make-config.scm' without #:libgcrypt.
(docker-image)[config, json]: Remove.
[build]: Add GUILE-GCRYPT to the extensions Remove (guix config) from
the imported modules.
* guix/self.scm (specification->package): Remove "libgcrypt", add
"guile-gcrypt".
(compiled-guix): Remove #:libgcrypt.
[guile-gcrypt]: New variable.
[dependencies]: Add it.
[*core-modules*]: Remove #:libgcrypt from 'make-config.scm' call.
Add #:extensions.
[*config*]: Remove #:libgcrypt from 'make-config.scm' call.
(%dependency-variables): Remove %libgcrypt.
(make-config.scm): Remove #:libgcrypt.
* build-aux/build-self.scm (guile-gcrypt): New variable.
(make-config.scm): Remove #:libgcrypt.
(build-program)[fake-gcrypt-hash]: New variable.
Add (gcrypt hash) to the imported modules. Adjust load path
assignments.
---
Makefile.am | 5 -
README | 3 +-
build-aux/build-self.scm | 81 ++++++-
configure.ac | 13 +-
doc/guix.texi | 4 +-
gnu/packages/bash.scm | 2 +-
gnu/system/vm.scm | 48 ++--
guix/derivations.scm | 2 +-
guix/docker.scm | 2 +-
guix/gcrypt.scm | 49 ----
guix/git.scm | 2 +-
guix/hash.scm | 184 ---------------
guix/http-client.scm | 2 +-
guix/import/cpan.scm | 2 +-
guix/import/cran.scm | 2 +-
guix/import/crate.scm | 2 +-
guix/import/elpa.scm | 2 +-
guix/import/gnu.scm | 2 +-
guix/import/hackage.scm | 2 +-
guix/import/texlive.scm | 2 +-
guix/import/utils.scm | 2 +-
guix/nar.scm | 4 +-
guix/pk-crypto.scm | 407 ----------------------------------
guix/pki.scm | 2 +-
guix/scripts/archive.scm | 2 +-
guix/scripts/authenticate.scm | 2 +-
guix/scripts/download.scm | 2 +-
guix/scripts/hash.scm | 6 +-
guix/scripts/pack.scm | 60 ++---
guix/scripts/publish.scm | 4 +-
guix/scripts/refresh.scm | 2 +-
guix/scripts/substitute.scm | 4 +-
guix/self.scm | 26 +--
guix/store.scm | 2 +-
guix/store/deduplication.scm | 2 +-
guix/tests.scm | 2 +-
m4/guix.m4 | 18 --
tests/base32.scm | 2 +-
tests/builders.scm | 2 +-
tests/challenge.scm | 2 +-
tests/cpan.scm | 2 +-
tests/crate.scm | 2 +-
tests/derivations.scm | 2 +-
tests/gem.scm | 2 +-
tests/hash.scm | 128 -----------
tests/nar.scm | 2 +-
tests/opam.scm | 2 +-
tests/packages.scm | 2 +-
tests/pk-crypto.scm | 290 ------------------------
tests/pki.scm | 4 +-
tests/publish.scm | 4 +-
tests/pypi.scm | 2 +-
tests/store-deduplication.scm | 2 +-
tests/store.scm | 2 +-
tests/substitute.scm | 4 +-
55 files changed, 175 insertions(+), 1239 deletions(-)
delete mode 100644 guix/gcrypt.scm
delete mode 100644 guix/hash.scm
delete mode 100644 guix/pk-crypto.scm
delete mode 100644 tests/hash.scm
delete mode 100644 tests/pk-crypto.scm

Toggle diff (359 lines)
diff --git a/Makefile.am b/Makefile.am
index 324674a60..8ffee98c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -63,9 +63,6 @@ MODULES = \
guix/base64.scm \
guix/cpio.scm \
guix/records.scm \
- guix/gcrypt.scm \
- guix/hash.scm \
- guix/pk-crypto.scm \
guix/pki.scm \
guix/progress.scm \
guix/combinators.scm \
@@ -329,8 +326,6 @@ SCM_TESTS = \
tests/base32.scm \
tests/base64.scm \
tests/cpio.scm \
- tests/hash.scm \
- tests/pk-crypto.scm \
tests/pki.scm \
tests/print.scm \
tests/sets.scm \
diff --git a/README b/README
index 348a7ada5..4c76c4bc4 100644
--- a/README
+++ b/README
@@ -21,7 +21,7 @@ Guix is based on the [[https://nixos.org/nix/][Nix]] package manager.
GNU Guix currently depends on the following packages:
- [[https://gnu.org/software/guile/][GNU Guile 2.2.x or 2.0.x]], version 2.0.13 or later
- - [[https://gnupg.org/][GNU libgcrypt]]
+ - [[https://notabug.org/cwebber/guile-gcrypt][Guile-Gcrypt]] 0.1.0 or later
- [[https://www.gnu.org/software/make/][GNU Make]]
- [[https://www.gnutls.org][GnuTLS]] compiled with guile support enabled
- [[https://notabug.org/civodul/guile-sqlite3][Guile-SQLite3]], version 0.1.0 or later
@@ -31,6 +31,7 @@ GNU Guix currently depends on the following packages:
Unless `--disable-daemon' was passed, the following packages are needed:
+ - [[https://gnupg.org/][GNU libgcrypt]]
- [[https://sqlite.org/][SQLite 3]]
- [[https://gcc.gnu.org][GCC's g++]]
- optionally [[http://www.bzip.org][libbz2]]
diff --git a/build-aux/build-self.scm b/build-aux/build-self.scm
index 3ecdc931a..f472724f1 100644
--- a/build-aux/build-self.scm
+++ b/build-aux/build-self.scm
@@ -22,6 +22,7 @@
#:use-module (guix ui)
#:use-module (guix config)
#:use-module (guix modules)
+ #:use-module (guix build-system gnu)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:use-module (rnrs io ports)
@@ -72,7 +73,7 @@
(variables rest ...))))))
(variables %localstatedir %storedir %sysconfdir %system)))
-(define* (make-config.scm #:key libgcrypt zlib gzip xz bzip2
+(define* (make-config.scm #:key zlib gzip xz bzip2
(package-name "GNU Guix")
(package-version "0")
(bug-report-address "bug-guix@gnu.org")
@@ -92,7 +93,6 @@
%state-directory
%store-database-directory
%config-directory
- %libgcrypt
%libz
%gzip
%bzip2
@@ -137,9 +137,6 @@
(define %xz
#+(and xz (file-append xz "/bin/xz")))
- (define %libgcrypt
- #+(and libgcrypt
- (file-append libgcrypt "/lib/libgcrypt")))
(define %libz
#+(and zlib
(file-append zlib "/lib/libz")))))))
@@ -200,6 +197,44 @@ person's version identifier."
;; XXX: Replace with a Git commit id.
(date->string (current-date 0) "~Y~m~d.~H"))
+(define guile-gcrypt
+ ;; The host Guix may or may not have 'guile-gcrypt', which was introduced in
+ ;; August 2018. If it has it, it's at least version 0.1.0, which is good
+ ;; enough. If it doesn't, specify our own package because the target Guix
+ ;; requires it.
+ (match (find-best-packages-by-name "guile-gcrypt" #f)
+ (()
+ (package
+ (name "guile-gcrypt")
+ (version "0.1.0")
+ (home-page "https://notabug.org/cwebber/guile-gcrypt")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append home-page "/archive/v" version ".tar.gz"))
+ (sha256
+ (base32
+ "1gir7ifknbmbvjlql5j6wzk7bkb5lnmq80q59ngz43hhpclrk5k3"))
+ (file-name (string-append name "-" version ".tar.gz"))))
+ (build-system gnu-build-system)
+ (native-inputs
+ `(("pkg-config" ,(specification->package "pkg-config"))
+ ("autoconf" ,(specification->package "autoconf"))
+ ("automake" ,(specification->package "automake"))
+ ("texinfo" ,(specification->package "texinfo"))))
+ (inputs
+ `(("guile" ,(specification->package "guile"))
+ ("libgcrypt" ,(specification->package "libgcrypt"))))
+ (synopsis "Cryptography library for Guile using Libgcrypt")
+ (description
+ "Guile-Gcrypt provides a Guile 2.x interface to a subset of the
+GNU Libgcrypt crytographic library. It provides modules for cryptographic
+hash functions, message authentication codes (MAC), public-key cryptography,
+strong randomness, and more. It is implemented using the foreign function
+interface (FFI) of Guile.")
+ (license #f))) ;license:gpl3+
+ ((package . _)
+ package)))
+
(define* (build-program source version
#:optional (guile-version (effective-version))
#:key (pull-version 0))
@@ -212,10 +247,21 @@ person's version identifier."
(('gnu _ ...) #t)
(_ #f)))
+ (define fake-gcrypt-hash
+ ;; Fake (gcrypt hash) module; see below.
+ (scheme-file "hash.scm"
+ #~(define-module (gcrypt hash)
+ #:export (sha1 sha256))))
+
(with-imported-modules `(((guix config)
- => ,(make-config.scm
- #:libgcrypt
- (specification->package "libgcrypt")))
+ => ,(make-config.scm))
+
+ ;; To avoid relying on 'with-extensions', which was
+ ;; introduced in 0.15.0, provide a fake (gcrypt
+ ;; hash) just so that we can build modules, and
+ ;; adjust %LOAD-PATH later on.
+ ((gcrypt hash) => ,fake-gcrypt-hash)
+
,@(source-module-closure `((guix store)
(guix self)
(guix derivations)
@@ -237,13 +283,24 @@ person's version identifier."
(match %load-path
((front _ ...)
(unless (string=? front source) ;already done?
- (set! %load-path (list source front)))))))
+ (set! %load-path
+ (list source
+ (string-append #$guile-gcrypt
+ "/share/guile/site/"
+ (effective-version))
+ front)))))))
- ;; Only load our own modules or those of Guile.
+ ;; Only load Guile-Gcrypt, our own modules, or those
+ ;; of Guile.
(match %load-compiled-path
((front _ ... sys1 sys2)
- (set! %load-compiled-path
- (list front sys1 sys2)))))
+ (unless (string-prefix? #$guile-gcrypt front)
+ (set! %load-compiled-path
+ (list (string-append #$guile-gcrypt
+ "/lib/guile/"
+ (effective-version)
+ "/site-ccache")
+ front sys1 sys2))))))
(use-modules (guix store)
(guix self)
diff --git a/configure.ac b/configure.ac
index b34f15a77..c83d4d8a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,6 +130,11 @@ if test "x$guix_cv_have_recent_guile_sqlite3" != "xyes"; then
AC_MSG_ERROR([A recent Guile-SQLite3 could not be found; please install it.])
fi
+GUILE_MODULE_AVAILABLE([have_guile_gcrypt], [(gcrypt hash)])
+if test "x$have_guile_gcrypt" != "xyes"; then
+ AC_MSG_ERROR([Guile-Gcrypt could not be found; please install it.])
+fi
+
dnl Make sure we have a full-fledged Guile.
GUIX_ASSERT_GUILE_FEATURES([regex posix socket net-db threads])
@@ -213,16 +218,10 @@ AC_ARG_WITH([libgcrypt-libdir],
esac])
dnl If none of the --with-libgcrypt-* options was used, try to determine the
-dnl absolute file name of libgcrypt.so.
+dnl the library directory.
case "x$LIBGCRYPT_PREFIX$LIBGCRYPT_LIBDIR" in
xnono)
GUIX_LIBGCRYPT_LIBDIR([LIBGCRYPT_LIBDIR])
- if test "x$LIBGCRYPT_LIBDIR" != x; then
- LIBGCRYPT="$LIBGCRYPT_LIBDIR/libgcrypt"
- else
- dnl 'config-daemon.ac' expects "no" in this case.
- LIBGCRYPT_LIBDIR="no"
- fi
;;
esac
diff --git a/doc/guix.texi b/doc/guix.texi
index 861105979..313e12387 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -619,7 +619,8 @@ GNU Guix depends on the following packages:
@itemize
@item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.13 or
later, including 2.2.x;
-@item @url{http://gnupg.org/, GNU libgcrypt};
+@item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
+0.1.0 or later;
@item
@uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
(@pxref{Guile Preparations, how to install the GnuTLS bindings for
@@ -661,6 +662,7 @@ Unless @code{--disable-daemon} was passed to @command{configure}, the
following packages are also needed:
@itemize
+@item @url{http://gnupg.org/, GNU libgcrypt};
@item @url{http://sqlite.org, SQLite 3};
@item @url{http://gcc.gnu.org, GCC's g++}, with support for the
C++11 standard.
diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 64f7782f5..121a459fa 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -36,7 +36,7 @@
#:use-module (guix store)
#:use-module (guix build-system gnu)
#:autoload (guix gnupg) (gnupg-verify*)
- #:autoload (guix hash) (port-sha256)
+ #:autoload (gcrypt hash) (port-sha256)
#:autoload (guix base32) (bytevector->nix-base32-string)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index b505b0cf6..3898872a4 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -32,7 +32,7 @@
#:use-module (guix modules)
#:use-module (guix scripts pack)
#:use-module (guix utils)
- #:use-module (guix hash)
+ #:use-module (gcrypt hash)
#:use-module (guix base32)
#:use-module ((guix self) #:select (make-config.scm))
@@ -43,7 +43,7 @@
#:use-module (gnu packages cdrom)
#:use-module (gnu packages compression)
#:use-module (gnu packages guile)
- #:autoload (gnu packages gnupg) (libgcrypt)
+ #:autoload (gnu packages gnupg) (guile-gcrypt)
#:use-module (gnu packages gawk)
#:use-module (gnu packages bash)
#:use-module (gnu packages less)
@@ -124,10 +124,12 @@
(('gnu rest ...) #t)
(rest #f)))
-(define guile-sqlite3&co
- ;; Guile-SQLite3 and its propagated inputs.
- (cons guile-sqlite3
- (package-transitive-propagated-inputs guile-sqlite3)))
+(define gcrypt-sqlite3&co
+ ;; Guile-Gcrypt, Guile-SQLite3, and their propagated inputs.
+ (append-map (lambda (package)
+ (cons package
+ (package-transitive-propagated-inputs package)))
+ (list guile-gcrypt guile-sqlite3)))
(define* (expression->derivation-in-linux-vm name exp
#:key
@@ -164,10 +166,6 @@ based on the size of the closure of REFERENCES-GRAPHS.
When REFERENCES-GRAPHS is true, it must be a list of file name/store path
pairs, as for `derivation'. The files containing the reference graphs are
made available under the /xchg CIFS share."
- (define config
- ;; (guix config) module for consumption by (guix gcrypt).
- (make-config.scm #:libgcrypt libgcrypt))
-
(define user-builder
(program-file "builder-in-linux-vm" exp))
@@ -195,12 +193,14 @@ made available under the /xchg CIFS share."
(define builder
;; Code that launches the VM that evaluates EXP.
- (with-extensions guile-sqlite3&co
+ (with-extensions gcrypt-sqlite3&co
(with-imported-modules `(,@(source-module-closure
'((guix build utils)
(gnu build vm))
#:select? not-config?)
- ((guix config) => ,config))
+
+ ;; For consumption by (gnu store database).
+ ((guix config) => ,(make-config.scm)))
#~(begin
(use-modules (guix build utils)
(gnu build vm))
@@ -255,9 +255,6 @@ made available under the /xchg CIFS share."
"Return a bootable, stand-alone iso9660 image.
INPUTS is a list of inputs (as for packages)."
- (define config
- (make-config.scm #:libgcrypt libgcrypt))
-
(define schema
(and register-closures?
(local-file (search-path %load-path
@@ -265,12 +262,12 @@ INPUTS is a list of inputs (as for packages)."
(expression->derivation-in-linux-vm
name
- (with-extensions guile-sqlite3&co
+ (with-extensions gcrypt-sqlite3&co
(with-imported-modules `(,@(source-module-closure '((gnu build vm)
(guix store database)
(guix build utils))
#:select? not-config?)
- ((guix config) => ,config))
+ ((guix config) => ,(make-config.scm)))
#~(begin
(use-modules (gnu build vm)
(guix store database)
@@ -347,9 +344,6 @@ INPUTS is a list of inputs (as for packages). When COPY-INPUTS? is true, copy
all of INPUTS into the image being built. When REGISTER-CLOSURES? is true,
register INPUTS in the store database of the image so that Guix can be used in
the image."
- (define config
- (make-config.scm #:libgcrypt libgcrypt))
-
(define schema
(and register-closures?
(local-file (search-path %load-path
@@ -357,13 +351,13 @@ the image."
(expression->derivation-in-linux-vm
name
- (with-extensions guile-sqlite3&co
+ (wit
This message was truncated. Download the full message here.
L
L
Ludovic Courtès wrote on 4 Sep 2018 17:56
(address . 32606-done@debbugs.gnu.org)
87d0tt9rz9.fsf@gnu.org
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (3 lines)
> This removes (guix hash) and (guix pk-crypto), which now live as part of
> Guile-Gcrypt (version 0.1.0.)

Pushed as commit ca719424455465fca4b872c371daf2a46de88b33!

Ludo’.
Closed
?