summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-01-23 14:30:04 +0000
committerFrancois Pons <fpons@mandriva.com>2003-01-23 14:30:04 +0000
commitb4e830357171338fbc62616ac87217e6ab3af4ba (patch)
tree5808859f973478e961aec5f83c19a026117c79ae
parent17acff9a4f8873d3c754af9e1c8cc4fa5bff2dd5 (diff)
downloadurpmi-b4e830357171338fbc62616ac87217e6ab3af4ba.tar
urpmi-b4e830357171338fbc62616ac87217e6ab3af4ba.tar.gz
urpmi-b4e830357171338fbc62616ac87217e6ab3af4ba.tar.bz2
urpmi-b4e830357171338fbc62616ac87217e6ab3af4ba.tar.xz
urpmi-b4e830357171338fbc62616ac87217e6ab3af4ba.zip
4.2-10mdk
-rw-r--r--urpm.pm58
-rwxr-xr-xurpmi11
-rw-r--r--urpmi.spec6
3 files changed, 63 insertions, 12 deletions
diff --git a/urpm.pm b/urpm.pm
index 3d746ff0..dfd8bebf 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -348,11 +348,30 @@ sub sync_rsync {
foreach (@_) {
my $count = 10; #- retry count on error (if file exists).
my $basename = (/^.*\/([^\/]*)$/ && $1) || $_;
+ my ($file) = /^rsync:\/\/(.*)/ or next;
+ ref $options && $options->{callback} and $options->{callback}('start', $file);
do {
- /^rsync:\/\/(.*)/ or next;
- system "/usr/bin/rsync", (ref $options && $options->{quiet} ? qw(-q) : qw(--progress -v)),
- qw(--partial --no-whole-file), $1, (ref $options ? $options->{dir} : $options);
+ local (*RSYNC, $_);
+ my $buf = '';
+ open RSYNC, "-|", "/usr/bin/rsync", (ref $options && $options->{quiet} ? qw(-q) : qw(--progress -v)),
+ qw(--partial --no-whole-file), $file, (ref $options ? $options->{dir} : $options);
+ local $/ = \1; #- read input by only one char, this is slow but very nice (and it works!).
+ while (<RSYNC>) {
+ $buf .= $_;
+ if ($_ eq "\r" || $_ eq "\n") {
+ if (ref $options && $options->{callback}) {
+ if (my ($percent, $speed) = $buf =~ /^\s*\d+\s+(\d+)%\s+(\S+)\s+/) {
+ $options->{callback}('progress', $file, $percent, undef, undef, $speed);
+ }
+ } else {
+ print STDERR $_;
+ }
+ $buf = '';
+ }
+ }
+ close RSYNC;
} while ($? != 0 && --$count > 0 && (-e (ref $options ? $options->{dir} : $options) . "/$basename"));
+ ref $options && $options->{callback} and $options->{callback}('end', $file);
}
$? == 0 or die _("rsync failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
}
@@ -360,13 +379,32 @@ sub sync_ssh {
-x "/usr/bin/rsync" or die _("rsync is missing\n");
-x "/usr/bin/ssh" or die _("ssh is missing\n");
my $options = shift @_;
- foreach (@_) {
+ foreach my $file (@_) {
my $count = 10; #- retry count on error (if file exists).
- my $basename = (/^.*\/([^\/]*)$/ && $1) || $_;
+ my $basename = ($file =~ /^.*\/([^\/]*)$/ && $1) || $file;
+ ref $options && $options->{callback} and $options->{callback}('start', $file);
do {
- system "/usr/bin/rsync", (ref $options && $options->{quiet} ? qw(-q) : qw(--progress -v)), qw(--partial -e ssh),
- $_, (ref $options ? $options->{dir} : $options);
+ local (*RSYNC, $_);
+ my $buf = '';
+ open RSYNC, "-|", "/usr/bin/rsync", (ref $options && $options->{quiet} ? qw(-q) : qw(--progress -v)),
+ qw(--partial -e ssh), $file, (ref $options ? $options->{dir} : $options);
+ local $/ = \1; #- read input by only one char, this is slow but very nice (and it works!).
+ while (<RSYNC>) {
+ $buf .= $_;
+ if ($_ eq "\r" || $_ eq "\n") {
+ if (ref $options && $options->{callback}) {
+ if (my ($percent, $speed) = $buf =~ /^\s*\d+\s+(\d+)%\s+(\S+)\s+/) {
+ $options->{callback}('progress', $file, $percent, undef, undef, $speed);
+ }
+ } else {
+ print STDERR $_;
+ }
+ $buf = '';
+ }
+ }
+ close RSYNC;
} while ($? != 0 && --$count > 0 && (-e (ref $options ? $options->{dir} : $options) . "/$basename"));
+ ref $options && $options->{callback} and $options->{callback}('end', $file);
}
$? == 0 or die _("rsync failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
}
@@ -377,7 +415,11 @@ sub sync_logger {
$file =~ s|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|$1xxxx$2|; #- if needed...
print STDERR " $file\n";
} elsif ($mode eq 'progress') {
- print STDERR _(" %s%% of %s, ETA = %s, speed = %s", $percent, $total, $eta, $speed) . "\r";
+ if (defined $total && defined $eta) {
+ print STDERR _(" %s%% of %s completed, ETA = %s, speed = %s", $percent, $total, $eta, $speed) . "\r";
+ } else {
+ print STDERR _(" %s%% completed, speed = %s", $percent, $speed) . "\r";
+ }
} elsif ($mode eq 'end') {
print STDERR (" "x79)."\r";
}
diff --git a/urpmi b/urpmi
index a73eb11f..a4d4c105 100755
--- a/urpmi
+++ b/urpmi
@@ -488,10 +488,15 @@ my %sources = $urpm->download_source_packages($local_sources, $list,
my ($mode, $file, $percent, $total, $eta, $speed) = @_;
if ($mode eq 'start') {
$file =~ s|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|$1xxxx$2|; #- if needed...
- print SAVEERR " $file\n";
+ print STDERR " $file\n"; #- allow pass-protected url to be logged.
} elsif ($mode eq 'progress') {
- print SAVEERR _(" %s%% of %s, ETA = %s, speed = %s",
- $percent, $total, $eta, $speed) . "\r";
+ if (defined $total && defined $eta) {
+ print SAVEERR _(" %s%% of %s completed, ETA = %s, speed = %s",
+ $percent, $total, $eta, $speed) . "\r";
+ } else {
+ print SAVEERR _(" %s%% completed, speed = %s",
+ $percent, $speed) . "\r";
+ }
} elsif ($mode eq 'end') {
print SAVEERR (" "x79)."\r";
}
diff --git a/urpmi.spec b/urpmi.spec
index b2e76a52..d82263eb 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -2,7 +2,7 @@
Name: urpmi
Version: 4.2
-Release: 9mdk
+Release: 10mdk
License: GPL
Source0: %{name}.tar.bz2
Source1: %{name}.logrotate
@@ -205,6 +205,10 @@ fi
%changelog
+* Thu Jan 23 2003 François Pons <fpons@mandrakesoft.com> 4.2-10mdk
+- added download log support for rsync and ssh protocol.
+- make log not visible in log file instead url.
+
* Thu Jan 23 2003 François Pons <fpons@mandrakesoft.com> 4.2-9mdk
- fix bug 994 according to Gerard Patel.
- added download log for urpmi.addmedia and urpmi.update.