From 94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Wed, 20 Aug 2003 15:10:25 +0000 Subject: 0.93-7mdk (signature comparison workaround) --- URPM.pm | 6 ++++-- URPM/Signature.pm | 33 ++++++++++++++++++++++++++------- perl-URPM.spec | 6 +++++- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/URPM.pm b/URPM.pm index 4d21c17..98e254f 100644 --- a/URPM.pm +++ b/URPM.pm @@ -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 0.93-7mdk +- added URPM::Signature::compare_pubkeys to workaround rpm + importation of key with modified armor. + * Tue Aug 19 2003 François Pons 0.93-6mdk - make URPM::Signature::import_armored_file independent from rpm. - added URPM::import_pubkey in xs directly. -- cgit v1.2.1