diff options
author | Francois Pons <fpons@mandriva.com> | 2003-08-20 15:10:25 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2003-08-20 15:10:25 +0000 |
commit | 94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd (patch) | |
tree | 08acc1938f395ea1333ab196fee3f4216fb285de | |
parent | d64a23741780b7715e128b1efb5680dba55f5458 (diff) | |
download | perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.tar perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.tar.gz perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.tar.bz2 perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.tar.xz perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.zip |
0.93-7mdk (signature comparison workaround)
-rw-r--r-- | URPM.pm | 6 | ||||
-rw-r--r-- | URPM/Signature.pm | 33 | ||||
-rw-r--r-- | perl-URPM.spec | 6 |
3 files changed, 35 insertions, 10 deletions
@@ -11,8 +11,10 @@ URPM->bootstrap($VERSION); sub new { my ($class) = @_; bless { - depslist => [], - provides => {}, + depslist => [], + provides => {}, + media => [], + options => {}, }, $class; } diff --git a/URPM/Signature.pm b/URPM/Signature.pm index e2089e6..b3ca91b 100644 --- a/URPM/Signature.pm +++ b/URPM/Signature.pm @@ -2,6 +2,29 @@ package URPM; use strict; +#- compare keys to avoid glitches introduced during the importation where +#- some characters may be modified on the fly by rpm --import... +sub compare_pubkeys { + my ($a, $b, %options) = @_; + my $diff = 0; + my @a = unpack "C*", $a->{content}; + my @b = unpack "C*", $b->{content}; + + #- default options to use. + $options{start} ||= 0; + $options{end} ||= @a < @b ? scalar(@b) : scalar(@a); + $options{diff} ||= 1; + + #- check element one by one, count all difference (do not work well if elements + #- have been inserted/deleted). + foreach ($options{start} .. $options{end}) { + $a[$_] != $b[$_] and ++$diff; + } + + #- diff options give level to consider the key equal (a character is not always the same). + $diff <= $options{diff} ? 0 : $diff; +} + #- pare from rpmlib db. sub parse_pubkeys { my ($urpm, %options) = @_; @@ -49,7 +72,7 @@ sub parse_armored_file { my $inside_block = /^$/ ... /^-----END PGP PUBLIC KEY BLOCK-----$/; if ($inside_block > 1) { if ($inside_block =~ /E/) { - push @l, $content; + push @l, +{ content => $content }; $block = undef; $content = ''; } else { @@ -60,22 +83,18 @@ sub parse_armored_file { } close F or die "unable to parse armored file $file"; - #- 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. if ($options{only_unknown_keys}) { @l = grep { my $found = 0; foreach my $k (values %{$urpm->{keys} || {}}) { - $k->{content} eq $_ and $found = 1, last; + compare_pubkeys($k, $_) == 0 and $found = 1, last; } !$found; } @l; } - #- now return something (true) which reflect what should be found in keys. - map { +{ content => $_ } } @l; + @l; } sub import_armored_file { diff --git a/perl-URPM.spec b/perl-URPM.spec index 2261f28..69f4b59 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 6mdk +%define release 7mdk %{expand:%%define rpm_version %(rpm -q --queryformat '%{VERSION}-%{RELEASE}' rpm)} @@ -52,6 +52,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Wed Aug 20 2003 François Pons <fpons@mandrakesoft.com> 0.93-7mdk +- added URPM::Signature::compare_pubkeys to workaround rpm + importation of key with modified armor. + * Tue Aug 19 2003 François Pons <fpons@mandrakesoft.com> 0.93-6mdk - make URPM::Signature::import_armored_file independent from rpm. - added URPM::import_pubkey in xs directly. |