1 |
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 |
2 |
--- smeserver-yum-1.2.0/root/etc/e-smith/events/actions/yum-import-keys 2005-09-25 20:30:54.000000000 -0600 |
3 |
+++ mezzanine_patched_smeserver-yum-1.2.0/root/etc/e-smith/events/actions/yum-import-keys 2007-01-17 16:39:51.000000000 -0700 |
4 |
@@ -23,16 +23,55 @@ |
5 |
|
6 |
use constant KEYDIR => "/usr/share/rpm-gpg-keys"; |
7 |
|
8 |
+sub parse_key { |
9 |
+ my @lines = @_; |
10 |
+ my ($key, $good); |
11 |
+ |
12 |
+ $good = 0; |
13 |
+ foreach (@lines) { |
14 |
+ chomp; |
15 |
+ next if m#Version:#i; |
16 |
+ |
17 |
+ if (m#BEGIN PGP PUBLIC KEY BLOCK#) { |
18 |
+ $good++; |
19 |
+ next; |
20 |
+ } |
21 |
+ |
22 |
+ return $key if m#END PGP PUBLIC KEY BLOCK#; |
23 |
+ |
24 |
+ $key .= $_ if m#^\S+$# && $good; |
25 |
+ } |
26 |
+ return undef; |
27 |
+} |
28 |
+ |
29 |
+my %keys; |
30 |
+ |
31 |
+if(open (RPMS, '/bin/rpm -q gpg-pubkey 2> /dev/null|')) { |
32 |
+ foreach my $rpm (map { chomp; $_ } <RPMS>) { |
33 |
+ if(open (KEY, "/bin/rpm -q --qf \%{DESCRIPTION} $rpm|")) { |
34 |
+ my $key = parse_key(<KEY>); |
35 |
+ $keys{$key}++ if $key; |
36 |
+ close(KEY); |
37 |
+ } |
38 |
+ } |
39 |
+ close (RPMS); |
40 |
+} |
41 |
+ |
42 |
chdir KEYDIR or die "Couldn't chdir " . KEYDIR . "\n"; |
43 |
|
44 |
opendir DIR, '.' or die "Couldn't opendir .\n"; |
45 |
|
46 |
-for my $key ( grep {!/^\./} readdir(DIR) ) |
47 |
+for my $file ( grep { m#^RPM-GPG-KEY# } readdir(DIR) ) |
48 |
{ |
49 |
- warn "Importing key $key\n"; |
50 |
+ if(open(KEY, "$file")) { |
51 |
+ my $key = parse_key(<KEY>); |
52 |
+ next if $key && $keys{$key}; |
53 |
+ } |
54 |
+ |
55 |
+ warn "Importing key $file\n"; |
56 |
|
57 |
- system("rpm", "--import", $key) == 0 or |
58 |
- warn "Couldn't rpm --import $key\n"; |
59 |
+ system("rpm", "--import", $file) == 0 or |
60 |
+ warn "Couldn't rpm --import $file\n"; |
61 |
} |
62 |
|
63 |
exit 0; |