summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2013-02-03 22:18:23 +0000
committerThierry Vignaud <tv@mageia.org>2013-02-03 22:18:23 +0000
commitfdd0bf67b2723c8eaccc53ac41d05dd54b73f43f (patch)
tree6e6ac1dd9d5e28588cf7397914c50eecf912fe75 /urpm
parent18228aa2fdd1aac34e953493528a43fa4f86a8ee (diff)
downloadurpmi-fdd0bf67b2723c8eaccc53ac41d05dd54b73f43f.tar
urpmi-fdd0bf67b2723c8eaccc53ac41d05dd54b73f43f.tar.gz
urpmi-fdd0bf67b2723c8eaccc53ac41d05dd54b73f43f.tar.bz2
urpmi-fdd0bf67b2723c8eaccc53ac41d05dd54b73f43f.tar.xz
urpmi-fdd0bf67b2723c8eaccc53ac41d05dd54b73f43f.zip
(callback_uninst) display erasure progress
inspirated from install_logger() adjust testsuite accordingly
Diffstat (limited to 'urpm')
-rw-r--r--urpm/install.pm26
1 files changed, 25 insertions, 1 deletions
diff --git a/urpm/install.pm b/urpm/install.pm
index b7fd6dd9..2670cf3c 100644
--- a/urpm/install.pm
+++ b/urpm/install.pm
@@ -269,7 +269,11 @@ sub _get_callbacks {
# and rpmdb won't be closed
my ($verbose, $callback_report_uninst) = ($options->{verbose}, $options->{callback_report_uninst});
$options->{callback_uninst} = sub {
- my ($_urpm, undef, undef, $subtype) = @_;
+ my ($urpm, undef, undef, $subtype, $amount, $total) = @_;
+
+ my $total_pkg = $trans->NElements - $urpm->{nb_install};
+ local $| = 1;
+
if ($subtype eq 'start') {
my ($name, $fullname) = ($trans->Element_name($index), $trans->Element_fullname($index));
my @previous = map { $trans->Element_name($_) } 0 .. ($index - 1);
@@ -282,6 +286,26 @@ sub _get_callbacks {
$urpm->{print}(N("removing package %s", $fullname)) if $verbose >= 0;
}
$index++;
+
+ $urpm->{logger_uninst_progress} = 0;
+ ++$urpm->{logger_uninst_count} if $name;
+ my $cnt = $name ? $urpm->{logger_uninst_count} : '-';
+ my $s = sprintf("%9s: %-22s", $cnt . "/" . $total_pkg, $name);
+ print $s;
+ $s =~ / $/ or printf "\n%9s %-22s", '', '';
+
+ } elsif ($subtype eq 'stop') {
+ if ($urpm->{logger_uninst_progress} < $progress_size) {
+ $urpm->{print}('#' x ($progress_size - $urpm->{logger_uninst_progress}));
+ $urpm->{logger_uninst_progress} = 0;
+ }
+ } elsif ($subtype eq 'progress') {
+ my $new_progress = $total > 0 ? int($progress_size * $amount / $total) : $progress_size;
+ if ($new_progress > $urpm->{logger_uninst_progress}) {
+ print '#' x ($new_progress - $urpm->{logger_uninst_progress});
+ $urpm->{logger_uninst_progress} = $new_progress;
+ $urpm->{logger_uninst_progress} == $progress_size and print "\n";
+ }
}
};