summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2006-02-08 15:11:47 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2006-02-08 15:11:47 +0000
commit1015446c571e56ec6a5b0f1aae497cbcf3fe6ef9 (patch)
treeab35b78e5311c609d715f559d55bc3410d403bc3
parente5172c4bcf96785aaae10fbc69d5407599f2a718 (diff)
downloadurpmi-1015446c571e56ec6a5b0f1aae497cbcf3fe6ef9.tar
urpmi-1015446c571e56ec6a5b0f1aae497cbcf3fe6ef9.tar.gz
urpmi-1015446c571e56ec6a5b0f1aae497cbcf3fe6ef9.tar.bz2
urpmi-1015446c571e56ec6a5b0f1aae497cbcf3fe6ef9.tar.xz
urpmi-1015446c571e56ec6a5b0f1aae497cbcf3fe6ef9.zip
Get rid of message() function
-rw-r--r--urpm/args.pm2
-rw-r--r--urpm/msg.pm15
-rwxr-xr-xurpmi58
3 files changed, 35 insertions, 40 deletions
diff --git a/urpm/args.pm b/urpm/args.pm
index a9010fe9..1acf0640 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -72,7 +72,7 @@ my %options_spec = (
'no-remove|no-uninstall' => \$::no_remove,
'no-install|noinstall' => \$::no_install,
keep => sub { $urpm->{options}{keep} = 1 },
- logfile => \$::logfile,
+ 'logfile=s' => \$::logfile,
'split-level=s' => sub { $urpm->{options}{'split-level'} = $_[1] },
'split-length=s' => sub { $urpm->{options}{'split-length'} = $_[1] },
'fuzzy!' => sub { $urpm->{options}{fuzzy} = $_[1] },
diff --git a/urpm/msg.pm b/urpm/msg.pm
index 5d633ace..e46638b0 100644
--- a/urpm/msg.pm
+++ b/urpm/msg.pm
@@ -7,7 +7,7 @@ use Exporter;
(our $VERSION) = q$Id$ =~ /(\d+\.\d+)/;
our @ISA = 'Exporter';
-our @EXPORT = qw(N bug_log to_utf8 message_input message toMb from_utf8 sys_log);
+our @EXPORT = qw(N bug_log to_utf8 message_input toMb from_utf8 sys_log);
#- I18N.
use Locale::gettext;
@@ -93,20 +93,11 @@ sub message_input {
} else {
last;
}
- message(N("Sorry, bad choice, try again\n"));
+ print N("Sorry, bad choice, try again\n");
}
return $input;
}
-sub message {
- my ($msg) = @_;
- if ($urpm::args::options{bug} || !defined fileno ::SAVEOUT) {
- print STDOUT "$msg\n";
- } else {
- print ::SAVEOUT "$msg\n";
- }
-}
-
sub toMb {
my $nb = $_[0] / 1024 / 1024;
int $nb + 0.5;
@@ -130,6 +121,6 @@ urpm::msg - routines to prompt messages from the urpm* tools
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 MandrakeSoft SA
-Copyright (C) 2005 Mandriva SA
+Copyright (C) 2005, 2006 Mandriva SA
=cut
diff --git a/urpmi b/urpmi
index 4096888a..7456fec0 100755
--- a/urpmi
+++ b/urpmi
@@ -320,7 +320,7 @@ if (exists $urpm->{options}{'priority-upgrade'} && $urpm->{options}{'priority-up
}
if ($auto_update && !$bug && !$env) {
#- For translators : there are several media here
- message(N("Updating media..."));
+ print N("Updating media..."), "\n";
#- FIXME we need to configure it twice; otherwise
#- some settings are lost (like the skiplist) for
#- some reason.
@@ -401,8 +401,9 @@ sub ask_choice {
} @$choices;
if (@l > 1 && !$urpm->{options}{auto}) {
- message(N("One of the following packages is needed:"));
- my $i = 0; foreach (@l) { message(" " . ++$i . "- $_") }
+ print N("One of the following packages is needed:"), "\n";
+ my $i = 0;
+ foreach (@l) { print " " . ++$i . "- $_\n" }
$n = message_input(N("What is your choice? (1-%d) ", $i), undef, range_min => 0, range => $i);
defined($n) && $n ne "0" or exit 1; # abort.
if ($n =~ /\D/) {
@@ -436,7 +437,7 @@ if (@unselected_uninstalled) {
my $msg = N("The following packages can't be installed because they depend on packages
that are older than the installed ones:\n%s", $list);
if ($urpm->{options}{auto}) {
- message($msg);
+ print "$msg\n";
} else {
my $noexpr = N("Nn");
my $yesexpr = N("Yy");
@@ -454,7 +455,7 @@ if (@ask_unselect) {
my $list = join "\n", $urpm->translate_why_unselected($state, sort @ask_unselect);
my $msg = N("Some requested packages cannot be installed:\n%s", $list);
if ($urpm->{options}{auto}) {
- message($msg);
+ print "$msg\n";
} else {
my $noexpr = N("Nn");
my $yesexpr = N("Yy");
@@ -482,8 +483,8 @@ if (@ask_remove) {
my $list = join "\n", $urpm->translate_why_removed($state, sort @ask_remove);
if ($no_remove && !$force) {
- message(N("The installation cannot continue because the following packages
-have to be removed for others to be upgraded:\n%s\n", $list));
+ print N("The installation cannot continue because the following packages
+have to be removed for others to be upgraded:\n%s\n", $list), "\n";
exit 0;
}
@@ -492,7 +493,7 @@ have to be removed for others to be upgraded:\n%s\n", $list));
$msg = "$msg\n" . N("(test only, removal will not be actually done)");
}
if ($urpm->{options}{auto}) {
- message($msg);
+ print "$msg\n";
} else {
my $noexpr = N("Nn");
my $yesexpr = N("Yy");
@@ -593,7 +594,7 @@ foreach my $set (@{$state->{transaction} || []}) {
my (@transaction_list, %transaction_sources);
#- put a blank line to separate with previous transaction or user question.
- message("");
+ print "\n";
#- prepare transaction...
$urpm->prepare_transaction($set, $list, \%sources, \@transaction_list, \%transaction_sources);
@@ -624,7 +625,7 @@ foreach my $set (@{$state->{transaction} || []}) {
my $p = join "\n", @bad_signatures;
#- rurpmi always abort here
if ($urpm->{options}{auto} || $restricted) {
- message("$msg:\n$p\n");
+ print "$msg:\n$p\n\n";
exit 1;
} else {
my $noexpr = N("Nn");
@@ -637,8 +638,8 @@ foreach my $set (@{$state->{transaction} || []}) {
#- check for local files.
if (my @missing = grep { m|^/| && ! -e $_ } values %transaction_sources_install, values %transaction_sources) {
#- Warning : the following message is parsed in urpm::parallel_*
- message(N("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database",
- join "\n", map { s|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|$1xxxx$2|; " $_" } @missing));
+ print N("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database",
+ join "\n", map { s|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|$1xxxx$2|; " $_" } @missing), "\n";
++$nok;
next;
}
@@ -648,7 +649,10 @@ foreach my $set (@{$state->{transaction} || []}) {
if (my @l = grep { /\.src\.rpm$/ } values %transaction_sources_install, values %transaction_sources) {
system("rpm", "-i$rpm_opt", @l, ($root ? ("--root", $root) : @{[]}));
#- Warning : the following message is parsed in urpm::parallel_*
- $? and message(N("Installation failed")), ++$nok;
+ if ($?) {
+ print N("Installation failed"), "\n";
+ ++$nok;
+ }
}
next;
}
@@ -665,7 +669,7 @@ foreach my $set (@{$state->{transaction} || []}) {
if (keys(%transaction_sources_install) || keys(%transaction_sources)) {
if ($parallel) {
- message(N("distributing %s", join(' ', values %transaction_sources_install, values %transaction_sources)));
+ print N("distributing %s", join(' ', values %transaction_sources_install, values %transaction_sources)), "\n";
#- no remove are handle here, automatically done by each distant node.
$urpm->{log}("starting distributed install");
$urpm->parallel_install([ keys %{$state->{rejected} || {}} ], \%transaction_sources_install, \%transaction_sources,
@@ -676,12 +680,12 @@ foreach my $set (@{$state->{transaction} || []}) {
(my $common_prefix) = $packnames[0] =~ /^(.*)\//;
if (length($common_prefix) && @packnames == grep { /^\Q$common_prefix\// } @packnames) {
#- there's a common prefix, simplify message
- message(N("installing %s from %s", join(' ', map { s/.*\///; $_ } @packnames), $common_prefix));
+ print N("installing %s from %s", join(' ', map { s/.*\///; $_ } @packnames), $common_prefix), "\n";
} else {
- message(N("installing %s", join(' ', @packnames)));
+ print N("installing %s", "@packnames"), "\n";
}
my $to_remove = $urpm->{options}{'allow-force'} ? [] : ($set->{remove} || []);
- @$to_remove and message(N("removing %s", "@$to_remove"));
+ @$to_remove and print N("removing %s", "@$to_remove"), "\n";
bug_log(scalar localtime, " ", join(' ', values %transaction_sources_install, values %transaction_sources), "\n");
$urpm->{log}("starting installing packages");
my %install_options_common = (
@@ -702,7 +706,7 @@ foreach my $set (@{$state->{transaction} || []}) {
);
if (@l) {
#- Warning : the following message is parsed in urpm::parallel_*
- message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
+ print N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l), "\n";
if ($urpm->{options}{auto} || !$urpm->{options}{'allow-nodeps'} && !$urpm->{options}{'allow-force'}) {
++$nok;
++$urpm->{logger_id};
@@ -722,7 +726,7 @@ foreach my $set (@{$state->{transaction} || []}) {
);
if (@l) {
#- Warning : the following message is parsed in urpm::parallel_*
- message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
+ print N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l), "\n";
if (!$urpm->{options}{'allow-force'}) {
++$nok;
++$urpm->{logger_id};
@@ -740,7 +744,7 @@ foreach my $set (@{$state->{transaction} || []}) {
);
if (@l) {
#- Warning : the following message is parsed in urpm::parallel_*
- message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
+ print N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l), "\n";
++$nok;
++$urpm->{logger_id};
push @errors, @l;
@@ -763,12 +767,12 @@ foreach my $set (@{$state->{transaction} || []}) {
my $exit_code = 0;
if (values %error_sources) {
#- Warning : the following message is parsed in urpm::parallel_*
- message(N("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database",
- join "\n", map { s|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|$1xxxx$2|; " $_" } values %error_sources));
+ print N("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database",
+ join "\n", map { s|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)|$1xxxx$2|; " $_" } values %error_sources), "\n";
$exit_code = 10;
}
if ($nok) {
- $nok > 1 and message(N("%d installation transactions failed", $nok) . (@errors && ":\n" . join("\n", map { "\t$_" } @errors)));
+ $nok > 1 and print N("%d installation transactions failed", $nok) . (@errors && ":\n" . join("\n", map { "\t$_" } @errors)), "\n";
if ($exit_code) {
$exit_code = $ok ? 13 : 14;
} else {
@@ -777,14 +781,14 @@ if ($nok) {
} else {
if ($test) {
#- Warning : the following message is parsed in urpm::parallel_*
- message(N("Installation is possible"));
+ print N("Installation is possible"), "\n";
} elsif (@names || @src_names || @files || @src_files || $auto_select) {
if (@{$state->{transaction} || []} == 0 && @ask_unselect == 0) {
- message(N("The package(s) are already installed")) if $verbose >= 0;
+ print N("The package(s) are already installed"), "\n" if $verbose >= 0;
if ($verbose >= 0 && !$auto_select) {
my @packages = map { $urpm->{depslist}[$_]->name } keys %requested;
my @guessed = difference2(\@packages, \(@names, @src_names));
- message(N("The following package names were assumed: %s", join ", ", @guessed)) if @guessed;
+ print N("The following package names were assumed: %s", join ", ", @guessed), "\n" if @guessed;
}
$exit_code = 15 if our $expect_install;
}
@@ -801,7 +805,7 @@ unless ($env || $nolock) {
#- restart urpmi if needed, keep command line for that.
if ($restart_itself && !$exit_code) {
- message(N("restarting urpmi"));
+ print N("restarting urpmi"), "\n";
#- it seems to work correctly with exec instead of system, provided
#- STDOUT or STDERR are not closed before (else no output at all).
#- added --no-priority-upgrade to make sure no restart will be done after this one.