summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2013-02-05 14:31:05 +0000
committerThierry Vignaud <tv@mageia.org>2013-02-05 14:31:05 +0000
commit424d49c945f5adea3425de2a1a8f173eb0ff82b5 (patch)
tree48b914c94bfceb01795cddeb0ef016886eb7a004
parentb00f4c5b263ca9e473b8bc4df06d5c44066cc0ad (diff)
downloadurpmi-424d49c945f5adea3425de2a1a8f173eb0ff82b5.tar
urpmi-424d49c945f5adea3425de2a1a8f173eb0ff82b5.tar.gz
urpmi-424d49c945f5adea3425de2a1a8f173eb0ff82b5.tar.bz2
urpmi-424d49c945f5adea3425de2a1a8f173eb0ff82b5.tar.xz
urpmi-424d49c945f5adea3425de2a1a8f173eb0ff82b5.zip
(install_logger) unify with callback_uninst(), thus fixing counting for
erasures (callback_uninst) restore quiet behavior when not in verbose mode (install) temporary set $urpm->{trans} adapt testsuite
-rw-r--r--NEWS3
-rw-r--r--t/superuser--obsolete-and-conflict.t9
-rw-r--r--urpm/install.pm46
3 files changed, 25 insertions, 33 deletions
diff --git a/NEWS b/NEWS
index 56a0f3a5..8b391ba3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+- fix counting for erasures
+- restore quiet behavior for erasures when not in verbose mode
+
Version 7.16 - 3 February 2013, by Thierry Vignaud
- add basic support for detecting I/O error
diff --git a/t/superuser--obsolete-and-conflict.t b/t/superuser--obsolete-and-conflict.t
index 08a968db..be3af8be 100644
--- a/t/superuser--obsolete-and-conflict.t
+++ b/t/superuser--obsolete-and-conflict.t
@@ -29,11 +29,12 @@ sub test1 {
urpmi('a');
check_installed_names('a');
- test_urpmi("b c", sprintf(<<'EOF', urpm::cfg::get_arch()));
- 1/2: c
- 2/2: b
+ my $arch = urpm::cfg::get_arch();
+ test_urpmi("b c", sprintf(<<'EOF', $arch, $arch));
+ 1/3: c
+ 2/3: b
removing package a-1-1.%s
- 1/1: a
+ 3/3: removing a-1-1.%s
EOF
check_installed_and_remove('b', 'c');
}
diff --git a/urpm/install.pm b/urpm/install.pm
index 2775cd30..6f705942 100644
--- a/urpm/install.pm
+++ b/urpm/install.pm
@@ -91,9 +91,9 @@ Standard logger for transactions
=cut
# install logger callback
+my ($erase_logger, $index);
sub install_logger {
- my ($urpm, $type, $id, $subtype, $amount, $total) = @_;
- my $pkg = defined $id && $urpm->{depslist}[$id];
+ my ($urpm, $type, undef, $subtype, $amount, $total) = @_;
my $total_pkg = $urpm->{nb_install};
local $| = 1;
@@ -104,7 +104,14 @@ sub install_logger {
my $p = N("Preparing...");
print $p, " " x (33 - length $p);
} else {
- my $pname = $pkg ? $pkg->name : '';
+ my $pname;
+ if ($type eq 'uninst') {
+ $pname = N("removing %s", $urpm->{trans}->Element_fullname($index));
+ $erase_logger->($urpm, undef, undef, $subtype);
+ } else {
+ # index already got bumped in {callback_open}:
+ $pname = $urpm->{trans}->Element_name($index-1);
+ }
++$urpm->{logger_count} if $pname;
my $cnt = $pname ? $urpm->{logger_count} : '-';
my $s = sprintf("%9s: %-22s", $cnt . "/" . $total_pkg, $pname);
@@ -241,7 +248,7 @@ sub _schedule_packages {
sub _get_callbacks {
my ($urpm, $db, $trans, $options, $install, $upgrade, $have_pkgs) = @_;
- my $index;
+ $index = 0;
my $fh;
my $is_test = $options->{test}; # fix circular reference
@@ -269,11 +276,8 @@ sub _get_callbacks {
#- ensure perl does not create a circular reference below, otherwise all this won't be collected,
# 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, $amount, $total) = @_;
-
- my $total_pkg = $trans->NElements - $urpm->{nb_install};
- local $| = 1;
+ $erase_logger = sub {
+ my ($urpm, undef, undef, $subtype) = @_;
if ($subtype eq 'start') {
my ($name, $fullname) = ($trans->Element_name($index), $trans->Element_fullname($index));
@@ -287,29 +291,11 @@ 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";
- }
}
};
+ $options->{callback_uninst} = $options->{verbose} >= 0 ? \&install_logger : $erase_logger;
+
$options->{callback_error} = sub {
my ($urpm, undef, $id, $subtype) = @_;
my $n = $urpm->{depslist}[$id]->fullname;
@@ -366,7 +352,9 @@ sub install {
_get_callbacks($urpm, $db, $trans, \%options, $install, $upgrade, scalar @trans_pkgs);
+ local $urpm->{trans} = $trans;
@errors = $trans->run($urpm, %options);
+ delete $urpm->{trans};
#- don't clear cache if transaction failed. We might want to retry.
if (!@errors && !$options{test} && $options{post_clean_cache}) {