Subject: | [PATCH] [TEST] Win32 gpg version detection on cygwin fails |
G'day Audrey and M::S maintainers,
The Module::Signature module fails to detect the version of gpg
installed when running under cygwin. The _has_gpg routine assumes that
the version number appears at the end of the line:
sub _has_gpg {
`gpg --version` =~ /GnuPG.*?(\S+)$/m or return;
return $1;
}
However the Windows version of GnuPG called from cygwin emits Windows
style 'CR LF' linefeeds, rather than unix style 'LF' linefeeds. These
end up in the output of backticks, meaning that the regexp can't find
the end of the file.
Attached are two patches against the 0.55 release on the CPAN. One for
a test which detects this condition, and a second for a patch that
solves it (by allowing \s* characters after the version).
Many thanks, and all the very best,
Paul
Subject: | 0002-Fix-for-incorrect-gpg-version-detction-under-cygwin.patch |
From 7a2ef1253cb7176fd7ccb1019f17654b8f114b54 Mon Sep 17 00:00:00 2001
From: Paul Fenwick <pjf@perltraining.com.au>
Date: Sun, 14 Sep 2008 15:00:20 +1000
Subject: [PATCH] Fix for incorrect gpg version detction under cygwin.
---
lib/Module/Signature.pm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/Module/Signature.pm b/lib/Module/Signature.pm
index f239e3b..1ee53c2 100644
--- a/lib/Module/Signature.pm
+++ b/lib/Module/Signature.pm
@@ -131,7 +131,7 @@ sub _verify {
}
sub _has_gpg {
- `gpg --version` =~ /GnuPG.*?(\S+)$/m or return;
+ `gpg --version` =~ /GnuPG.*?(\S+)\s*$/m or return;
return $1;
}
--
1.5.2.2
Subject: | 0001-Test-for-failing-gpg-detection-under-cygwin.patch |
From 61e4595e0baaeb27ef4d842120c1aa7c832cfc6b Mon Sep 17 00:00:00 2001
From: Paul Fenwick <pjf@perltraining.com.au>
Date: Sun, 14 Sep 2008 14:59:15 +1000
Subject: [PATCH] Test for failing gpg detection under cygwin
---
t/2-cygwin.t | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
create mode 100644 t/2-cygwin.t
diff --git a/t/2-cygwin.t b/t/2-cygwin.t
new file mode 100644
index 0000000..e9248c0
--- /dev/null
+++ b/t/2-cygwin.t
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Module::Signature;
+use Test::More;
+
+if ($^O ne 'cygwin') {
+ plan skip_all => "Cygwin only tests";
+}
+elsif (! $ENV{TEST_CYGWIN_GNUPG} ) {
+ plan skip_all => 'Set the environment variable TEST_CYGWIN_GNUPG to enable this test';
+}
+elsif (! -x '/usr/local/bin/gpg') {
+ plan skip_all => '/usr/local/bin/gpg not found';
+}
+
+plan tests => 1;
+
+my $version = Module::Signature::_has_gpg();
+
+like($version, qr/^\d+\.\d+\.\d+$/, "gpg version detected");
--
1.5.2.2