summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2004-03-17 16:13:34 +0000
committerDaouda Lo <daouda@mandriva.com>2004-03-17 16:13:34 +0000
commit4c1ea31b962c7eee613a29740d06ee3bcb10f5a4 (patch)
tree590e6f2e9669495c38c90879c043b56b74427ff1
parent7fdc979dcc68490bbd9a3ff3a65b01576655ba5c (diff)
downloadmgaonline-4c1ea31b962c7eee613a29740d06ee3bcb10f5a4.tar
mgaonline-4c1ea31b962c7eee613a29740d06ee3bcb10f5a4.tar.gz
mgaonline-4c1ea31b962c7eee613a29740d06ee3bcb10f5a4.tar.bz2
mgaonline-4c1ea31b962c7eee613a29740d06ee3bcb10f5a4.tar.xz
mgaonline-4c1ea31b962c7eee613a29740d06ee3bcb10f5a4.zip
- changes for better error handling
-rwxr-xr-xmdkupdate71
1 files changed, 44 insertions, 27 deletions
diff --git a/mdkupdate b/mdkupdate
index 15a954d5..9b5aa0e0 100755
--- a/mdkupdate
+++ b/mdkupdate
@@ -69,43 +69,60 @@ my ($opt) = @ARGV;
my %o = getVarsFromSh($conffile);
if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) {
+ my $u;
my $MandrakeUpdateURL = $url->{online3_RemoteAction} . '?action=ScheduledRPM' . '&log=' . $o{LOGIN} . '&pass=' . $o{PASS} . '&host=' . $o{MACHINE} . '&key=' . $o{CURRENTKEY};
my $resp = getFromURL($MandrakeUpdateURL);
my $contents = $resp->content;
print " \n\n ***** Response from Online3_RemoteAction is : \n $contents \n end update_rpms answer **********\n\n";
if ($resp->is_success) {
- $ret = ($contents =~ /TRUE/) ? 0 : -1;
+ if ($contents =~ /TRUE/) { $ret = 10 } elsif ($contents = m/(\d+)/) { $u = sprintf("%d", $1) } else { $u = 83 } ;
+ my $action = {
+ 10 => sub {
+ print "\nCONTENTS = $contents \n";
+ my $c2h = splitContents($contents);
+ if ($c2h->{torf} eq "TRUE" && $c2h->{OLDKEY} && $c2h->{NEWKEY}) { updateConf($c2h->{OLDKEY}, $c2h->{NEWKEY}) }
+ if ($c2h->{FTP}) { addMedia($c2h->{FTP}) }
+ $scheduled = join(',',@{$c2h->{sched}});
+ $noscheduled = join(',',@{$c2h->{nosched}});
+ if ($opt eq '--applet') {
+ system "MandrakeUpdate","--media=mdkupdate","--pkg-sel=$scheduled","--pkg-nosel=$nosheduled";
+ } elsif ($opt eq '--auto') {
+ $o{AUTO} eq 'TRUE' and autoInstallRpms($c2h->{sched});
+ }
+ rpm_qa("/root/rpm_qa_installed_after");
+ my %new = getVarsFromSh($conffile);
+ if (! -s "/root/.mdkupdate.rpms" || $update) {
+ #- send configuration and get back key to use...
+ $new{CURRENTKEY} = send_config($new{LOGIN},$new{PASS},$new{MACHINE});
+ delete $new{OLDKEY};
+ #- save back keys.
+ setVarsInSh($conffile, \%new);
+ } else {
+ #- this can safely be ignored if new configuration is sent.
+ send_rpm_dif($new{LOGIN},$new{PASS},$new{MACHINE},$new{OLDKEY});
+ }
+ clean_dir();
+ },
+ 80 => sub {
+ log::l("[mdkupdate] Client password does not match in database")
+ },
+ 81 => sub {
+ log::l("[mdkupdate] Bad Authentification key. Please rerun mdkonline wizard")
+ },
+ 82 => sub {
+ log::l("[mdkupdate] No active Online service found for this host.")
+ }
+ 83 => sub {
+ log::l("[mdkupdate] Unknown problem, better relaunch mdkonline wizard")
+ }
+ }
+ $action->{$u}->();
} else {
- log_i(N("Connection problem")."\n" . N("MandrakeUpdate could not contact the site, we will try again."));
+ log::l(N("Connection problem")."\n" . N("MandrakeUpdate could not contact the site, we will try again."));
}
} else {
$ret = -1;
}
-if(!$ret) {
- my $c2h = splitContents($contents);
- if ($c2h->{torf} eq "TRUE" && $c2h->{OLDKEY} && $c2h->{NEWKEY}) { updateConf($c2h->{OLDKEY}, $c2h->{NEWKEY}) }
- if ($c2h->{FTP}) { addMedia($c2h->{FTP}) }
- $scheduled = join(',',@{$c2h->{sched}});
- $noscheduled = join(',',@{$c2h->{nosched}});
- if ($opt eq '--applet') {
- system "MandrakeUpdate","--media=mdkupdate","--pkg-sel=$scheduled","--pkg-nosel=$nosheduled";
- } elsif ($opt eq '--auto') {
- $o{AUTO} eq 'TRUE' and autoInstallRpms($c2h->{sched});
- }
- rpm_qa("/root/rpm_qa_installed_after");
- my %new = getVarsFromSh($conffile);
- if (! -s "/root/.mdkupdate.rpms" || $update) {
- #- send configuration and get back key to use...
- $new{CURRENTKEY} = send_config($new{LOGIN},$new{PASS},$new{MACHINE});
- delete $new{OLDKEY};
- #- save back keys.
- setVarsInSh($conffile, \%new);
- } else {
- #- this can safely be ignored if new configuration is sent.
- send_rpm_dif($new{LOGIN},$new{PASS},$new{MACHINE},$new{OLDKEY});
- }
- clean_dir();
-}
sub splitContents {
my $cont = shift;
my ($elem, $s);