summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-28 09:56:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-28 09:56:32 +0000
commiteabc176287bd29cfd8f49b97937092297009ff67 (patch)
tree66b185978d1aa3f30393970447470aea56972478
parent0be5a05e064a676b72052422f0e8f7e434e4c2c8 (diff)
downloadurpmi-eabc176287bd29cfd8f49b97937092297009ff67.tar
urpmi-eabc176287bd29cfd8f49b97937092297009ff67.tar.gz
urpmi-eabc176287bd29cfd8f49b97937092297009ff67.tar.bz2
urpmi-eabc176287bd29cfd8f49b97937092297009ff67.tar.xz
urpmi-eabc176287bd29cfd8f49b97937092297009ff67.zip
factorize code with new function _error(). make separate message for either bad exit status or signal caught
-rw-r--r--urpm/download.pm19
1 files changed, 13 insertions, 6 deletions
diff --git a/urpm/download.pm b/urpm/download.pm
index 0b6b94e9..7d2b8d6a 100644
--- a/urpm/download.pm
+++ b/urpm/download.pm
@@ -188,6 +188,14 @@ sub set_proxy {
return @res;
}
+sub _error {
+ my ($name) = @_;
+
+ my $msg = $? & 127 ? N("%s failed: exited with signal %d", $name, $? & 127) :
+ N("%s failed: exited with %d", $name, $? >> 8);
+ die "$msg\n";
+}
+
sub propagate_sync_callback {
my $options = shift;
if (ref($options) && $options->{callback}) {
@@ -274,7 +282,7 @@ sub sync_wget {
}
$file and propagate_sync_callback($options, 'end', $file);
chdir $cwd;
- close $wget or die N("wget failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
+ close $wget or _error('wget');
}
sub sync_curl {
@@ -335,8 +343,7 @@ sub sync_curl {
};
}
}
- close $curl
- or die N("curl failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
+ close $curl or _error('curl');
#- now analyse size and time stamp according to what already exists here.
if (@ftp_files) {
@@ -422,7 +429,7 @@ sub sync_curl {
}
}
chdir $cwd;
- close $curl or die N("curl failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
+ close $curl or _error('curl');
} else {
chdir $cwd;
}
@@ -483,7 +490,7 @@ sub sync_rsync {
propagate_sync_callback($options, 'end', $file);
}
chdir $cwd;
- $? == 0 or die N("rsync failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
+ $? == 0 or _error('rsync');
}
our $SSH_PATH;
@@ -538,7 +545,7 @@ sub sync_prozilla {
if ($? == -1) {
die N("Couldn't execute prozilla\n");
} else {
- die N("prozilla failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
+ _error('prozilla');
}
}
}