configure: better error handling on session key check.

There are a few changes bundled here:

 * say "No." explicitly if there's a failure.

 * try to avoid implying that gpgme-config is necessary to build
   notmuch itself (it's not, though it may be useful if you need to
   rebuild gmime).

 * leave _check_session_keys and _check_session_keys.c around if
   ./configure fails, so that the user can play with it more easily
   for debugging.

 * let error messages show when _check_session_keys.c is built.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>

Amended by DB: use command -v instead of which.
This commit is contained in:
Daniel Kahn Gillmor 2019-05-20 16:51:59 -04:00 committed by David Bremner
parent f4708ce0b1
commit 7546fd9cf6

16
configure vendored
View file

@ -529,7 +529,7 @@ int main () {
return 0; return 0;
} }
EOF EOF
if ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags} _check_session_keys.c -o _check_session_keys > /dev/null 2>&1 \ if ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags} _check_session_keys.c -o _check_session_keys \
&& TEMP_GPG=$(mktemp -d) \ && TEMP_GPG=$(mktemp -d) \
&& GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < test/gnupg-secret-key.asc \ && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < test/gnupg-secret-key.asc \
&& SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \ && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \
@ -538,17 +538,21 @@ EOF
printf "OK.\n" printf "OK.\n"
else else
cat <<EOF cat <<EOF
No.
*** Error: Could not extract session keys from encrypted message. *** Error: Could not extract session keys from encrypted message.
This is likely due to your GMime having been built against a old This is likely due to your GMime having been built against a old
version of GPGME. version of GPGME.
Please try to rebuild your version of GMime against a more recent Please try to rebuild your version of GMime against a more recent
version of GPGME (at least GPGME 1.8.0). Your current GPGME version version of GPGME (at least GPGME 1.8.0).
is: $(gpgme-config --version)
EOF EOF
rm -rf _check_session_keys.c _check_session_keys "$TEMP_GPG" if command -v gpgme-config >/dev/null; then
printf 'Your current GPGME development version is: %s\n' "$(gpgme-config --version)"
else
printf 'You do not have the GPGME development libraries installed.\n'
fi
rm -rf "$TEMP_GPG"
errors=$((errors + 1)) errors=$((errors + 1))
fi fi
else else
@ -1023,7 +1027,7 @@ for flag in -Wmissing-declarations; do
done done
printf "\n\t%s\n" "${WARN_CFLAGS}" printf "\n\t%s\n" "${WARN_CFLAGS}"
rm -f minimal minimal.c _libversion.c _libversion _libversion.sh rm -f minimal minimal.c _libversion.c _libversion _libversion.sh _check_session_keys.c _check_session_keys
# construct the Makefile.config # construct the Makefile.config
cat > Makefile.config <<EOF cat > Makefile.config <<EOF