summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-01-23 11:13:44 +0000
committerFrancois Pons <fpons@mandriva.com>2003-01-23 11:13:44 +0000
commit17acff9a4f8873d3c754af9e1c8cc4fa5bff2dd5 (patch)
treed7afcfd62bfd1344f9c9bf256f7a1e1bdd07ea8b
parentfece8f144f24a45fbbdb92ac2bcbe017379c09d3 (diff)
downloadurpmi-17acff9a4f8873d3c754af9e1c8cc4fa5bff2dd5.tar
urpmi-17acff9a4f8873d3c754af9e1c8cc4fa5bff2dd5.tar.gz
urpmi-17acff9a4f8873d3c754af9e1c8cc4fa5bff2dd5.tar.bz2
urpmi-17acff9a4f8873d3c754af9e1c8cc4fa5bff2dd5.tar.xz
urpmi-17acff9a4f8873d3c754af9e1c8cc4fa5bff2dd5.zip
4.2-9mdk
-rw-r--r--urpm.pm40
-rwxr-xr-xurpmi.addmedia10
-rw-r--r--urpmi.spec7
-rwxr-xr-xurpmi.update2
4 files changed, 41 insertions, 18 deletions
diff --git a/urpm.pm b/urpm.pm
index d6790d42..3d746ff0 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -224,7 +224,7 @@ sub sync_wget {
-x "/usr/bin/wget" or die _("wget is missing\n");
local *WGET;
my $options = shift @_;
- my ($buf, $file) = ('', undef);
+ my ($buf, $total, $file) = ('', undef, undef);
open WGET, "-|", "/usr/bin/wget",
(ref $options && $options->{proxy} ? set_proxy({type => "wget", proxy => $options->{proxy}}) : ()),
(ref $options && $options->{callback} ? ("--progress=bar:force", "-o", "-") :
@@ -236,14 +236,18 @@ sub sync_wget {
$buf .= $_;
if ($_ eq "\r" || $_ eq "\n") {
if (ref $options && $options->{callback}) {
- if ($buf =~ /^--\d\d:\d\d:\d\d--\s+(\S.*)\n/ms) {
+ if (! defined $file && $buf =~ /^--\d\d:\d\d:\d\d--\s+(\S.*)\n/ms) {
$file = $1;
$options->{callback}('start', $file);
- } elsif (my ($percent, $eta, $speed) = $buf =~ /^\s*(\d+)%\s+.*\s+(\S+)\s+ETA\s+(\S+)[\r\n]$/ms) {
- $options->{callback}('progress', $file, $percent, undef, $eta, $speed);
+ } elsif (defined $file && ! defined $total && $buf =~ /==>\s+RETR/) {
+ $total = '';
+ } elsif (defined $total && $total eq '' && $buf =~ /^[^:]*:\s+(\d\S*)/) {
+ $total = $1;
+ } elsif (my ($percent, $speed, $eta) = $buf =~ /^\s*(\d+)%.*\s+(\S+)\s+ETA\s+(\S+)\s*[\r\n]$/ms) {
+ $options->{callback}('progress', $file, $percent, $total, $eta, $speed);
if ($_ eq "\n") {
$options->{callback}('end', $file);
- $file = undef;
+ ($total, $file) = (undef, undef);
}
}
} else {
@@ -366,6 +370,18 @@ sub sync_ssh {
}
$? == 0 or die _("rsync failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
}
+#- default logger suitable for sync operation on STDERR only.
+sub sync_logger {
+ my ($mode, $file, $percent, $total, $eta, $speed) = @_;
+ if ($mode eq 'start') {
+ $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";
+ } elsif ($mode eq 'end') {
+ print STDERR (" "x79)."\r";
+ }
+}
#- read /etc/urpmi/urpmi.cfg as config file, keep compability with older
#- configuration file by examining if one entry is of the form
@@ -808,7 +824,8 @@ sub add_distrib_media {
unlink "$urpm->{cachedir}/partial/hdlists";
eval {
$urpm->{log}(_("retrieving hdlists file..."));
- $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 0, proxy => $urpm->{proxy}}, reduce_pathname("$url/Mandrake/base/hdlists"));
+ $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy}},
+ reduce_pathname("$url/Mandrake/base/hdlists"));
$urpm->{log}(_("...retrieving done"));
};
$@ and $urpm->{log}(_("...retrieving failed: %s", $@));
@@ -1137,7 +1154,7 @@ sub update_media {
}
eval {
$urpm->{log}(_("retrieving description file of \"%s\"...", $medium->{name}));
- $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy} },
+ $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy} },
reduce_pathname("$medium->{url}/../descriptions"));
$urpm->{log}(_("...retrieving done"));
};
@@ -1162,8 +1179,8 @@ sub update_media {
unlink "$urpm->{cachedir}/partial/$basename";
eval {
- $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy} },
- reduce_pathname("$medium->{url}/$_"));
+ $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 0, callback => $options{callback},
+ proxy => $urpm->{proxy} }, reduce_pathname("$medium->{url}/$_"));
};
if (!$@ && -s "$urpm->{cachedir}/partial/$basename" > 32) {
$medium->{with_hdlist} = $_;
@@ -1184,7 +1201,8 @@ sub update_media {
system("cp", "-pR", "$urpm->{statedir}/$medium->{hdlist}", "$urpm->{cachedir}/partial/$basename");
}
eval {
- $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 0, proxy => $urpm->{proxy}}, reduce_pathname("$medium->{url}/$medium->{with_hdlist}"));
+ $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 0, callback => $options{callback},
+ proxy => $urpm->{proxy}}, reduce_pathname("$medium->{url}/$medium->{with_hdlist}"));
};
if ($@) {
$urpm->{log}(_("...retrieving failed: %s", $@));
@@ -1688,7 +1706,7 @@ sub register_rpms {
unlink "$urpm->{cachedir}/partial/$basename";
eval {
$urpm->{log}(_("retrieving rpm file [%s] ...", $_));
- $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 0, proxy => $urpm->{proxy}}, $_);
+ $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy}}, $_);
$urpm->{log}(_("...retrieving done"));
$_ = "$urpm->{cachedir}/partial/$basename";
};
diff --git a/urpmi.addmedia b/urpmi.addmedia
index 29d1aba8..395c894d 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -144,7 +144,7 @@ and [options] are from
unlink "$urpm->{cachedir}/partial/$basename";
eval {
$urpm->{log}(_("retrieving mirrors at %s ...", $options{from}));
- $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 0, proxy => $urpm->{proxy}}, $options{from});
+ $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy}}, $options{from});
$urpm->{log}(_("...retrieving done"));
};
$@ and $urpm->{log}(_("...retrieving failed: %s", $@));
@@ -182,7 +182,7 @@ and [options] are from
$urpm->add_distrib_media($name, $url, update => $options{update});
}
- $urpm->update_media(%options);
+ $urpm->update_media(%options, callback => \&urpm::sync_logger);
if (my @unsynced_media = grep { $_->{modified} } @{$urpm->{media}}) {
print STDERR join("\n", map { _("unable to update medium \"%s\"\n", $_->{name}) } @unsynced_media);
@@ -190,7 +190,7 @@ and [options] are from
#- remove quietly the failing media.
$urpm->{log} = sub {};
$urpm->remove_selected_media;
- $urpm->update_media(%options);
+ $urpm->update_media(%options, callback => \&urpm::sync_logger);
}
} else {
$name or die $usage;
@@ -202,7 +202,7 @@ and [options] are from
}
$urpm->add_medium($name, $url, $relative_hdlist, update => $options{update});
- $urpm->update_media(%options);
+ $urpm->update_media(%options, callback => \&urpm::sync_logger);
#- check creation of media (during update has been successfull)
my ($medium) = grep { $_->{name} eq $name } @{$urpm->{media}};
@@ -212,7 +212,7 @@ and [options] are from
#- remove quietly the failing media.
$urpm->{log} = sub {};
$urpm->remove_selected_media;
- $urpm->update_media(%options);
+ $urpm->update_media(%options, callback => \&urpm::sync_logger);
}
}
}
diff --git a/urpmi.spec b/urpmi.spec
index e959f09a..b2e76a52 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -2,7 +2,7 @@
Name: urpmi
Version: 4.2
-Release: 8mdk
+Release: 9mdk
License: GPL
Source0: %{name}.tar.bz2
Source1: %{name}.logrotate
@@ -205,6 +205,11 @@ fi
%changelog
+* 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.
+- fixed wget download log with total size available.
+
* Wed Jan 22 2003 François Pons <fpons@mandrakesoft.com> 4.2-8mdk
- add callback support for download (fix bug 632 and 387).
diff --git a/urpmi.update b/urpmi.update
index 3325552f..c9c9b8d7 100755
--- a/urpmi.update
+++ b/urpmi.update
@@ -93,7 +93,7 @@ where <name> is a medium name to update.
$something_todo or die _("the entry to update is missing\n(one of %s)\n", join(", ", @entries));
}
- $urpm->update_media(%options);
+ $urpm->update_media(%options, callback => \&urpm::sync_logger);
}
main(@ARGV);