summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-11-29 11:07:10 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-11-29 11:07:10 +0000
commit57faea33c3d26f059aa32d464da1ace6d9b9e279 (patch)
treeab550ae51d71a9457bc34446810893881e81bcf8
parente32b95d1d22a1b2c785671783a51491cdd674daf (diff)
downloadurpmi-57faea33c3d26f059aa32d464da1ace6d9b9e279.tar
urpmi-57faea33c3d26f059aa32d464da1ace6d9b9e279.tar.gz
urpmi-57faea33c3d26f059aa32d464da1ace6d9b9e279.tar.bz2
urpmi-57faea33c3d26f059aa32d464da1ace6d9b9e279.tar.xz
urpmi-57faea33c3d26f059aa32d464da1ace6d9b9e279.zip
Display total number of packages along with progress bars in urpmi
(see bug #12514)
-rw-r--r--urpm.pm16
1 files changed, 12 insertions, 4 deletions
diff --git a/urpm.pm b/urpm.pm
index 50d9c4c7..3f073daf 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -2717,15 +2717,20 @@ sub extract_packages_to_install {
sub install_logger {
my ($urpm, $type, $id, $subtype, $amount, $total) = @_;
my $pkg = defined $id && $urpm->{depslist}[$id];
- my $progress_size = 50;
+ my $total_pkg = $urpm->{nb_install} + $urpm->{nb_upgrade};
+ my $progress_size = $total_pkg ? 45 : 50;
if ($subtype eq 'start') {
$urpm->{logger_progress} = 0;
if ($type eq 'trans') {
$urpm->{logger_id} ||= 0;
- printf "%-28s", N("Preparing...");
+ printf $total_pkg ? "%-33s" : "%-28s", N("Preparing...");
} else {
- printf "%4d:%-23s", ++$urpm->{logger_id}, ($pkg && $pkg->name);
+ if ($total_pkg) {
+ printf "%9s:%-23s", "(" . (++$urpm->{logger_id}) . "/" . $total_pkg . ")", ($pkg && $pkg->name);
+ } else {
+ printf "%4d:%-23s", ++$urpm->{logger_id}, ($pkg && $pkg->name);
+ }
}
} elsif ($subtype eq 'stop') {
if ($urpm->{logger_progress} < $progress_size) {
@@ -2840,11 +2845,14 @@ sub install {
} $pkg->files;
close $fh;
};
- if (keys %$install || keys %$upgrade) {
+ $urpm->{nb_install} = scalar keys %$install;
+ $urpm->{nb_upgrade} = scalar keys %$upgrade;
+ if ($urpm->{nb_install} || $urpm->{nb_upgrade}) {
$options{callback_inst} ||= \&install_logger;
$options{callback_trans} ||= \&install_logger;
}
@l = $trans->run($urpm, %options);
+ delete $urpm->{$_} for qw(nb_install nb_upgrade);
#- in case of error or testing, do not try to check rpmdb
#- for packages being upgraded or not.