summaryrefslogtreecommitdiffstats
path: root/urpm/parallel_ssh.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-07-09 21:02:32 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-07-09 21:02:32 +0000
commit9a938127fbb9337e7322a2b446fa992e17703058 (patch)
tree608331c1ec1a8ffc13cd0b8bc9958560d1581047 /urpm/parallel_ssh.pm
parent6ff044532c06e074f4bfc91073624a72660ba9eb (diff)
downloadurpmi-9a938127fbb9337e7322a2b446fa992e17703058.tar
urpmi-9a938127fbb9337e7322a2b446fa992e17703058.tar.gz
urpmi-9a938127fbb9337e7322a2b446fa992e17703058.tar.bz2
urpmi-9a938127fbb9337e7322a2b446fa992e17703058.tar.xz
urpmi-9a938127fbb9337e7322a2b446fa992e17703058.zip
create _scp() and use it
Diffstat (limited to 'urpm/parallel_ssh.pm')
-rw-r--r--urpm/parallel_ssh.pm21
1 files changed, 14 insertions, 7 deletions
diff --git a/urpm/parallel_ssh.pm b/urpm/parallel_ssh.pm
index 56506584..92976203 100644
--- a/urpm/parallel_ssh.pm
+++ b/urpm/parallel_ssh.pm
@@ -19,19 +19,28 @@ sub _nolock { &_localhost ? '--nolock ' : '' }
sub _ssh { &_localhost ? '' : "ssh $_[0] " }
sub _host { &_localhost ? '' : "$_[0]:" }
+sub _scp {
+ my ($urpm, $host, @para) = @_;
+ my $dest = pop @para;
+
+ $urpm->{log}("parallel_ssh: scp " . join(' ', @para) . " $host:$dest");
+ system('scp', @para, _host($host) . $dest) == 0
+ or $urpm->{fatal}(1, N("scp failed on host %s (%d)", $host, $? >> 8));
+}
+
sub scp_rpms {
my ($parallel, $urpm, @files) = @_;
foreach my $host (keys %{$parallel->{nodes}}) {
- $urpm->{log}("parallel_ssh: scp @files $host:$urpm->{cachedir}/rpms");
if (_localhost($host)) {
if (my @f = grep { dirname($_) ne "$urpm->{cachedir}/rpms" } @files) {
- system('cp', @f, "$urpm->{cachedir}/rpms");
+ $urpm->{log}("parallel_ssh: cp @f $urpm->{cachedir}/rpms");
+ system('cp', @f, "$urpm->{cachedir}/rpms") == 0
+ or $urpm->{fatal}(1, N("cp failed on host %s (%d)", $host, $? >> 8));
}
} else {
- system('scp', @files, "$host:$urpm->{cachedir}/rpms");
+ _scp($urpm, $host, @files, "$urpm->{cachedir}/rpms");
}
- $? == 0 or $urpm->{fatal}(1, N("scp failed on host %s (%d)", $host, $? >> 8));
}
}
@@ -100,9 +109,7 @@ sub parallel_resolve_dependencies {
#- first propagate the synthesis file to all machines
foreach (grep { !_localhost($_) } keys %{$parallel->{nodes}}) {
- $urpm->{log}("parallel_ssh: scp -q $synthesis $_:$synthesis");
- system "scp", "-q", $synthesis, _host($_) . $synthesis;
- $? == 0 or $urpm->{fatal}(1, N("scp failed on host %s (%d)", $_, $? >> 8));
+ _scp($urpm, $_, '-q', $synthesis, $synthesis);
}
$parallel->{synthesis} = $synthesis;