Hi,

Holger Levsen wrote (13 Feb 2014 15:48:59 GMT) :
> right. I'd be happy to do this, but I dont know how to remove those hundred 
> keys from my keyring...

OK, so here's a small gift for you! The attached script should list
the keys that belong to both of the two keyrings passed on the
command-line. It depends on an internal parcimonie library, and on the
libset-object-perl Debian package.

*Caution*: please backup the original ~/.gnupg/pubring.gpg before
deleting all these keys from your keyring, as you will lose some
information in this process, such as local-only key certifications,
your own public keys, and probably more.

Once you're sure you want to do it, I assume that piping the output
into "xargs -n 1 gpg --batch --delete-key" should do the job.

Cheers,
-- 
  intrigeri
  | GnuPG key @ https://gaffer.ptitcanardnoir.org/intrigeri/intrigeri.asc
  | OTR fingerprint @ https://gaffer.ptitcanardnoir.org/intrigeri/otr.asc

#!/usr/bin/perl

=head1 NAME

keyrings_intersection - list keys that belong to the intersection of two 
keyrings

=cut

use strict;
use warnings FATAL => 'all';

use 5.10.1;

use App::Parcimonie qw{gpgPublicKeys};
use Set::Object qw{set};

my $usage = 'Usage: keyrings_intersection KEYRING_1 KEYRING_2';

sub keys_in {
    my $keyring = shift;

    gpgPublicKeys({ extra_args => [
        '--no-default-keyring', "--keyring=$keyring",
    ]});
}

if (@ARGV == 1 and $ARGV[0] eq '--help') {
    say STDERR $usage;
    exit 0;
}
elsif (@ARGV != 2) {
    die "$usage";
}

my $keyring_1 = shift;
my $keyring_2 = shift;
-e $keyring_1 || die "'$keyring_1' does not exist.";
-e $keyring_2 || die "'$keyring_2' does not exist.";

say join("\n",
         (set(keys_in $keyring_1) * set(keys_in $keyring_2))->members
);

Attachment: pgpoTDWzrx5yf.pgp
Description: PGP signature

Reply via email to