Re: [PATCH] test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected

2016-08-30 Thread Augie Fackler
On Mon, Aug 29, 2016 at 11:57:37PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1472479179 -32400
> #  Mon Aug 29 22:59:39 2016 +0900
> # Node ID eee93fb483588ed1f0ff26898e06cb3713d2afa4
> # Parent  b1f69dbdd76be170429185c3b0f50027f55e4f07
> test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected

Queued this, thanks

>
> Danek Duvall found that gpg-connect-agent of GnuPG 2.0 never starts gpg-agent
> daemon. The 2.1 way is documented as "gpg-coonect-agent /bye" [1], which
> appears to be different from the 2.0 way [2].
>
>  [1]: 
> https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html
>  [2]: 
> https://www.gnupg.org/documentation/manuals/gnupg-2.0/Invoking-GPG_002dAGENT.html
>
> Since "gpg-agent --daemon" of GnuPG 2.1 never prints environment variables,
> "eval $(gpg-agent --daemon)" would be valid only for GnuPG < 2.1, and we'll
> need a different workaround for 2.0. I have no 2.0 environment, I won't
> implement it.
>
> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -353,6 +353,10 @@ def has_gpg():
>  def has_gpg2():
>  return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.')
>
> +@check("gpg21", "gpg client v2.1+")
> +def has_gpg21():
> +return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.(?!0)')
> +
>  @check("unix-permissions", "unix-style permissions")
>  def has_unix_permissions():
>  d = tempfile.mkdtemp(dir='.', prefix=tempprefix)
> diff --git a/tests/test-gpg.t b/tests/test-gpg.t
> --- a/tests/test-gpg.t
> +++ b/tests/test-gpg.t
> @@ -12,11 +12,16 @@ Test the GPG extension
>$ GNUPGHOME="$TESTTMP/gpg"; export GNUPGHOME
>$ cp -R "$TESTDIR/gpg" "$GNUPGHOME"
>
> -Start gpg-agent, which is required by GnuPG v2, and migrate secret keys
> +Start gpg-agent, which is required by GnuPG v2
> +
> +#if gpg21
> +  $ gpg-connect-agent -q --subst /serverpid '/echo ${get serverpid}' /bye \
> +  > >> $DAEMON_PIDS
> +#endif
> +
> +and migrate secret keys
>
>  #if gpg2
> -  $ gpg-connect-agent -q --subst /serverpid '/echo ${get serverpid}' /bye \
> -  > >> $DAEMON_PIDS
>$ gpg --no-permission-warning --no-secmem-warning --list-secret-keys \
>> > /dev/null 2>&1
>  #endif
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected

2016-08-29 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1472479179 -32400
#  Mon Aug 29 22:59:39 2016 +0900
# Node ID eee93fb483588ed1f0ff26898e06cb3713d2afa4
# Parent  b1f69dbdd76be170429185c3b0f50027f55e4f07
test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected

Danek Duvall found that gpg-connect-agent of GnuPG 2.0 never starts gpg-agent
daemon. The 2.1 way is documented as "gpg-coonect-agent /bye" [1], which
appears to be different from the 2.0 way [2].

 [1]: 
https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html
 [2]: 
https://www.gnupg.org/documentation/manuals/gnupg-2.0/Invoking-GPG_002dAGENT.html

Since "gpg-agent --daemon" of GnuPG 2.1 never prints environment variables,
"eval $(gpg-agent --daemon)" would be valid only for GnuPG < 2.1, and we'll
need a different workaround for 2.0. I have no 2.0 environment, I won't
implement it.

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -353,6 +353,10 @@ def has_gpg():
 def has_gpg2():
 return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.')
 
+@check("gpg21", "gpg client v2.1+")
+def has_gpg21():
+return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.(?!0)')
+
 @check("unix-permissions", "unix-style permissions")
 def has_unix_permissions():
 d = tempfile.mkdtemp(dir='.', prefix=tempprefix)
diff --git a/tests/test-gpg.t b/tests/test-gpg.t
--- a/tests/test-gpg.t
+++ b/tests/test-gpg.t
@@ -12,11 +12,16 @@ Test the GPG extension
   $ GNUPGHOME="$TESTTMP/gpg"; export GNUPGHOME
   $ cp -R "$TESTDIR/gpg" "$GNUPGHOME"
 
-Start gpg-agent, which is required by GnuPG v2, and migrate secret keys
+Start gpg-agent, which is required by GnuPG v2
+
+#if gpg21
+  $ gpg-connect-agent -q --subst /serverpid '/echo ${get serverpid}' /bye \
+  > >> $DAEMON_PIDS
+#endif
+
+and migrate secret keys
 
 #if gpg2
-  $ gpg-connect-agent -q --subst /serverpid '/echo ${get serverpid}' /bye \
-  > >> $DAEMON_PIDS
   $ gpg --no-permission-warning --no-secmem-warning --list-secret-keys \
   > > /dev/null 2>&1
 #endif
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel