#!/usr/bin/perl my $keyring=''; $keyring="--no-default-keyring --keyring=$ARGV[0]" if $ARGV[0] ne ''; my @line; my $ver; my $rel; my $name; open(GPG, "gpg $keyring --no-secmem-warning --list-sigs --list-options show-keyring --fixed-list-mode --with-colons |"); while () { chomp; next unless /^pub:/; @line = split(':', $_); my $id = $line[4]; $_ = ; chomp; next unless /^uid:/; @line = split(':', $_); $name = $line[9]; while (1) { $_ = ; chomp; die unless /^sig:/; @line = split(':', $_); next if $line[4] ne $id; $ver = lc($id); $ver =~ s/.*(........)$/$1/; $rel = sprintf("%08x", $line[5]); last; } $names{"gpg-pubkey-$ver-$rel"} = $id; } close GPG; my $n; for $n (sort keys %names) { print "writing $n.asc\n"; system("gpg $keyring --no-secmem-warning --export -a '$names{$n}' >$n.asc"); }