summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-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";
}