summaryrefslogtreecommitdiffstats
path: root/mdkapplet
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2004-03-23 18:30:18 +0000
committerDaouda Lo <daouda@mandriva.com>2004-03-23 18:30:18 +0000
commit1028be9f23177cf06d73f5489dfb6b85849991bc (patch)
tree462d3236e39c2d8c4aa8c656f587f4bf0d2c4089 /mdkapplet
parent834b6d978639c8ea137c3d688ba497c2640d52b7 (diff)
downloadmgaonline-1028be9f23177cf06d73f5489dfb6b85849991bc.tar
mgaonline-1028be9f23177cf06d73f5489dfb6b85849991bc.tar.gz
mgaonline-1028be9f23177cf06d73f5489dfb6b85849991bc.tar.bz2
mgaonline-1028be9f23177cf06d73f5489dfb6b85849991bc.tar.xz
mgaonline-1028be9f23177cf06d73f5489dfb6b85849991bc.zip
- better algo to check updates
Diffstat (limited to 'mdkapplet')
-rwxr-xr-xmdkapplet21
1 files changed, 13 insertions, 8 deletions
diff --git a/mdkapplet b/mdkapplet
index 20691579..aa5b1563 100755
--- a/mdkapplet
+++ b/mdkapplet
@@ -192,16 +192,19 @@ sub silentCheck {
# 98 - wrong pass
# 97 - host not active
my $retcode = {
- 10 => sub { $isAvailable = 0; $mLog .= N("System is up to date\n") ;go2State('okay') },
+ 10 => sub { okState() },
11 => sub {
my @contents = sort ( split /\n/, $ct);
my @t = split /\n/, `rpm -qa`;
+ my $comp = 0;
foreach my $cand (@contents) {
$cand =~ s/\.(i586|ppc|ia64).rpm//;
$cand =~ /(.*)-(.*)-(.*)$/; my ($name, $ver, $rel) = ($1, $2, $3);
- my $comp = compareWithInstalled($name, $ver, $rel, \@t);
- if ($comp) { $isAvailable = 1; $mLog .= N("Checking... Updates are available\n"); go2State('error') and last } else { $isAvailable = 0; go2State('okay') and last };
+ $comp = compareWithInstalled($name, $ver, $rel, \@t);
+ #print "COMP = $comp\n";
+ if ($comp) { $isAvailable = 1; $mLog .= N("Checking... Updates are available\n"); go2State('error') and last } else { $isAvailable = 0 };
}
+ !$comp and okState();
},
97 => sub { $mLog .= N("Online services disabled. Contact MandrakeOnline site\n") ; go2State('disabled'); },
98 => sub { $mLog .= N("Wrong Password.\n"); go2State('critical'); },
@@ -209,17 +212,19 @@ sub silentCheck {
};
$retcode->{$u}->();
}
+sub okState { $isAvailable = 0; $mLog=N("System is up to date"); go2State('okay') }
sub compareWithInstalled {
my ($name, $ver, $rel, $t) = @_;
my $isUpdate = 0;
foreach my $p (@{$t}) {
$p =~ /(.*)-(.*)-(.*)$/; my ($n, $v, $r) = ($1, $2, $3);
- if ($name eq $n ) {
- my $iu = rpmvercmp($ver, $v); my $ir = rpmvercmp( $rel, $r);
- #print "$name-$ver-$rel $n-$v-$r *** CMPVER=$iu ** CMPREL = $ir \n";
+ if ($name eq $n) {
+ #my $iu = rpmvercmp($ver, $v); my $ir = rpmvercmp( $rel,
+ #$r); print "$name-$ver-$rel $n-$v-$r *** CMPVER=$iu ** CMPREL = $ir \n";
+
if (rpmvercmp($ver, $v) > 0 || ( rpmvercmp($ver, $v) == 0 && rpmvercmp( $rel, $r) > 0)) {
$isUpdate = 1 and last;
- }
+ }
}
}
$isUpdate
@@ -329,7 +334,7 @@ sub checkUpdates {
} else {
$update_label and setLabel($update_label, N("Checking for Updates..."));
setLastTime();
- $lastch and setLabel($lastch, lastCheck() );
+ $lastch and setLabel($lastch, lastCheck());
silentCheck();
}
setLabel($update_label, $isAvailable ? N("Available") : N("Not Available"));