From 9a938127fbb9337e7322a2b446fa992e17703058 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 9 Jul 2008 21:02:32 +0000 Subject: create _scp() and use it --- urpm/parallel_ssh.pm | 21 ++++++++++++++------- 1 file 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; -- cgit v1.2.1