aboutsummaryrefslogtreecommitdiffstats
path: root/URPM/Signature.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-08-19 16:31:35 +0000
committerFrancois Pons <fpons@mandriva.com>2003-08-19 16:31:35 +0000
commit7f1053179a772a944adf76a17b0d459bbdde662b (patch)
tree3318f35ea7ea673c1a122b5885d7ad60e1166e6f /URPM/Signature.pm
parent6234a392b4070a7a2c8441506db9913028075588 (diff)
downloadperl-URPM-7f1053179a772a944adf76a17b0d459bbdde662b.tar
perl-URPM-7f1053179a772a944adf76a17b0d459bbdde662b.tar.gz
perl-URPM-7f1053179a772a944adf76a17b0d459bbdde662b.tar.bz2
perl-URPM-7f1053179a772a944adf76a17b0d459bbdde662b.tar.xz
perl-URPM-7f1053179a772a944adf76a17b0d459bbdde662b.zip
fixed URPM::import_armored_file to use internal XS function to import directly
to database, handle importation of multiple keys by file.
Diffstat (limited to 'URPM/Signature.pm')
-rw-r--r--URPM/Signature.pm29
1 files changed, 23 insertions, 6 deletions
diff --git a/URPM/Signature.pm b/URPM/Signature.pm
index 7b90693..e2089e6 100644
--- a/URPM/Signature.pm
+++ b/URPM/Signature.pm
@@ -7,7 +7,8 @@ sub parse_pubkeys {
my ($urpm, %options) = @_;
my ($block, @l, $content);
- my $db = URPM::DB::open($options{root});
+ my $db = $options{db};
+ $db ||= URPM::DB::open($options{root});
$db->traverse_tag('name', [ 'gpg-pubkey' ], sub {
my ($p) = @_;
@@ -59,8 +60,7 @@ sub parse_armored_file {
}
close F or die "unable to parse armored file $file";
- #- check only one key has been found.
- @l > 1 and die "armored file contains more than one key";
+ #- check at least one key has been found.
@l < 1 and die "no key found while parsing armored file";
#- check if key has been found, remove from list.
@@ -80,9 +80,26 @@ sub parse_armored_file {
sub import_armored_file {
my ($urpm, $file, %options) = @_;
+ local (*F, $_);
+ my $block = '';
- #- this is a tempory operation currently...
- system("rpm", ($options{root} ? ("--root", $options{root}) : @{[]}), "--import", $file) == 0 or
- die "import of armored file failed";
+ #- read armored file.
+ open F, $file;
+ while (<F>) {
+ my $inside_block = /^-----BEGIN PGP PUBLIC KEY BLOCK-----$/ ... /^-----END PGP PUBLIC KEY BLOCK-----$/;
+ if ($inside_block) {
+ $block .= $_;
+ if ($inside_block =~ /E/) {
+ #- import key using the given database if any else the function will open the rpmdb itself.
+ #- FIXME workaround for rpm 4.2 if the rpmdb is left opened, the keys content are sligtly
+ #- modified by algorithms...
+ URPM::import_pubkey(block => $block, db => $options{db}, root => $options{root})
+ or die "import of armored file failed";
+ $block = '';
+ }
+ }
+ }
+ close F or die "unable to parse armored file $file";
}
+
1;