gpgsigs: In LaTeX mode, use the samepage env to not split entries at pagebreaks.
[pgp-tools.git] / gpgsigs / gpgsigs
index 5ba8c126792afc10486632b237f86bacf5d05b75..50505d24251bbb6c58f62c0a25af78dc41b38c4a 100755 (executable)
@@ -181,7 +181,7 @@ while (<SIGS>) {
                next if $uidstatus eq "r";
                if ($latex and not $photocount) { # call once per key
                        my ($shortkey) = substr $key, -8;
-                       system "rm $shortkey.[1-9]*.eps";
+                       system "rm -f $shortkey.[1-9]*.eps";
                        system "gpg --photo-viewer 'gpgsigs-eps-helper $shortkey' --list-options show-photos --list-key $key > /dev/null";
                        $photocount = 1;
                }
@@ -297,6 +297,7 @@ sub print_tag
 $key = undef;
 $uid = undef;
 my $line = 0;
+my $keys = 0;
 print STDERR "Annotating $keytxt, writing into $outfile\n";
 open (TXT, $keytxt) or die ("Cannot open $keytxt\n");
 open (WRITE, '>'.$outfile) or die ("Cannot open $outfile for writing\n");
@@ -307,6 +308,7 @@ if ($latex) {
 \usepackage[margin=2cm]{geometry}
 \usepackage{alltt}
 \usepackage{graphicx}
+\usepackage{grffile}
 \begin{document}
 \begin{alltt}
 EOF
@@ -327,6 +329,19 @@ while (<TXT>) {
        if (/^RIPEMD160 Checksum:/ && defined $RIPEMD160) {
                s/[_[:xdigit:]][_ [:xdigit:]]+_/$RIPEMD160/;
        }
+
+       if ( m/^[0-9]+\s+\[ \] Fingerprint OK/ ){
+               if ($latex) {
+                       if ($keys > 0) {
+                               print WRITE "\\end{samepage}\n";
+                       }
+                       print WRITE "\\begin{samepage}\n";
+                       ++$keys;
+               }
+               print WRITE;
+               next;
+       }
+
        if ( m/^pub  +(?:\d+)[DR]\/([0-9A-F]{8}) [0-9]{4}-[0-9]{2}-[0-9]{2} *(.*)/ ) {
                $key = $1;
                $uid = $2;
@@ -354,7 +369,7 @@ while (<TXT>) {
                                if ($latex and ($uid =~ /^\[jpeg image/)) {
                                        $photocount++;
                                        print WRITE "\\begin{flushright}\n";
-                                       print WRITE "\\includegraphics[height=3cm]{$key.$photocount.eps}\n";
+                                       print WRITE "\\includegraphics[height=3cm]{$key.$photocount}\n";
                                        print WRITE "\\end{flushright}\n";
                                }
                        }
@@ -376,6 +391,10 @@ while (<TXT>) {
        print WRITE;
 }
 
+if ($latex && ($keys > 0)) {
+       print WRITE "\\end{samepage}\n";
+}
+
 print WRITE "Legend:\n";
 my $num_myuids = 0;
 foreach my $i (0 .. @mykeys - 1) {