summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mandriva.org>2009-08-11 15:50:38 +0000
committerThierry Vignaud <tv@mandriva.org>2009-08-11 15:50:38 +0000
commit851d102e779e84d843a71b9f5a730be59b5e69c0 (patch)
treeeb1aca2f5990431ae29e83c85402dd1411eadc99
parent67bbf4e2bcb1ece11f00d13845b08b35a46cbcb5 (diff)
downloadurpmi-851d102e779e84d843a71b9f5a730be59b5e69c0.tar
urpmi-851d102e779e84d843a71b9f5a730be59b5e69c0.tar.gz
urpmi-851d102e779e84d843a71b9f5a730be59b5e69c0.tar.bz2
urpmi-851d102e779e84d843a71b9f5a730be59b5e69c0.tar.xz
urpmi-851d102e779e84d843a71b9f5a730be59b5e69c0.zip
(install,run) prevent garbaging text installer (#50776)
rationale: all prints in transaction/installation code now go through a callback that redirects the output at install time
-rw-r--r--NEWS1
-rw-r--r--urpm.pm1
-rw-r--r--urpm/install.pm9
-rw-r--r--urpm/main_loop.pm14
4 files changed, 14 insertions, 11 deletions
diff --git a/NEWS b/NEWS
index ef8d2073..735f9829 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+- prevent garbaging text installer screen (#50776)
- urpmq:
o -a option was ignored when using --src (fixes #52672)
- urpmi.addmedia:
diff --git a/urpm.pm b/urpm.pm
index cf62fe5e..848074bb 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -57,6 +57,7 @@ sub new {
error => sub { printf STDERR "%s\n", $_[0] },
info => sub { printf "%s\n", $_[0] }, #- displayed unless --quiet
log => sub { printf "%s\n", $_[0] }, #- displayed if --verbose
+ print => sub { printf "%s\n", $_[0] }, #- always displayed, enable to redirect output for eg: installer
ui_msg => sub {
# deprecated
$self->{log}($_[0]);
diff --git a/urpm/install.pm b/urpm/install.pm
index 675bd872..2ff075ca 100644
--- a/urpm/install.pm
+++ b/urpm/install.pm
@@ -256,7 +256,7 @@ sub install {
$urpm->{log}("removing upgraded package $fullname");
} else {
$callback_report_uninst and $callback_report_uninst->(N("Removing package %s", $fullname));
- print N("removing package %s", $fullname), "\n" if $verbose >= 0;
+ $urpm->{print}(N("removing package %s", $fullname)) if $verbose >= 0;
}
$index++;
}
@@ -280,9 +280,10 @@ sub install {
if ($options{verbose} >= 0) {
foreach (keys %{$urpm->{readmes}}) {
- print "-" x 70, "\n", N("More information on package %s", $urpm->{readmes}{$_}), "\n";
- print cat_utf8(($urpm->{root} || '') . $_);
- print "-" x 70, "\n";
+ $urpm->{print}("-" x 70 . "\n" .
+ N("More information on package %s", $urpm->{readmes}{$_}));
+ $urpm->{print}(scalar cat_utf8(($urpm->{root} || '') . $_));
+ $urpm->{print}("-" x 70);
}
}
}
diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm
index 010eeb0b..32f08dd5 100644
--- a/urpm/main_loop.pm
+++ b/urpm/main_loop.pm
@@ -171,7 +171,7 @@ foreach my $set (@{$state->{transaction} || []}) {
system("rpm", "-i$rpm_opt", @l, ($urpm->{root} ? ("--root", $urpm->{root}) : @{[]}));
#- Warning : the following message is parsed in urpm::parallel_*
if ($?) {
- print N("Installation failed"), "\n";
+ $urpm->{print}(N("Installation failed"));
++$nok;
} elsif ($urpm->{options}{'post-clean'}) {
if (my @tmp_srpm = grep { urpm::is_temporary_file($urpm, $_) } @l) {
@@ -195,7 +195,7 @@ foreach my $set (@{$state->{transaction} || []}) {
if (keys(%transaction_sources_install) || keys(%$transaction_sources) || $set->{remove}) {
if ($parallel) {
- print N("distributing %s", join(' ', values %transaction_sources_install, values %$transaction_sources)), "\n";
+ $urpm->{print}(N("distributing %s", join(' ', values %transaction_sources_install, values %$transaction_sources)));
#- no remove are handle here, automatically done by each distant node.
$urpm->{log}("starting distributed install");
$urpm->{parallel_handler}->parallel_install(
@@ -210,9 +210,9 @@ foreach my $set (@{$state->{transaction} || []}) {
(my $common_prefix) = $packnames[0] =~ m!^(.*)/!;
if (length($common_prefix) && @packnames == grep { m!^\Q$common_prefix/! } @packnames) {
#- there's a common prefix, simplify message
- print N("installing %s from %s", join(' ', map { s!.*/!!; $_ } @packnames), $common_prefix), "\n";
+ $urpm->{print}(N("installing %s from %s", join(' ', map { s!.*/!!; $_ } @packnames), $common_prefix));
} else {
- print N("installing %s", join "\n", @packnames), "\n";
+ $urpm->{print}(N("installing %s", join "\n", @packnames));
}
}
}
@@ -290,10 +290,10 @@ $callbacks->{completed} and $callbacks->{completed}->();
if ($nok) {
$callbacks->{trans_error_summary} and $callbacks->{trans_error_summary}->($nok, \@errors);
if (@formatted_errors) {
- print join("\n", @formatted_errors), "\n";
+ $urpm->{print}(join("\n", @formatted_errors));
}
if (@errors) {
- print N("Installation failed:"), "\n", map { "\t$_\n" } @errors;
+ $urpm->{print}(N("Installation failed:")), map { "\t$_\n" } @errors;
}
$exit_code ||= $ok ? 11 : 12;
} else {
@@ -303,7 +303,7 @@ if ($nok) {
if ($auto_select) {
if ($options{verbose} >= 0) {
#- Warning : the following message is parsed in urpm::parallel_*
- print N("Packages are up to date"), "\n";
+ $urpm->{print}(N("Packages are up to date"));
}
} else {
if ($callbacks->{already_installed_or_not_installable}) {