From 550ec8b7e7ddd502ef2afb7bd246c1809523cb72 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 17 Nov 2000 21:20:53 +0000 Subject: [PATCH] configuration changes --- trunk/acconfig.h | 2 + trunk/acinclude.m4 | 23 +++++++ trunk/configure.in | 23 ++++++- trunk/gpgme/Makefile.am | 2 +- trunk/gpgme/data.c | 22 +++++++ trunk/gpgme/gpgme.h | 13 ++++ trunk/gpgme/gpgme.m4 | 134 +++++++++++++++++++++------------------- trunk/gpgme/rungpg.c | 2 +- trunk/tests/mkdemodirs | 44 +++++++++++++ 9 files changed, 198 insertions(+), 67 deletions(-) create mode 100644 trunk/acinclude.m4 create mode 100755 trunk/tests/mkdemodirs diff --git a/trunk/acconfig.h b/trunk/acconfig.h index adcb309..2db9b12 100644 --- a/trunk/acconfig.h +++ b/trunk/acconfig.h @@ -40,6 +40,8 @@ /* Some systems have mkdir that takes a single argument. */ #undef MKDIR_TAKES_ONE_ARG +/* path to the gpg binary */ +#undef GPG_PATH @BOTTOM@ diff --git a/trunk/acinclude.m4 b/trunk/acinclude.m4 new file mode 100644 index 0000000..296639b --- /dev/null +++ b/trunk/acinclude.m4 @@ -0,0 +1,23 @@ +dnl Macros to configure gpgme + +dnl GNUPG_FIX_HDR_VERSION(FILE, NAME) +dnl (wk 2000-11-17) +AC_DEFUN(GNUPG_FIX_HDR_VERSION, + [ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > $srcdir/$1.tmp + if cmp -s $srcdir/$1 $srcdir/$1.tmp 2>/dev/null; then + rm -f $srcdir/$1.tmp + else + rm -f $srcdir/$1 + if mv $srcdir/$1.tmp $srcdir/$1 ; then + : + else + AC_MSG_ERROR([[ +*** Failed to fix the version string macro $2 in $1. +*** The old file has been saved as $1.tmp + ]]) + fi + AC_MSG_WARN([fixed the $2 macro in $1]) + fi + ]) + + diff --git a/trunk/configure.in b/trunk/configure.in index 10aab74..f8301ca 100644 --- a/trunk/configure.in +++ b/trunk/configure.in @@ -13,7 +13,7 @@ AM_MAINTAINER_MODE # AGE, set REVISION to 0. # 3. Interfaces removed (BAD, breaks upward compatibility): Increment # CURRENT, set AGE and REVISION to 0. -AM_INIT_AUTOMAKE(gpgme,0.0.0) +AM_INIT_AUTOMAKE(gpgme,0.0.1) LIBGPGME_LT_CURRENT=0 LIBGPGME_LT_AGE=0 LIBGPGME_LT_REVISION=0 @@ -63,11 +63,32 @@ dnl dnl Checks for system services dnl +AC_PATH_PROG(GPG, gpg) +if test -z "$GPG"; then + AC_MSG_ERROR([[ +*** +*** GnuPG not found. Please install GnuPG first. +*** See http://www.gnupg.org/download.html +*** +]]) +fi +AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG") dnl dnl Create config files dnl +dnl + +dnl Make the version number in gpgme/gpgme.h the same as the one here. +dnl (this is easier than to have a *.in file just for one substitution) +GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION) + +dnl Substitution used for gpgme-config +GPGME_LIBS="-L${libdir} -lgpgme" +GPGME_CFLAGS="" +AC_SUBST(GPGME_LIBS) +AC_SUBST(GPGME_CFLAGS) AC_OUTPUT_COMMANDS([ chmod +x gpgme/gpgme-config diff --git a/trunk/gpgme/Makefile.am b/trunk/gpgme/Makefile.am index acc2305..b65157a 100644 --- a/trunk/gpgme/Makefile.am +++ b/trunk/gpgme/Makefile.am @@ -24,7 +24,7 @@ libgpgme_la_SOURCES = \ key.c key.h \ keylist.c \ rungpg.c rungpg.h status-table.h \ - gpgme.c errors.c + gpgme.c version.c errors.c errors.c : gpgme.h diff --git a/trunk/gpgme/data.c b/trunk/gpgme/data.c index 4a8f6ed..1037166 100644 --- a/trunk/gpgme/data.c +++ b/trunk/gpgme/data.c @@ -210,6 +210,28 @@ _gpgme_data_release_and_return_string ( GpgmeData dh ) return val; } +char * +gpgme_data_release_and_get_mem ( GpgmeData dh, size_t *r_len ) +{ + char *val = NULL; + + if (r_len) + *r_len = 0; + if (dh) { + size_t len = dh->len; + val = dh->private_buffer; + if ( !val && dh->data ) { + val = xtrymalloc ( len ); + if ( val ) + memcpy ( val, dh->data, len ); + } + xfree (dh); + if (val && r_len ) + *r_len = len; + } + return val; +} + GpgmeDataType gpgme_data_get_type ( GpgmeData dh ) diff --git a/trunk/gpgme/gpgme.h b/trunk/gpgme/gpgme.h index f2b8ebc..6c9c766 100644 --- a/trunk/gpgme/gpgme.h +++ b/trunk/gpgme/gpgme.h @@ -27,6 +27,17 @@ extern "C" { #endif #endif +/* + * The version of this header should match the one of the library + * It should not be used by a program because gpgme_check_version(NULL) + * does return the same version. The purpose of this macro is to + * let autoconf (using the AM_PATH_GPGME macro) check that this + * header matches the installed library. + * Warning: Do not edit the next line. configure will do that for you! */ +#define GPGME_VERSION "0.0.1" + + + struct gpgme_context_s; typedef struct gpgme_context_s *GpgmeCtx; @@ -108,6 +119,7 @@ GpgmeError gpgme_data_new_from_file ( GpgmeData *r_dh, const char *fname, int copy ); void gpgme_data_release ( GpgmeData dh ); +char * gpgme_data_release_and_get_mem ( GpgmeData dh, size_t *r_len ); GpgmeDataType gpgme_data_get_type ( GpgmeData dh ); GpgmeError gpgme_data_rewind ( GpgmeData dh ); GpgmeError gpgme_data_read ( GpgmeData dh, @@ -144,6 +156,7 @@ GpgmeError gpgme_op_verify ( GpgmeCtx c, GpgmeData sig, GpgmeData text, /* miscellaneous functions */ +const char *gpgme_check_version ( const char *req_version ); const char *gpgme_strerror (GpgmeError err); diff --git a/trunk/gpgme/gpgme.m4 b/trunk/gpgme/gpgme.m4 index f2dce9a..c00071a 100644 --- a/trunk/gpgme/gpgme.m4 +++ b/trunk/gpgme/gpgme.m4 @@ -3,7 +3,7 @@ dnl $Id$ # Configure paths for GPGME # Shamelessly stolen from the one of XDELTA by Owen Taylor -# Werner Koch 2000-10-27 +# Werner Koch 2000-11-17 dnl AM_PATH_GPGME([MINIMUM-VERSION, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) @@ -13,11 +13,11 @@ AC_DEFUN(AM_PATH_GPGME, [dnl dnl Get the cflags and libraries from the gpgme-config script dnl -AC_ARG_WITH(gpgme-prefix, - [ --with-gpgme-prefix=PFX Prefix where gpgme is installed (optional)], + AC_ARG_WITH(gpgme-prefix, + [ --with-gpgme-prefix=PFX Prefix where gpgme is installed (optional)], gpgme_config_prefix="$withval", gpgme_config_prefix="") -AC_ARG_ENABLE(gpgmetest, - [ --disable-gpgmetest Do not try to compile and run a test gpgme program], + AC_ARG_ENABLE(gpgmetest, + [ --disable-gpgmetest Do not try to compile and run a test gpgme program], , enable_gpgmetest=yes) if test x$gpgme_config_prefix != x ; then @@ -28,7 +28,7 @@ AC_ARG_ENABLE(gpgmetest, fi AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no) - min_gpgme_version=ifelse([$1], ,1.1.0,$1) + min_gpgme_version=ifelse([$1], ,1.0.0,$1) AC_MSG_CHECKING(for gpgme - version >= $min_gpgme_version) no_gpgme="" if test "$GPGME_CONFIG" = "no" ; then @@ -56,49 +56,50 @@ dnl int main () { - system ("touch conf.gpgmetest"); + system ("touch conf.gpgmetest"); - if( strcmp( gcry_check_version(NULL), "$gpgme_config_version" ) ) - { - printf("\n*** 'gpgme-config --version' returned %s, but GPGME (%s)\n", - "$gpgme_config_version", gcry_check_version(NULL) ); - printf("*** was found! If gpgme-config was correct, then it is best\n"); - printf("*** to remove the old version of GPGME. You may also be able to fix the error\n"); - printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); - printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); - printf("*** required on your system.\n"); - printf("*** If gpgme-config was wrong, set the environment variable GPGME_CONFIG\n"); - printf("*** to point to the correct copy of gpgme-config, and remove the file config.cache\n"); - printf("*** before re-running configure\n"); - } - else if ( strcmp(gcry_check_version(NULL), GPGME_VERSION ) ) - { - printf("\n*** GPGME header file (version %s) does not match\n", GPGME_VERSION); - printf("*** library (version %s)\n", gcry_check_version(NULL) ); - } - else - { - if ( gcry_check_version( "$min_gpgme_version" ) ) - { - return 0; - } - else - { - printf("no\n*** An old version of GPGME (%s) was found.\n", - gcry_check_version(NULL) ); - printf("*** You need a version of GPGME newer than %s. The latest version of\n", - "$min_gpgme_version" ); - printf("*** GPGME is always available from ftp://ftp.gnupg.org/pub/gpgme/gnupg.\n"); - printf("*** (It is distributed along with GnuPG).\n"); - printf("*** \n"); - printf("*** If you have already installed a sufficiently new version, this error\n"); - printf("*** probably means that the wrong copy of the gpgme-config shell script is\n"); - printf("*** being found. The easiest way to fix this is to remove the old version\n"); - printf("*** of GPGME, but you can also set the GPGME_CONFIG environment to point to the\n"); - printf("*** correct copy of gpgme-config. (In this case, you will have to\n"); - printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); - printf("*** so that the correct libraries are found at run-time))\n"); - } + if( strcmp( gpgme_check_version(NULL), "$gpgme_config_version" ) ) + { + printf("\n" +"*** 'gpgme-config --version' returned %s, but GPGME (%s) was found!\n", + "$gpgme_config_version", gpgme_check_version(NULL) ); + printf( +"*** If gpgme-config was correct, then it is best to remove the old\n" +"*** version of GPGME. You may also be able to fix the error\n" +"*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n" +"*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n" +"*** required on your system.\n" +"*** If gpgme-config was wrong, set the environment variable GPGME_CONFIG\n" +"*** to point to the correct copy of gpgme-config, \n" +"*** and remove the file config.cache before re-running configure\n" + ); + } + else if ( strcmp(gpgme_check_version(NULL), GPGME_VERSION ) ) + { + printf("\n*** GPGME header file (version %s) does not match\n", + GPGME_VERSION); + printf("*** library (version %s)\n", gpgme_check_version(NULL) ); + } + else + { + if ( gpgme_check_version( "$min_gpgme_version" ) ) + return 0; + printf("no\n" +"*** An old version of GPGME (%s) was found.\n", gpgme_check_version(NULL) ); + printf( +"*** You need a version of GPGME newer than %s.\n", "$min_gpgme_version" ); + printf( +"*** The latest version of GPGME is always available at\n" +"*** ftp://ftp.gnupg.org/pub/gcrypt/alpha/gpgme/\n" +"*** \n" +"*** If you have already installed a sufficiently new version, this error\n" +"*** probably means that the wrong copy of the gpgme-config shell script is\n" +"*** being found. The easiest way to fix this is to remove the old version\n" +"*** of GPGME, but you can also set the GPGME_CONFIG environment to point to\n" +"*** the correct copy of gpgme-config. (In this case, you will have to\n" +"*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n" +"*** so that the correct libraries are found at run-time).\n" + ); } return 1; } @@ -133,21 +134,27 @@ main () #include #include #include -], [ return !!gcry_check_version(NULL); ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding GPGME or finding the wrong" - echo "*** version of GPGME. If it is not finding GPGME, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" - echo "***" ], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means GPGME was incorrectly installed" - echo "*** or that you have moved GPGME since it was installed. In the latter case, you" - echo "*** may want to edit the gpgme-config script: $GPGME_CONFIG" ]) +], [ gpgme_check_version(NULL); return 0 ], + [ +echo "*** The test program compiled, but did not run. This usually means" +echo "*** that the run-time linker is not finding GPGME or finding the wrong" +echo "*** version of GPGME. If it is not finding GPGME, you'll need to set your" +echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" +echo "*** to the installed location Also, make sure you have run ldconfig if" +echo "*** that is required on your system" +echo "***" +echo "*** If you have an old version installed, it is best to remove it," +echo "*** although you may also be able to get things to work by" +echo "*** modifying LD_LIBRARY_PATH" +echo "***" + ], + [ +echo "*** The test program failed to compile or link. See the file config.log" +echo "*** for the exact error that occured. This usually means GPGME was" +echo "*** incorrectly installed or that you have moved GPGME since it was" +echo "*** installed. In the latter case, you may want to edit the" +echo "*** gpgme-config script: $GPGME_CONFIG" + ]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" fi @@ -161,4 +168,3 @@ main () rm -f conf.gpgmetest ]) - diff --git a/trunk/gpgme/rungpg.c b/trunk/gpgme/rungpg.c index a370f5e..991624f 100644 --- a/trunk/gpgme/rungpg.c +++ b/trunk/gpgme/rungpg.c @@ -548,7 +548,7 @@ _gpgme_gpg_spawn( GpgObject gpg, void *opaque ) close (fd); } - execv ("/usr/local/bin/gpg", gpg->argv ); + execv ( GPG_PATH, gpg->argv ); fprintf (stderr,"exec of gpg failed\n"); _exit (8); } diff --git a/trunk/tests/mkdemodirs b/trunk/tests/mkdemodirs new file mode 100755 index 0000000..0808846 --- /dev/null +++ b/trunk/tests/mkdemodirs @@ -0,0 +1,44 @@ +#!/bin/sh + +set -e + +GPG="gpg --batch --quiet --no-secmem-warning" +NAMES='Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India + Juliet Kilo Lima Mike November Oscar Papa Quebec Romeo + Sierra Tango Uniform Victor Whisky XRay Yankee Zulu' + +if [ "$1" = "--clean" ]; then + (for i in $NAMES; do + [ -d $i ] && rm -r $i + done) || true + exit 0 +fi + +[ -z "$srcdir" ] && srcdir="../tests" + + +$GPG --dearmor -o secdemo.gpg --yes $srcdir/secdemo.asc +$GPG --dearmor -o pubdemo.gpg --yes $srcdir/pubdemo.asc +[ -f ./tdb.tmp ] && rm ./tdb.tmp +GPGDEMO="$GPG --homedir . --trustdb-name ./tdb.tmp --no-default-keyring + --keyring pubdemo.gpg --secret-keyring secdemo.gpg" +echo -n "Creating:" +for name in $NAMES; do + echo -n " $name" + [ -d $name ] && rm -r $name + mkdir $name + $GPGDEMO --export-secret-key -o - $name > $name/Secret.gpg + $GPG --homedir $name --import $name/Secret.gpg + $GPGDEMO --export -o - $name > $name/Public.gpg + $GPG --homedir $name --import $name/Public.gpg + [ -f $name/pubring.gpg~ ] && rm $name/pubring.gpg~ +done +echo "." +[ -f ./tdb.tmp ] && rm ./tdb.tmp +rm pubdemo.gpg secdemo.gpg + + + + + + -- 2.26.2