From 88ecd1dc25f7fe4e407027251863d6aa69499905 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Thu, 3 Mar 2016 11:00:59 -0700 Subject: [PATCH] Fix plugin testing, -available? predicates, install hooks. Signal an error (not warning) if a plugin is not tested because it appears to be unavailable. --- src/blowfish/Makefile.am | 6 ++- src/blowfish/README | 2 +- src/blowfish/blowfish-check.scm | 4 +- src/blowfish/blowfish.pkg | 8 +++- src/blowfish/blowfish.scm | 7 +--- src/blowfish/check.scm | 2 +- src/blowfish/compile.scm | 2 +- src/gdbm/Makefile.am | 6 ++- src/gdbm/README | 2 +- src/gdbm/check.scm | 2 +- src/gdbm/compile.scm | 2 +- src/gdbm/gdbm-check.scm | 4 +- src/gdbm/gdbm.pkg | 10 +++-- src/gdbm/gdbm.scm | 7 +--- src/mcrypt/Makefile.am | 6 ++- src/mcrypt/README | 2 +- src/mcrypt/check.scm | 2 +- src/mcrypt/compile.scm | 2 +- src/mcrypt/mcrypt-check.scm | 4 +- src/mcrypt/mcrypt.pkg | 10 ++--- src/mcrypt/mcrypt.scm | 11 ++---- src/md5/Makefile.am | 6 ++- src/md5/README | 2 +- src/md5/check.scm | 2 +- src/md5/compile.scm | 2 +- src/md5/md5-check.scm | 4 +- src/md5/md5.pkg | 8 +++- src/md5/md5.scm | 10 ++--- src/mhash/Makefile.am | 6 ++- src/mhash/README | 2 +- src/mhash/check.scm | 2 +- src/mhash/compile.scm | 2 +- src/mhash/mhash-check.scm | 4 +- src/mhash/mhash.pkg | 8 +++- src/mhash/mhash.scm | 68 ++++++++++++++++----------------- 35 files changed, 126 insertions(+), 101 deletions(-) diff --git a/src/blowfish/Makefile.am b/src/blowfish/Makefile.am index e5cb8c035..c8fdbde84 100644 --- a/src/blowfish/Makefile.am +++ b/src/blowfish/Makefile.am @@ -66,6 +66,10 @@ CLEANFILES += test TESTS = check-scm -install-data-hook uninstall-data-hook: +install-data-hook: + echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ + | $(MIT_SCHEME_EXE) --batch-mode + +uninstall-hook: echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ | $(MIT_SCHEME_EXE) --batch-mode diff --git a/src/blowfish/README b/src/blowfish/README index 400ff5ac3..3d283be3c 100644 --- a/src/blowfish/README +++ b/src/blowfish/README @@ -1,4 +1,4 @@ -The blowfish wrapper. +The BLOWFISH option. This is a drop-in replacement for the bfish microcode module and runtime/blowfish.scm. It is not part of the core build and can be diff --git a/src/blowfish/blowfish-check.scm b/src/blowfish/blowfish-check.scm index a2696d282..2f89d742f 100644 --- a/src/blowfish/blowfish-check.scm +++ b/src/blowfish/blowfish-check.scm @@ -24,10 +24,10 @@ USA. |# -;;;; Test the Blowfish wrapper. +;;;; Test the BLOWFISH option. (if (not (blowfish-available?)) - (warn "blowfish wrapper not found") + (error "BLOWFISH plugin not found") (let ((sample "Some text to encrypt and decrypt.")) (call-with-binary-output-file "test" (lambda (output) diff --git a/src/blowfish/blowfish.pkg b/src/blowfish/blowfish.pkg index 6d03fd489..34685216b 100644 --- a/src/blowfish/blowfish.pkg +++ b/src/blowfish/blowfish.pkg @@ -31,7 +31,7 @@ USA. (parent ()) ;; You'll have to import these from (global-definitions blowfish/). ;; They are currently bound in () by exports from (runtime blowfish). - #;(export #f + (export (blowfish global) blowfish-available? blowfish-cbc blowfish-cfb64 @@ -42,4 +42,8 @@ USA. blowfish-set-key compute-blowfish-init-vector read-blowfish-file-header - write-blowfish-file-header)) \ No newline at end of file + write-blowfish-file-header)) + +(define-package (blowfish global) + ;; Just to get cref to analyze whether all exports are defined. + ) \ No newline at end of file diff --git a/src/blowfish/blowfish.scm b/src/blowfish/blowfish.scm index 71adaa400..9107cc400 100644 --- a/src/blowfish/blowfish.scm +++ b/src/blowfish/blowfish.scm @@ -24,7 +24,7 @@ USA. |# -;;;; Blowfish wrapper +;;;; The BLOWFISH option. ;;; package: (blowfish) (declare (usual-integrations)) @@ -172,10 +172,7 @@ USA. operator))) (define (blowfish-available?) - (let ((path (ignore-errors (lambda () - (system-library-pathname "blowfish-shim.so"))))) - (and (pathname? path) - (file-loadable? path)))) + (plugin-available? "blowfish")) (define (blowfish-encrypt-port input output key init-vector encrypt?) ;; Assumes that INPUT is in blocking mode. diff --git a/src/blowfish/check.scm b/src/blowfish/check.scm index 36ce18590..2c6c1bed2 100644 --- a/src/blowfish/check.scm +++ b/src/blowfish/check.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Test the Blowfish wrapper. +;;;; Test the BLOWFISH option. (load "make") (with-system-library-directories diff --git a/src/blowfish/compile.scm b/src/blowfish/compile.scm index 477c7c8ba..d42c8b7c3 100644 --- a/src/blowfish/compile.scm +++ b/src/blowfish/compile.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Compile the Blowfish wrapper. +;;;; Compile the BLOWFISH option. (load-option 'CREF) (load-option 'FFI) diff --git a/src/gdbm/Makefile.am b/src/gdbm/Makefile.am index f19e4008b..5709e13e4 100644 --- a/src/gdbm/Makefile.am +++ b/src/gdbm/Makefile.am @@ -64,6 +64,10 @@ CLEANFILES += test TESTS = check-scm -install-data-hook uninstall-data-hook: +install-data-hook: + echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ + | $(MIT_SCHEME_EXE) --batch-mode + +uninstall-hook: echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ | $(MIT_SCHEME_EXE) --batch-mode diff --git a/src/gdbm/README b/src/gdbm/README index fee1fa66b..3bacf4c61 100644 --- a/src/gdbm/README +++ b/src/gdbm/README @@ -1,4 +1,4 @@ -The GDBM wrapper. +The GDBM option. This is a drop-in replacement for the gdbm microcode module and runtime/gdbm.scm. It is not part of the core build and can be built diff --git a/src/gdbm/check.scm b/src/gdbm/check.scm index 77bbd67a1..62b8095e2 100644 --- a/src/gdbm/check.scm +++ b/src/gdbm/check.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Test the GDBM wrapper. +;;;; Test the GDBM option. (load "make") (with-system-library-directories diff --git a/src/gdbm/compile.scm b/src/gdbm/compile.scm index 2052264a1..2479f78ec 100644 --- a/src/gdbm/compile.scm +++ b/src/gdbm/compile.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Compile the GDBM wrapper. +;;;; Compile the GDBM option. (load-option 'CREF) (load-option 'FFI) diff --git a/src/gdbm/gdbm-check.scm b/src/gdbm/gdbm-check.scm index 9e2f23940..e35559b88 100644 --- a/src/gdbm/gdbm-check.scm +++ b/src/gdbm/gdbm-check.scm @@ -24,10 +24,10 @@ USA. |# -;;;; Test the GDBM wrapper. +;;;; Test the GDBM option. (if (not (gdbm-available?)) - (warn "gdbm wrapper not found") + (error "GDBM plugin not found") (let ((filename.db "gdbm-check.db")) (ignore-errors (lambda () (delete-file filename.db))) (let ((dbf (gdbm-open filename.db 0 GDBM_WRCREAT #o660))) diff --git a/src/gdbm/gdbm.pkg b/src/gdbm/gdbm.pkg index ad4b313f4..05823348a 100644 --- a/src/gdbm/gdbm.pkg +++ b/src/gdbm/gdbm.pkg @@ -32,7 +32,7 @@ USA. (initialization (initialize-package!)) ;; You'll have to import these from (global-definitions gdbm/). ;; They are currently bound in () by exports from (runtime gdbm). - #;(export #f + (export (gdbm global) gdbm-available? gdbm-close gdbm-delete @@ -48,10 +48,14 @@ USA. gdbm-version gdbm_cachesize gdbm_fast - gdbm_fastmode + ;;gdbm_fastmode obsolete gdbm_insert gdbm_newdb gdbm_reader gdbm_replace gdbm_wrcreat - gdbm_writer)) \ No newline at end of file + gdbm_writer)) + +(define-package (gdbm global) + ;; Just to get cref to analyze whether all exports are defined. + ) \ No newline at end of file diff --git a/src/gdbm/gdbm.scm b/src/gdbm/gdbm.scm index 996c72adb..7295f805d 100644 --- a/src/gdbm/gdbm.scm +++ b/src/gdbm/gdbm.scm @@ -24,7 +24,7 @@ USA. |# -;;;; GDBM wrapper +;;;; The GDBM option. ;;; package: (gdbm) (declare (usual-integrations)) @@ -32,10 +32,7 @@ USA. (C-include "gdbm") (define (gdbm-available?) - (let ((path (ignore-errors (lambda () - (system-library-pathname "gdbm-shim.so"))))) - (and (pathname? path) - (file-loadable? path)))) + (plugin-available? "gdbm")) ;; Parameters to gdbm_open for READERS, WRITERS, and WRITERS who can ;; create the database. diff --git a/src/mcrypt/Makefile.am b/src/mcrypt/Makefile.am index fe30bad10..6c1cddbd8 100644 --- a/src/mcrypt/Makefile.am +++ b/src/mcrypt/Makefile.am @@ -65,6 +65,10 @@ CLEANFILES += test TESTS = check-scm -install-data-hook uninstall-data-hook: +install-data-hook: + echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ + | $(MIT_SCHEME_EXE) --batch-mode + +uninstall-hook: echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ | $(MIT_SCHEME_EXE) --batch-mode diff --git a/src/mcrypt/README b/src/mcrypt/README index d48e8c2e0..7a73aaf9a 100644 --- a/src/mcrypt/README +++ b/src/mcrypt/README @@ -1,4 +1,4 @@ -The mcrypt wrapper. +The MCRYPT option. This is a drop-in replacement for the mcrypt microcode module and the mcrypt-* procedures in runtime/crypto.scm. It is not part of the core diff --git a/src/mcrypt/check.scm b/src/mcrypt/check.scm index fc1f17c31..f47a4edaa 100644 --- a/src/mcrypt/check.scm +++ b/src/mcrypt/check.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Test the mcrypt wrapper. +;;;; Test the MCRYPT option. (load "make") (with-system-library-directories diff --git a/src/mcrypt/compile.scm b/src/mcrypt/compile.scm index 0479bc167..c5576c077 100644 --- a/src/mcrypt/compile.scm +++ b/src/mcrypt/compile.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Compile the mcrypt wrapper. +;;;; Compile the MCRYPT option. (load-option 'CREF) (load-option 'FFI) diff --git a/src/mcrypt/mcrypt-check.scm b/src/mcrypt/mcrypt-check.scm index 4b61be195..628d020cc 100644 --- a/src/mcrypt/mcrypt-check.scm +++ b/src/mcrypt/mcrypt-check.scm @@ -24,7 +24,7 @@ USA. |# -;;;; Test the mcrypt wrapper. +;;;; Test the MCRYPT option. (define (random-string length) (list->string (make-initialized-list length @@ -33,7 +33,7 @@ USA. (ascii->char (random 256)))))) (if (not (mcrypt-available?)) - (warn "mcrypt plugin not found") + (error "MCRYPT plugin not found") (begin (if (not (member "tripledes" (mcrypt-algorithm-names))) (error "No tripledes.")) diff --git a/src/mcrypt/mcrypt.pkg b/src/mcrypt/mcrypt.pkg index 4b75d2b7e..5bff03316 100644 --- a/src/mcrypt/mcrypt.pkg +++ b/src/mcrypt/mcrypt.pkg @@ -26,10 +26,6 @@ USA. (global-definitions runtime/) -(define-package (mcrypt global) - ;; Just to get cref to analyze whether all exports are defined. - ) - (define-package (mcrypt) (files "mcrypt") (parent ()) @@ -55,4 +51,8 @@ USA. mcrypt-mode-names mcrypt-open-module mcrypt-self-test - mcrypt-supported-key-sizes)) \ No newline at end of file + mcrypt-supported-key-sizes)) + +(define-package (mcrypt global) + ;; Just to get cref to analyze whether all exports are defined. + ) \ No newline at end of file diff --git a/src/mcrypt/mcrypt.scm b/src/mcrypt/mcrypt.scm index 810fa0a6b..841dbcb16 100644 --- a/src/mcrypt/mcrypt.scm +++ b/src/mcrypt/mcrypt.scm @@ -24,7 +24,7 @@ USA. |# -;;;; mcrypt wrapper +;;;; The MCRYPT option. ;;; package: (mcrypt) (declare (usual-integrations)) @@ -41,7 +41,7 @@ USA. ;;; multithreaded application... with dynamic module loading support". ;;; It is assumed this is the case for MIT Scheme. ;;; -;;; This wrapper uses an OS mutex to implement lock and unlock +;;; This plugin uses an OS mutex to implement lock and unlock ;;; functions passed to mcrypt_mutex_register, and locks and unlocks ;;; it during mcrypt_module_open. The Scheme mcrypt-context object, ;;; representing an MCRYPT "thread", should be used by one Scheme @@ -80,7 +80,7 @@ USA. ;;; mcrypt_list_algorithms and ;;; mcrypt_list_modes. ;;; -;;; This wrapper ensures that MCRYPTs and size/name lists returned by +;;; This plugin ensures that MCRYPTs and size/name lists returned by ;;; the library do not "leak" by putting cleanup thunks on a weak ;;; alist that is periodically scanned for objects that were GCed and ;;; not freed. @@ -92,10 +92,7 @@ USA. (define mcrypt-mode-names-vector) (define (mcrypt-available?) - (let ((path (ignore-errors (lambda () - (system-library-pathname "mcrypt-shim.so"))))) - (and (pathname? path) - (file-loadable? path)))) + (plugin-available? "mcrypt")) (define (init!) (if (not mcrypt-initialized?) diff --git a/src/md5/Makefile.am b/src/md5/Makefile.am index 7ac7bd23a..132ed7a50 100644 --- a/src/md5/Makefile.am +++ b/src/md5/Makefile.am @@ -65,6 +65,10 @@ CLEANFILES += test TESTS = check-scm -install-data-hook uninstall-data-hook: +install-data-hook: + echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ + | $(MIT_SCHEME_EXE) --batch-mode + +uninstall-hook: echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ | $(MIT_SCHEME_EXE) --batch-mode diff --git a/src/md5/README b/src/md5/README index de928cc8f..d3a4fdda3 100644 --- a/src/md5/README +++ b/src/md5/README @@ -1,4 +1,4 @@ -The md5 wrapper. +The MD5 option. This is a drop-in replacement for the md5 microcode module and the md5-* procedures in runtime/crypto.scm. It is not part of the core diff --git a/src/md5/check.scm b/src/md5/check.scm index 09647192b..060027afe 100644 --- a/src/md5/check.scm +++ b/src/md5/check.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Test the MD5 wrapper. +;;;; Test the MD5 option. (load "make") (with-system-library-directories diff --git a/src/md5/compile.scm b/src/md5/compile.scm index 749754eb4..93bc0da8b 100644 --- a/src/md5/compile.scm +++ b/src/md5/compile.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Compile the MD5 wrapper. +;;;; Compile the MD5 option. (load-option 'CREF) (load-option 'FFI) diff --git a/src/md5/md5-check.scm b/src/md5/md5-check.scm index eb6beac94..fb86f209b 100644 --- a/src/md5/md5-check.scm +++ b/src/md5/md5-check.scm @@ -24,10 +24,10 @@ USA. |# -;;;; Test the MD5 wrapper. +;;;; Test the MD5 option. (if (not (md5-available?)) - (warn "md5 wrapper not found") + (error "MD5 plugin not found") (let ((sample "Some text to hash.")) (let ((hash (md5-sum->hexadecimal (md5-string sample)))) (if (not (string=? hash "c8e89c4cbf3abf9aa758d691cbe4b784")) diff --git a/src/md5/md5.pkg b/src/md5/md5.pkg index 81282b87c..a6229937c 100644 --- a/src/md5/md5.pkg +++ b/src/md5/md5.pkg @@ -31,10 +31,14 @@ USA. (parent ()) ;; You'll have to import these from (global-definitions md5/). They ;; are currently bound in () by exports from (runtime crypto). - #;(export #f + (export (md5 global) md5-available? md5-file md5-string md5-substring md5-sum->hexadecimal - md5-sum->number)) \ No newline at end of file + md5-sum->number)) + +(define-package (md5 global) + ;; Just to get cref to analyze whether all exports are defined. + ) \ No newline at end of file diff --git a/src/md5/md5.scm b/src/md5/md5.scm index a13877a25..a8052fa66 100644 --- a/src/md5/md5.scm +++ b/src/md5/md5.scm @@ -24,14 +24,15 @@ USA. |# -;;;; MD5 wrapper +;;;; The MD5 option. ;;; package: (md5) (declare (usual-integrations)) (C-include "md5") -(define-integrable (mhash-available?) #f) +(define (mhash-available?) + (plugin-available? "mhash")) (define (%md5-init) ;; Create and return an MD5 digest context. @@ -74,10 +75,7 @@ USA. (%md5-available?))) (define (%md5-available?) - (let ((path (ignore-errors (lambda () - (system-library-pathname "md5-shim.so"))))) - (and (pathname? path) - (file-loadable? path)))) + (plugin-available? "md5")) (define (md5-file filename) (cond ((mhash-available?) diff --git a/src/mhash/Makefile.am b/src/mhash/Makefile.am index 4f3a2c1db..aab510bb5 100644 --- a/src/mhash/Makefile.am +++ b/src/mhash/Makefile.am @@ -65,6 +65,10 @@ CLEANFILES += test TESTS = check-scm -install-data-hook uninstall-data-hook: +install-data-hook: + echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ + | $(MIT_SCHEME_EXE) --batch-mode + +uninstall-hook: echo '(update-optiondb "$(DESTDIR)$(scmlibdir)/")' \ | $(MIT_SCHEME_EXE) --batch-mode diff --git a/src/mhash/README b/src/mhash/README index 6aca4b097..f83f43d52 100644 --- a/src/mhash/README +++ b/src/mhash/README @@ -1,4 +1,4 @@ -The mhash wrapper. +The MHASH option. This is a drop-in replacement for the mhash microcode module and the mhash-* procedures in runtime/crypto.scm. It is not part of the core diff --git a/src/mhash/check.scm b/src/mhash/check.scm index aaaf5065c..a03b9f754 100644 --- a/src/mhash/check.scm +++ b/src/mhash/check.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Test the mhash wrapper. +;;;; Test the MHASH option. (load "make") (with-system-library-directories diff --git a/src/mhash/compile.scm b/src/mhash/compile.scm index e5b92ce1a..9719d7781 100644 --- a/src/mhash/compile.scm +++ b/src/mhash/compile.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- |# -;;;; Compile the mhash wrapper. +;;;; Compile the MHASH option. (load-option 'CREF) (load-option 'FFI) diff --git a/src/mhash/mhash-check.scm b/src/mhash/mhash-check.scm index 0dc297449..7c58c7928 100644 --- a/src/mhash/mhash-check.scm +++ b/src/mhash/mhash-check.scm @@ -24,10 +24,10 @@ USA. |# -;;;; Test the mhash wrapper. +;;;; Test the MHASH option. (if (not (mhash-available?)) - (warn "mhash wrapper not found") + (error "MHASH plugin not found") (let ((sample "Some text to hash.")) (let ((hash (mhash-sum->hexadecimal (mhash-string 'MD5 sample)))) (if (not (string=? hash "c8e89c4cbf3abf9aa758d691cbe4b784")) diff --git a/src/mhash/mhash.pkg b/src/mhash/mhash.pkg index 3eece2637..b0223d92c 100644 --- a/src/mhash/mhash.pkg +++ b/src/mhash/mhash.pkg @@ -32,7 +32,7 @@ USA. (initialization (initialize-package!)) ;; You'll have to import these from (global-definitions mhash/). ;; They are currently bound in () by exports from (runtime crypto). - #;(export #f + (export (mhash global) make-mhash-keygen-type mhash-available? mhash-context? @@ -56,4 +56,8 @@ USA. mhash-sum->hexadecimal mhash-sum->number mhash-type-names - mhash-update)) \ No newline at end of file + mhash-update)) + +(define-package (mhash global) + ;; Just to get cref to analyze whether all exports are defined. + ) \ No newline at end of file diff --git a/src/mhash/mhash.scm b/src/mhash/mhash.scm index 9bccc0a04..1cf152b6d 100644 --- a/src/mhash/mhash.scm +++ b/src/mhash/mhash.scm @@ -24,7 +24,7 @@ USA. |# -;;;; mhash wrapper +;;;; The MHASH option. ;;; package: (mhash) (declare (usual-integrations)) @@ -360,39 +360,39 @@ USA. v))))) (define (mhash-available?) - (let ((path (ignore-errors (lambda () - (system-library-pathname "mhash-shim.so"))))) - (and (pathname? path) - (file-loadable? path) - (begin - (if (not mhash-initialized?) - (begin - (set! mhash-algorithm-names - (make-names-vector - (lambda () (C-call "mhash_count")) - (lambda (hashid) - (let* ((alien (make-alien-to-free - '(* char) - (lambda (alien) - (C-call "mhash_get_hash_name" - alien hashid)))) - (str (c-peek-cstring alien))) - (free alien) - str)))) - (set! mhash-keygen-names - (make-names-vector - (lambda () (C-call "mhash_keygen_count")) - (lambda (keygenid) - (let* ((alien (make-alien-to-free - '(* char) - (lambda (alien) - (C-call "mhash_get_keygen_name" - alien keygenid)))) - (str (c-peek-cstring alien))) - (free alien) - str)))) - (set! mhash-initialized? #t))) - #t)))) + (and (plugin-available? "mhash") + (begin + (initialize-mhash-variables!) + #t))) + +(define (initialize-mhash-variables!) + (if (not mhash-initialized?) + (begin + (set! mhash-algorithm-names + (make-names-vector + (lambda () (C-call "mhash_count")) + (lambda (hashid) + (let* ((alien (make-alien-to-free + '(* char) + (lambda (alien) + (C-call "mhash_get_hash_name" + alien hashid)))) + (str (c-peek-cstring alien))) + (free alien) + str)))) + (set! mhash-keygen-names + (make-names-vector + (lambda () (C-call "mhash_keygen_count")) + (lambda (keygenid) + (let* ((alien (make-alien-to-free + '(* char) + (lambda (alien) + (C-call "mhash_get_keygen_name" + alien keygenid)))) + (str (c-peek-cstring alien))) + (free alien) + str)))) + (set! mhash-initialized? #t)))) (define (reset-mhash-variables!) (set! mhash-initialized? #f) -- 2.25.1