diff -Nur -x '*.orig' -x '*.rej' smeserver-yum-1.2.0/root/etc/e-smith/events/actions/yum-import-keys mezzanine_patched_smeserver-yum-1.2.0/root/etc/e-smith/events/actions/yum-import-keys --- smeserver-yum-1.2.0/root/etc/e-smith/events/actions/yum-import-keys 2005-09-25 20:30:54.000000000 -0600 +++ mezzanine_patched_smeserver-yum-1.2.0/root/etc/e-smith/events/actions/yum-import-keys 2007-01-17 16:39:51.000000000 -0700 @@ -23,16 +23,55 @@ use constant KEYDIR => "/usr/share/rpm-gpg-keys"; +sub parse_key { + my @lines = @_; + my ($key, $good); + + $good = 0; + foreach (@lines) { + chomp; + next if m#Version:#i; + + if (m#BEGIN PGP PUBLIC KEY BLOCK#) { + $good++; + next; + } + + return $key if m#END PGP PUBLIC KEY BLOCK#; + + $key .= $_ if m#^\S+$# && $good; + } + return undef; +} + +my %keys; + +if(open (RPMS, '/bin/rpm -q gpg-pubkey 2> /dev/null|')) { + foreach my $rpm (map { chomp; $_ } ) { + if(open (KEY, "/bin/rpm -q --qf \%{DESCRIPTION} $rpm|")) { + my $key = parse_key(); + $keys{$key}++ if $key; + close(KEY); + } + } + close (RPMS); +} + chdir KEYDIR or die "Couldn't chdir " . KEYDIR . "\n"; opendir DIR, '.' or die "Couldn't opendir .\n"; -for my $key ( grep {!/^\./} readdir(DIR) ) +for my $file ( grep { m#^RPM-GPG-KEY# } readdir(DIR) ) { - warn "Importing key $key\n"; + if(open(KEY, "$file")) { + my $key = parse_key(); + next if $key && $keys{$key}; + } + + warn "Importing key $file\n"; - system("rpm", "--import", $key) == 0 or - warn "Couldn't rpm --import $key\n"; + system("rpm", "--import", $file) == 0 or + warn "Couldn't rpm --import $file\n"; } exit 0;