summaryrefslogtreecommitdiffstats
path: root/tools/syncrpms
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2001-06-27 15:06:37 +0000
committerFrancois Pons <fpons@mandriva.com>2001-06-27 15:06:37 +0000
commit41e5eccad2108d79e23cfafdaa794bf02e6ffb4f (patch)
treeb803131d11f2af84a71c317d25d157a029643f93 /tools/syncrpms
parent444c4ee9b0e02cc9e9f2c6bbebf057bad80f1792 (diff)
downloaddrakx-backup-do-not-use-41e5eccad2108d79e23cfafdaa794bf02e6ffb4f.tar
drakx-backup-do-not-use-41e5eccad2108d79e23cfafdaa794bf02e6ffb4f.tar.gz
drakx-backup-do-not-use-41e5eccad2108d79e23cfafdaa794bf02e6ffb4f.tar.bz2
drakx-backup-do-not-use-41e5eccad2108d79e23cfafdaa794bf02e6ffb4f.tar.xz
drakx-backup-do-not-use-41e5eccad2108d79e23cfafdaa794bf02e6ffb4f.zip
make syncrpms use rpmtools::version_compare.
Diffstat (limited to 'tools/syncrpms')
-rwxr-xr-xtools/syncrpms30
1 files changed, 11 insertions, 19 deletions
diff --git a/tools/syncrpms b/tools/syncrpms
index f3fa8fb4d..891474b8b 100755
--- a/tools/syncrpms
+++ b/tools/syncrpms
@@ -20,19 +20,11 @@
use strict qw(subs vars refs);
-#- get basename for a file.
-sub basename { $_[0] =~ /([^\/]*)$/ ? $1 : $_[0]; }
-
#- compare a version string.
-sub version_compare {
- my ($a, $b) = @_;
- local $_;
+use rpmtools;
- 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 $_;
- }
-}
+#- get basename for a file.
+sub basename { $_[0] =~ /([^\/]*)$/ ? $1 : $_[0]; }
#- system functions.
sub cp {
@@ -69,8 +61,8 @@ sub get_rpms {
if (/([^\/]*?)-([^-]*)-([^-]*)\.([^-\.]*)\.rpm$/) {
my $key = "$1 $4"; #- get name including architecture.
if ($rpms->{$key}) {
- if (version_compare($2, $rpms->{$key}{version}) > 0 ||
- version_compare($2, $rpms->{$key}{version}) == 0 && version_compare($3, $rpms->{$key}{release}) > 0) {
+ if (rpmtools::version_compare($2, $rpms->{$key}{version}) > 0 ||
+ rpmtools::version_compare($2, $rpms->{$key}{version}) == 0 && version_compare($3, $rpms->{$key}{release}) > 0) {
if ($modifiable) {
if ($flag->{sorted}) {
print "you said rpms directory are sorted, so I keep obseleted $rpms->{$key}{file} by $_ in $rpms->{$key}{dir}\n" if $flag->{verbose};
@@ -174,10 +166,10 @@ sub sync_rpms {
#- search in both part.
foreach (keys %$source) {
if ($target->{$_}) {
- if (version_compare($source->{$_}{version}, $target->{$_}{version}) > 0 ||
- version_compare($source->{$_}{version}, $target->{$_}{version}) == 0 &&
- (version_compare($source->{$_}{release}, $target->{$_}{release}) > 0 ||
- version_compare($source->{$_}{release}, $target->{$_}{release}) == 0 &&
+ if (rpmtools::version_compare($source->{$_}{version}, $target->{$_}{version}) > 0 ||
+ rpmtools::version_compare($source->{$_}{version}, $target->{$_}{version}) == 0 &&
+ (rpmtools::version_compare($source->{$_}{release}, $target->{$_}{release}) > 0 ||
+ rpmtools::version_compare($source->{$_}{release}, $target->{$_}{release}) == 0 &&
-s "$source->{$_}{dir}/$source->{$_}{file}" != -s "$target->{$_}{dir}/$target->{$_}{file}")) {
if ($flag->{verbose}) {
print "updating $target->{$_}{dir}/$target->{$_}{file} with newer version $source->{$_}{file}\n";
@@ -190,8 +182,8 @@ sub sync_rpms {
}
rm("$target->{$_}{dir}/$target->{$_}{file}") unless $source->{$_}{file} eq $target->{$_}{file}; #- copy on eq
}
- } elsif (version_compare($source->{$_}{version}, $target->{$_}{version}) != 0 ||
- version_compare($source->{$_}{release}, $target->{$_}{release}) != 0) {
+ } elsif (rpmtools::version_compare($source->{$_}{version}, $target->{$_}{version}) != 0 ||
+ rpmtools::version_compare($source->{$_}{release}, $target->{$_}{release}) != 0) {
if ($flag->{verbose}) {
print STDERR "keeping more up-to-date version $target->{$_}{dir}/$target->{$_}{file} against $source->{$_}{dir}/$source->{$_}{file}, check your repository !\n";
}