* Reintroduce failure on key not found.
authorkink-guest <kink-guest@b513b33f-fedd-0310-b452-c3deb5f4c849>
Sat, 13 Aug 2005 17:29:35 +0000 (17:29 +0000)
committerkink-guest <kink-guest@b513b33f-fedd-0310-b452-c3deb5f4c849>
Sat, 13 Aug 2005 17:29:35 +0000 (17:29 +0000)
* Use strict.

git-svn-id: svn://svn.debian.org/pgp-tools/trunk@173 b513b33f-fedd-0310-b452-c3deb5f4c849

TODO
gpg-key2ps/gpg-key2ps

diff --git a/TODO b/TODO
index b50422db52a13f93d62f405a6109c10a603731b4..125279518a3c14b494cd4eafe3fac6e90f821b61 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
 TODO
 
-- Get Simon's new gpg-key2ps script into the repo, and fix it up so it
-  provides at least the functionality that gpg-key2ps now has.
 - Integrate documentation of all different parts.
 
 
index 4186ba0d2f298e84a5e013b16499c3239e768bed..e1b1515324d46f5b5ad0c4a4c725d5d64281234a 100755 (executable)
@@ -1,21 +1,24 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
 #
 # gpg-key2ps: convert a PGP/GnuPG key into paper slips.
 #
 # $Id$
 
-$version = '$Rev$';
+use strict;
+use Getopt::Std;
+
+my $version = '$Rev$';
 $version =~ s/\$Rev:\s*(\d+)\s*\$/$1/;
-$usage = "Usage: $0 [-p papersize] [-r revoked-style] keyid-or-name\n";
-$keyids = "";
-$revokestyle="hide";
+my $usage = "Usage: $0 [-p papersize] [-r revoked-style] keyid-or-name\n";
+my $keyids = "";
+my $revokestyle="hide";
 
 if ( $#ARGV < 0 ) {
        print $usage;
        exit 1;
 }
 
-use Getopt::Std;
+my %opts;
 getopt('pr', \%opts);
 if ( $opts{r} ) { $revokestyle = $opts{'r'}; }
 if ( $opts{p} ) { $ENV{'PAPERSIZE'} = $opts{'p'}; }
@@ -31,6 +34,7 @@ if ( $revokestyle !~ /^(grey|hide|note|show|strike)$/ ) {
        exit 1;
 }
 
+my $w; my $h;
 if ( -x "/usr/bin/paperconf" ) {
        $w=`paperconf -w`;
        $h=`paperconf -h`;
@@ -42,6 +46,11 @@ if ( -x "/usr/bin/paperconf" ) {
        $h=842;
 }
 
+if ( system( "gpg --fingerprint $keyids >/dev/null" ) != 0 ) {
+       print STDERR "Key not found. Try 'gpg --list-keys'\n";
+       exit 1;
+}
+
 open(GPG, "gpg --fingerprint --with-colons $keyids |");
 
 print <<EOF;
@@ -144,13 +153,13 @@ print <<EOF;
        noneedhline
 EOF
 
-$numlines = 0;
+my $numlines = 0;
 while(<GPG>) {
        if ( /^(tru|uat):/ ) { next; }
        if ( /^pub:/ ) { $numlines++; } 
        s/^pub:[^:]*:([^:]*):([0-9]*):.{8,8}(.{8,8}):([^:]*):[^:]*:[^:]*:[^:]*:([^:]*):[^:]*:[^:]*:.*/  ($5) ($4) ($3) $2 ($1) pub/;
        if ( /^fpr:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:]*):.*/ ) {
-               $fpr = $1;
+               my $fpr = $1;
                # v4 key
                $fpr =~ s/(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})/$1 $2 $3 $4 $5  $6 $7 $8 $9 $10/;
                # v3 key
@@ -164,8 +173,6 @@ while(<GPG>) {
        $numlines++;
        print;
 }
-$numlines -= 1;
-
 close(GPG);
 
 print <<EOF;
@@ -202,4 +209,5 @@ showpage
 %%EOF
 EOF
 
+exit 0;