On Thu Jan 05 08:01:56 2006, JMEHNLE wrote:
Show quoted text> It should be possible to specify the ID of the key that is to be used
> for signing modules. AFAICT it currently just uses the gpg default
> key, which is not always the key one wants to use.
#or we could pull the key from the AUTHOR in the Makefile.PL with this
patch:
--- a/usr/local/share/perl/5.10.0/Module/Signature.pm
+++ b/usr/local/share/perl/5.10.0/Module/Signature.pm
@@ -348,8 +348,17 @@ sub sign {
return unless <STDIN> =~ /[Yy]/;
}
+ #dirty hack to let the user chose the key
+ my $AUTHOR = '';
+ $AUTHOR = `grep AUTHOR Makefile.PL` if(-f "Makefile.PL");
+ #$AUTHOR = `grep AUTHOR Makefile.PL|sed -e 's/.*{//' -e 's/}.*//'`
if(-f "Makefile.PL");
+ $AUTHOR = '' unless $AUTHOR=~s/.*<(.+\@.+)\>.*/$1/;
+ #$AUTHOR=~s/.*\{(.+)\}.*/$1/;
+ chomp($AUTHOR);
+ $AUTHOR=~s/\s*\n$//;
+
if (my $version = _has_gpg()) {
- _sign_gpg($SIGNATURE, $plaintext, $version);
+ _sign_gpg($SIGNATURE, $plaintext, $version, $AUTHOR);
}
elsif (eval {require Crypt::OpenPGP; 1}) {
_sign_crypt_openpgp($SIGNATURE, $plaintext);
@@ -363,13 +372,15 @@ sub sign {
}
sub _sign_gpg {
- my ($sigfile, $plaintext, $version) = @_;
+ my ($sigfile, $plaintext, $version, $AUTHOR) = @_;
die "Could not write to $sigfile"
if -e $sigfile and (-d $sigfile or not -w $sigfile);
local *D;
- open D, "| gpg --clearsign >> $sigfile.tmp" or die "Could not call
gpg: $!";
+ my $set_key ='';
+ $set_key = "--default-key $AUTHOR" if $AUTHOR;
+ open D, "| gpg $set_key --clearsign >> $sigfile.tmp" or die "Could
not call gpg: $!";
print D $plaintext;
close D;
# grep VERSION /usr/local/share/perl/5.10.0/Module/Signature.pm
# $Module::Signature::VERSION = '0.66';
# works for me (and I agree, this did bug me as I have lots of keys and
lots of addresses.