summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-09-10 16:19:03 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-09-10 16:19:03 +0000
commitcab13c537afddd8915df0c90735c3a7b65fb22d2 (patch)
tree67d5cc3e17e0bb7492538fc5641234ab476d6853
parentf9a92cd5222952f32dec99d5f63086eecfb2cd1b (diff)
downloadurpmi-cab13c537afddd8915df0c90735c3a7b65fb22d2.tar
urpmi-cab13c537afddd8915df0c90735c3a7b65fb22d2.tar.gz
urpmi-cab13c537afddd8915df0c90735c3a7b65fb22d2.tar.bz2
urpmi-cab13c537afddd8915df0c90735c3a7b65fb22d2.tar.xz
urpmi-cab13c537afddd8915df0c90735c3a7b65fb22d2.zip
- urpmi, urpme
o do not prompt questions if not waiting for user answer (for urpmi --force or urpme --force) create message_input_() which deprecated message_input(), $o_default_input is dumb IMO
-rw-r--r--NEWS4
-rw-r--r--urpm/msg.pm14
-rw-r--r--urpme2
-rwxr-xr-xurpmi28
-rwxr-xr-xurpmi.addmedia3
5 files changed, 27 insertions, 24 deletions
diff --git a/NEWS b/NEWS
index 4b27f2a0..e8a5d767 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+- urpmi, urpme
+ o do not prompt questions if not waiting for user answer
+ (for urpmi --force or urpme --force)
+
Version 4.10.8 - 10 September 2007, by Pascal "Pixel" Rigaux
- urpmi
diff --git a/urpm/msg.pm b/urpm/msg.pm
index 31719dbc..daa1c55e 100644
--- a/urpm/msg.pm
+++ b/urpm/msg.pm
@@ -15,7 +15,7 @@ BEGIN {
(our $VERSION) = q($Revision$) =~ /(\d+)/;
our @ISA = 'Exporter';
-our @EXPORT = qw(N P translate bug_log message_input toMb formatXiB sys_log);
+our @EXPORT = qw(N P translate bug_log message_input message_input_ toMb formatXiB sys_log);
#- I18N.
use Locale::gettext;
@@ -88,17 +88,25 @@ sub bug_log {
}
}
-sub message_input {
+#- deprecated, use message_input_() instead
+sub message_input { &_message_input }
+
+sub message_input_ {
+ my ($msg, %o_opts) = @_;
+ _message_input($msg, undef, %o_opts);
+}
+sub _message_input {
my ($msg, $o_default_input, %o_opts) = @_;
my $input;
while (1) {
print $msg;
if ($o_default_input) {
+ #- deprecated argument. don't you want to use $o_opts{default} instead?
$urpm::args::options{bug} and bug_log($o_default_input);
return $o_default_input;
}
$input = <STDIN>;
- defined $input or return undef;
+ defined $input or return $o_opts{default};
chomp $input;
$urpm::args::options{bug} and bug_log($input);
if ($o_opts{boolean}) {
diff --git a/urpme b/urpme
index 95214b0e..da13149d 100644
--- a/urpme
+++ b/urpme
@@ -128,7 +128,7 @@ if ($test && $auto) {
"To satisfy dependencies, the following %d packages will be removed",
scalar(@toremove), scalar(@toremove)) . sprintf(" (%s)", formatXiB(-$urpm->selected_size($state)));
print STDOUT "$msg:\n$list\n";
- message_input(P("Remove %d package?", "Remove %d packages?", scalar(@toremove), scalar(@toremove)) . N(" (y/N) "), $force && $yesexpr, boolean => 1) =~ /[$yesexpr]/ or exit 0;
+ $force || message_input_(P("Remove %d package?", "Remove %d packages?", scalar(@toremove), scalar(@toremove)) . N(" (y/N) "), boolean => 1) =~ /[$yesexpr]/ or exit 0;
}
#- Warning : the following message is parsed in urpm::parallel_*
diff --git a/urpmi b/urpmi
index 52a321bd..2b053f11 100755
--- a/urpmi
+++ b/urpmi
@@ -452,7 +452,7 @@ sub ask_choice {
print N("In order to satisfy the '%s' dependency, one of the following packages is needed:", $virtual_pkg_name), "\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);
+ $n = message_input_(N("What is your choice? (1-%d) ", $i), range_min => 0, range => $i);
defined($n) && $n ne "0" or exit 1; # abort.
if ($n =~ /\D/) {
my @nn = map { $choices[$_ - 1] } grep { !/\D/ } split /[, \t]+/, $n;
@@ -502,12 +502,8 @@ that are older than the installed ones:\n%s", $list);
} else {
my $noexpr = N("Nn");
my $yesexpr = N("Yy");
- message_input(
- $msg . N("\nContinue installation anyway?") . N(" (Y/n) "),
- $force && $yesexpr,
- boolean => 1,
- ) =~ /[$noexpr]/
- and exit 0;
+ $msg .= N("\nContinue installation anyway?");
+ $force || message_input_($msg . N(" (Y/n) "), boolean => 1) !~ /[$noexpr]/ or exit 0;
}
}
@@ -522,12 +518,8 @@ if (@ask_unselect) {
} else {
my $noexpr = N("Nn");
my $yesexpr = N("Yy");
- message_input(
- $msg . N("\nContinue installation anyway?") . N(" (Y/n) "),
- $force && $yesexpr,
- boolean => 1,
- ) =~ /[$noexpr]/
- and exit 0;
+ $msg .= N("\nContinue installation anyway?");
+ $force || message_input_($msg . N(" (Y/n) "), boolean => 1) !~ /[$noexpr]/ or exit 0;
}
}
@@ -565,7 +557,7 @@ have to be removed for others to be upgraded:\n%s\n", $list);
print "$msg\n";
} else {
my $yesexpr = N("Yy");
- message_input($msg . N(" (y/N) "), $force && $yesexpr, boolean => 1) =~ /[$yesexpr]/ or exit 0;
+ $force || message_input_($msg . N(" (y/N) "), boolean => 1) =~ /[$yesexpr]/ or exit 0;
}
}
@@ -611,7 +603,7 @@ if (!$urpm->{options}{auto} && $ask_user && $urpm->{nb_install} || $env) {
}
my $noexpr = N("Nn");
my $yesexpr = N("Yy");
- message_input($p . N(" (Y/n) "), $force && $yesexpr, boolean => 1) =~ /[$noexpr]/ and exit 0;
+ $force || message_input_($p . N(" (Y/n) "), boolean => 1) !~ /[$noexpr]/ or exit 0;
}
my $exit_code = urpm::main_loop::run($urpm, $state,
@@ -627,7 +619,7 @@ my $exit_code = urpm::main_loop::run($urpm, $state,
return system($gmessage, '-buttons', N("Ok") . ':1,' . N("Cancel") . ':0', "\n$msg\n");
}
}
- return defined message_input("$msg\n$msg2 ");
+ return defined message_input_("$msg\n$msg2 ");
}) : ()),
trans_log => sub {
# my ($mode, $file, $percent, $total, $eta, $speed) = @_;
@@ -641,13 +633,13 @@ my $exit_code = urpm::main_loop::run($urpm, $state,
exit 1;
} else {
my $yesexpr = N("Yy");
- message_input("$msg$msg2" . N(" (y/N) "), $force && $yesexpr, boolean => 1) =~ /[$yesexpr]/ or exit 1;
+ $force || message_input_("$msg$msg2" . N(" (y/N) "), boolean => 1) =~ /[$yesexpr]/ or exit 1;
}
},
ask_yes_or_no => sub {
my ($_title, $msg) = @_; # graphical title
my $yesexpr = N("Yy");
- message_input($msg, $force && $yesexpr, boolean => 1) =~ /[$yesexpr]/;
+ $force || message_input_($msg, boolean => 1) =~ /[$yesexpr]/;
},
});
diff --git a/urpmi.addmedia b/urpmi.addmedia
index 3a1f6ed1..acbd852a 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -127,9 +127,8 @@ if ($options{distrib}) {
my ($medianame, $add_by_default) = @_;
my $yesexpr = N("Yy");
$add_by_default = 1 if $options{allmedia};
- my $answer = message_input(
+ my $answer = message_input_(
N("\nDo you want to add media '%s'", $medianame) . ($add_by_default ? N(" (Y/n) ") : N(" (y/N) ")),
- undef,
boolean => 1,
);
return $answer ? $answer =~ /[$yesexpr]/ : $add_by_default;