unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* clean up session-key configure checks
@ 2019-05-20 20:51 Daniel Kahn Gillmor
  2019-05-20 20:51 ` [PATCH 1/3] configure: better error handling on session key check Daniel Kahn Gillmor
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Daniel Kahn Gillmor @ 2019-05-20 20:51 UTC (permalink / raw)
  To: Notmuch Mail

The Ubuntu linker prefers --as-needed.  This is nice, but it means
that our _check_session_key.c configure-time script (introduced by me
in 30c4fa3702f90572afcd1984dbd7aba70f2b4fd9) fails on xenial.

In the course of debugging the reason, i found several other
infelicities in the error cases in handling that bit of ./configure,
so i'm cleaning those up with this series too.

   --dkg

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] configure: better error handling on session key check.
  2019-05-20 20:51 clean up session-key configure checks Daniel Kahn Gillmor
@ 2019-05-20 20:51 ` Daniel Kahn Gillmor
  2019-05-20 20:52 ` [PATCH 2/3] configure: handle TEMP_GPG more robustly Daniel Kahn Gillmor
  2019-05-20 20:52 ` [PATCH 3/3] configure: make _check_session_keys work with an as-needed linker Daniel Kahn Gillmor
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel Kahn Gillmor @ 2019-05-20 20:51 UTC (permalink / raw)
  To: Notmuch Mail

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>
---
 configure | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index e157aadf..7bb4625e 100755
--- a/configure
+++ b/configure
@@ -529,7 +529,7 @@ int main () {
     return 0;
 }
 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) \
            && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < test/gnupg-secret-key.asc \
            && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \
@@ -538,17 +538,21 @@ EOF
         printf "OK.\n"
     else
         cat <<EOF
-
+No.
 *** Error: Could not extract session keys from encrypted message.
 
 This is likely due to your GMime having been built against a old
 version of GPGME.
 
 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
-is: $(gpgme-config --version)
+version of GPGME (at least GPGME 1.8.0).
 EOF
-        rm -rf _check_session_keys.c _check_session_keys "$TEMP_GPG"
+        if which 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))
     fi
 else
@@ -1023,7 +1027,7 @@ for flag in -Wmissing-declarations; do
 done
 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
 cat > Makefile.config <<EOF
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] configure: handle TEMP_GPG more robustly
  2019-05-20 20:51 clean up session-key configure checks Daniel Kahn Gillmor
  2019-05-20 20:51 ` [PATCH 1/3] configure: better error handling on session key check Daniel Kahn Gillmor
@ 2019-05-20 20:52 ` Daniel Kahn Gillmor
  2019-05-20 20:52 ` [PATCH 3/3] configure: make _check_session_keys work with an as-needed linker Daniel Kahn Gillmor
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel Kahn Gillmor @ 2019-05-20 20:52 UTC (permalink / raw)
  To: Notmuch Mail

We never want ./configure to try to do something with an unassigned
variable.  So, make the directory $TEMP_GPG at the start of the
testing of session-key handling, and clean it up afterwards as long as
the directory exists.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
---
 configure | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 7bb4625e..2531cc39 100755
--- a/configure
+++ b/configure
@@ -529,8 +529,10 @@ int main () {
     return 0;
 }
 EOF
-    if ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags}  _check_session_keys.c -o _check_session_keys \
-           && TEMP_GPG=$(mktemp -d) \
+    if ! TEMP_GPG=$(mktemp -d); then
+        printf 'No.\nCould not make tempdir for testing session-key support.\n'
+        errors=$((errors + 1))
+    elif ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags}  _check_session_keys.c -o _check_session_keys \
            && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < test/gnupg-secret-key.asc \
            && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \
            && [ $SESSION_KEY = 9:0BACD64099D1468AB07C796F0C0AC4851948A658A15B34E803865E9FC635F2F5 ]
@@ -552,9 +554,11 @@ EOF
         else
             printf 'You do not have the GPGME development libraries installed.\n'
         fi
-        rm -rf "$TEMP_GPG"
         errors=$((errors + 1))
     fi
+    if [ -n "$TEMP_GPG" -a -d "$TEMP_GPG" ]; then
+        rm -rf "$TEMP_GPG"
+    fi
 else
     have_gmime=0
     printf "No.\n"
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] configure: make _check_session_keys work with an as-needed linker
  2019-05-20 20:51 clean up session-key configure checks Daniel Kahn Gillmor
  2019-05-20 20:51 ` [PATCH 1/3] configure: better error handling on session key check Daniel Kahn Gillmor
  2019-05-20 20:52 ` [PATCH 2/3] configure: handle TEMP_GPG more robustly Daniel Kahn Gillmor
@ 2019-05-20 20:52 ` Daniel Kahn Gillmor
  2019-05-20 21:48   ` David Bremner
  2 siblings, 1 reply; 6+ messages in thread
From: Daniel Kahn Gillmor @ 2019-05-20 20:52 UTC (permalink / raw)
  To: Notmuch Mail

When using a promiscuous linker, _check_session_keys was working fine.

But some OSes (including some versions of Ubuntu) have set their
linker to always link in "--as-needed" mode, which means that the
order of the objects linked is relevant.  If a library is loaded
before it is needed, that library will no longer be linked in the
final outcome.  _check_session_keys.c was failing on those systems.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 2531cc39..9e8a21bf 100755
--- a/configure
+++ b/configure
@@ -532,7 +532,7 @@ EOF
     if ! TEMP_GPG=$(mktemp -d); then
         printf 'No.\nCould not make tempdir for testing session-key support.\n'
         errors=$((errors + 1))
-    elif ${CC} ${CFLAGS} ${gmime_cflags} ${gmime_ldflags}  _check_session_keys.c -o _check_session_keys \
+    elif ${CC} ${CFLAGS} ${gmime_cflags} _check_session_keys.c ${gmime_ldflags} -o _check_session_keys \
            && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < test/gnupg-secret-key.asc \
            && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \
            && [ $SESSION_KEY = 9:0BACD64099D1468AB07C796F0C0AC4851948A658A15B34E803865E9FC635F2F5 ]
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] configure: make _check_session_keys work with an as-needed linker
  2019-05-20 20:52 ` [PATCH 3/3] configure: make _check_session_keys work with an as-needed linker Daniel Kahn Gillmor
@ 2019-05-20 21:48   ` David Bremner
  2019-05-21 18:32     ` Tomi Ollila
  0 siblings, 1 reply; 6+ messages in thread
From: David Bremner @ 2019-05-20 21:48 UTC (permalink / raw)
  To: Daniel Kahn Gillmor, Notmuch Mail

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:

> When using a promiscuous linker, _check_session_keys was working fine.
>

cleanup series pushed, with one minor change. For reasons that Tomi can
explain, we use "command -v" instead of "which" in scripts.

d

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] configure: make _check_session_keys work with an as-needed linker
  2019-05-20 21:48   ` David Bremner
@ 2019-05-21 18:32     ` Tomi Ollila
  0 siblings, 0 replies; 6+ messages in thread
From: Tomi Ollila @ 2019-05-21 18:32 UTC (permalink / raw)
  To: Notmuch Mail

On Mon, May 20 2019, David Bremner wrote:

> Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
>
>> When using a promiscuous linker, _check_session_keys was working fine.
>>
>
> cleanup series pushed, with one minor change. For reasons that Tomi can
> explain, we use "command -v" instead of "which" in scripts.

command is shell builtin, and all modern shells knows the 

    command -v name >/dev/null construct.

and works similarly, hash is also shell builtin, but in ksh it returns
0 even the name in question is not found. So when someone uses parts of
our shell scripts as an example when they do their own they have better
change of succeeding. which(1) is not shell builtin, usually 
located at /usr/bin.

BR, 

Tomi

>
> d

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-21 18:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-20 20:51 clean up session-key configure checks Daniel Kahn Gillmor
2019-05-20 20:51 ` [PATCH 1/3] configure: better error handling on session key check Daniel Kahn Gillmor
2019-05-20 20:52 ` [PATCH 2/3] configure: handle TEMP_GPG more robustly Daniel Kahn Gillmor
2019-05-20 20:52 ` [PATCH 3/3] configure: make _check_session_keys work with an as-needed linker Daniel Kahn Gillmor
2019-05-20 21:48   ` David Bremner
2019-05-21 18:32     ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).