diff options
author | Francois Pons <fpons@mandriva.com> | 2000-09-03 17:18:35 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2000-09-03 17:18:35 +0000 |
commit | 1b6b9fb133b7f0e16b725a199a81003100cd65a0 (patch) | |
tree | 8bfcb30c983952e8c42b04dc65a3fc1505d84e36 /rpmtools.pm | |
parent | 6b947817a5c48e175a43f95ab6d59cfec58f4e67 (diff) | |
download | rpmtools-1b6b9fb133b7f0e16b725a199a81003100cd65a0.tar rpmtools-1b6b9fb133b7f0e16b725a199a81003100cd65a0.tar.gz rpmtools-1b6b9fb133b7f0e16b725a199a81003100cd65a0.tar.bz2 rpmtools-1b6b9fb133b7f0e16b725a199a81003100cd65a0.tar.xz rpmtools-1b6b9fb133b7f0e16b725a199a81003100cd65a0.zip |
*** empty log message ***
Diffstat (limited to 'rpmtools.pm')
-rw-r--r-- | rpmtools.pm | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/rpmtools.pm b/rpmtools.pm index 6ccb303..280e899 100644 --- a/rpmtools.pm +++ b/rpmtools.pm @@ -251,9 +251,8 @@ sub relocate_depslist { #- is multiply defined and this should be fixed. #- first correct info hash, then a second pass on depslist #- is required to relocate its entries. - my $cmp_version = compare_version($_->{version}, $params->{info}{$_->{name}}); - if ($cmp_version > 0 || $cmp_version == 0 && - compare_version($_->{release}, $params->{info}{$_->{name}}) > 0) { + my $cmp_version = version_compare($_->{version}, $params->{info}{$_->{name}}); + if ($cmp_version > 0 || $cmp_version == 0 && version_compare($_->{release}, $params->{info}{$_->{name}}) > 0) { $params->{info}{$_->{name}} = $_; ++$relocated_entries; } @@ -261,8 +260,7 @@ sub relocate_depslist { } if ($relocated_entries) { - my $n = scalar(@{$params->{depslist}}) - 1; - for (0..$n) { + for (0 .. scalar(@{$params->{depslist}}) - 1) { my $pkg = $params->{depslist}[$_]; $params->{depslist}[$_] = $params->{info}{$pkg->{name}}; } @@ -388,4 +386,15 @@ sub write_compss { 1; } +#- compare a version string. +sub version_compare { + my ($a, $b) = @_; + local $_; + + while ($a || $b) { + my ($sb, $sa) = map { $1 if $a =~ /^\W*\d/ ? s/^\W*0*(\d+)// : s/^\W*(\D+)// } ($b, $a); + $_ = length($sa) cmp length($sb) || $sa cmp $sb and return $_; + } +} + 1; |