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.
-#!/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'}; }
exit 1;
}
+my $w; my $h;
if ( -x "/usr/bin/paperconf" ) {
$w=`paperconf -w`;
$h=`paperconf -h`;
$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;
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
$numlines++;
print;
}
-$numlines -= 1;
-
close(GPG);
print <<EOF;
%%EOF
EOF
+exit 0;