aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--URPM.pm2
-rw-r--r--URPM/Signature.pm115
-rw-r--r--perl-URPM.spec9
3 files changed, 67 insertions, 59 deletions
diff --git a/URPM.pm b/URPM.pm
index 98e254f..97f0a95 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -4,7 +4,7 @@ use strict;
use DynaLoader;
our @ISA = qw(DynaLoader);
-our $VERSION = '0.93';
+our $VERSION = '0.94';
URPM->bootstrap($VERSION);
diff --git a/URPM/Signature.pm b/URPM/Signature.pm
index 5ef9bbe..78fdbd5 100644
--- a/URPM/Signature.pm
+++ b/URPM/Signature.pm
@@ -25,6 +25,41 @@ sub compare_pubkeys {
$diff <= $options{diff} ? 0 : $diff;
}
+#- parse an armored file and import in keys hash if the key does not already exists.
+sub parse_armored_file {
+ my ($urpm, $file, %options) = @_;
+ my ($block, $content, @l);
+
+ #- check if an already opened file has been given directly.
+ unless (ref $file) {
+ my $F;
+ open $F, $file;
+ $file = $F;
+ }
+
+ #- read armored file.
+ local $_;
+ while (<$file>) {
+ my $inside_block = /^-----BEGIN PGP PUBLIC KEY BLOCK-----$/ ... /^-----END PGP PUBLIC KEY BLOCK-----$/;
+ if ($inside_block) {
+ $block .= $_;
+ if ($inside_block =~ /E/) {
+ #- block is needed to import the key if needed.
+ push @l, { block => $block, content => $content };
+ $block = $content = undef;
+ } else {
+ #- compute content for finding the right key.
+ chomp;
+ /^$/ and $content = '';
+ defined $content and $content .= $_;
+ }
+ }
+ }
+ close F;
+
+ @l;
+}
+
#- pare from rpmlib db.
sub parse_pubkeys {
my ($urpm, %options) = @_;
@@ -45,6 +80,7 @@ sub parse_pubkeys {
$urpm->{keys}{$p->version} = { $p->summary =~ /^gpg\((.*)\)$/ ? (name => $1) : @{[]},
id => $p->version,
content => $content,
+ block => $p->description,
};
$block = undef;
$content = '';
@@ -57,68 +93,35 @@ sub parse_pubkeys {
})
}
-#- parse an armored file and import in keys hash if the key does not already exists.
-sub parse_armored_file {
- my ($urpm, $file, %options) = @_;
- my ($block, @l, $content);
- local (*F, $_);
-
- #- read armored file.
- open F, $file;
- while (<F>) {
- chomp;
- $block ||= /^-----BEGIN PGP PUBLIC KEY BLOCK-----$/;
- if ($block) {
- my $inside_block = /^$/ ... /^-----END PGP PUBLIC KEY BLOCK-----$/;
- if ($inside_block > 1) {
- if ($inside_block =~ /E/) {
- push @l, +{ content => $content };
- $block = undef;
- $content = '';
- } else {
- $content .= $_;
- }
- }
- }
- }
- close F or die "unable to parse armored file $file";
-
- #- check if key has been found, remove from list.
- if ($options{only_unknown_keys}) {
- @l = grep {
- my $found = 0;
- foreach my $k (values %{$urpm->{keys} || {}}) {
- compare_pubkeys($k, $_) == 0 and $found = 1, last;
- }
- !$found;
- } @l;
- }
-
- @l;
-}
-
-sub import_armored_file {
- my ($urpm, $file, %options) = @_;
+#- import pubkeys only if it is needed.
+sub import_needed_pubkeys {
+ my ($urpm, $l, %options) = @_;
local (*F, $_);
my $block = '';
- #- 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 = '';
+ #- use the same database handle to avoid re-opening multiple times the database.
+ my $db = $options{db};
+ $db ||= URPM::DB::open($options{root}, 1);
+
+ #- assume $l is a reference to an array containing all the keys to import
+ #- if needed.
+ foreach my $k (@{$l || []}) {
+ my ($id, $imported);
+ foreach my $kv (values %{$urpm->{keys} || {}}) {
+ compare_pubkeys($k, $kv, %options) == 0 and $id = $kv->{id}, last;
+ }
+ unless ($id) {
+ $imported = 1;
+ import_pubkey(block => $k->{block}, db => $db);
+ $urpm->parse_pubkeys(db => $db);
+ foreach my $kv (values %{$urpm->{keys} || {}}) {
+ compare_pubkeys($k, $kv, %options) == 0 and $id = $kv->{id}, last;
}
}
+ #- let the caller know about what has been found.
+ #- this is an error if the key is not found.
+ $options{callback} and $options{callback}->($urpm, $db, $k, $id, $imported, %options);
}
- close F or die "unable to parse armored file $file";
}
1;
diff --git a/perl-URPM.spec b/perl-URPM.spec
index b45083f..45092e8 100644
--- a/perl-URPM.spec
+++ b/perl-URPM.spec
@@ -1,7 +1,7 @@
%define name perl-URPM
%define real_name URPM
-%define version 0.93
-%define release 7mdk
+%define version 0.94
+%define release 1mdk
%{expand:%%define rpm_version %(rpm -q --queryformat '%{VERSION}-%{RELEASE}' rpm)}
@@ -52,6 +52,11 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Thu Aug 21 2003 François Pons <fpons@mandrakesoft.com> 0.94-1mdk
+- fix for pubkey name extraction (gc).
+- updated code to be more adapted for both urpmi and DrakX
+ in URPM::Signature.
+
* Wed Aug 20 2003 François Pons <fpons@mandrakesoft.com> 0.93-7mdk
- fixed diff provides to be ignored on obsoleted provides which caused
resolver to choose bad package due to removed obsoleted provides.