summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--NEWS2
-rw-r--r--t/superuser--obsolete-and-conflict.t1
-rw-r--r--urpm/install.pm26
3 files changed, 28 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index fe3b4f89..9b6d2cfd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+- display erasure progress too
+
Version 7.15.2 - 16 January 2013, by Thierry Vignaud
- update translations
diff --git a/t/superuser--obsolete-and-conflict.t b/t/superuser--obsolete-and-conflict.t
index 343f9ed0..08a968db 100644
--- a/t/superuser--obsolete-and-conflict.t
+++ b/t/superuser--obsolete-and-conflict.t
@@ -33,6 +33,7 @@ sub test1 {
1/2: c
2/2: b
removing package a-1-1.%s
+ 1/1: a
EOF
check_installed_and_remove('b', 'c');
}
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";
+ }
}
};