summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rwxr-xr-xgurpmi216
-rw-r--r--urpm.pm4
-rwxr-xr-xurpmi12
4 files changed, 35 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index cf6602b5..04affc24 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
- urpmi:
o downgrade from rpm-4.9 to 4.8 db when installing mga1 in a chroot from
mga2+ (mga#4590)
+ o fix urpmi failing silently and with exit status 0 when package
+ installation fails due to either conflicts (mdv#63072) or to
+ unselecting package (mdv#63940)
o kill unused DUDF support (mga#4493)
o return the proper error code in some cases when failing to install some
packages
diff --git a/gurpmi2 b/gurpmi2
index 754f2e8f..d1989753 100755
--- a/gurpmi2
+++ b/gurpmi2
@@ -106,6 +106,15 @@ my $restart_itself = urpm::select::resolve_dependencies($urpm,
priority_upgrade => $urpm->{options}{'priority-upgrade'},
);
my @ask_unselect = urpm::select::unselected_packages($urpm, $state);
+
+# If there are some unselected packages, designate that we are going to return nonzero code.
+if (@ask_unselect) {
+ my $unselect_msg = N("Some requested packages cannot be installed:\n%s",
+ urpm::select::translate_why_unselected($urpm, $state, @ask_unselect));
+ $urpm::postponed_msg .= $unselect_msg . "\n";
+ $urpm::postponed_code = 17;
+}
+
@ask_unselect
? ask_continue(N(
"Some requested packages cannot be installed:\n%s\nContinue installation anyway?",
@@ -410,6 +419,9 @@ sub do_install_3 () {
}
);
+ # Merge postponed exit code to the result of package installation.
+ $exit_code ||= $urpm::postponed_code;
+
#- restart gurpmi if needed, keep command line for that.
if ($restart_itself && !$exit_code) {
print N("restarting urpmi"), "\n";
@@ -420,6 +432,10 @@ sub do_install_3 () {
grep { !/^--no-priority-upgrade$|--previous-priority-upgrade=/ } @ARGV);
exec $0, @ARGV;
}
+
+ # Show postponed message before exiting
+ $urpm->{error}->($urpm::postponed_msg) if $urpm::postponed_code != 0;
+
exit $exit_code;
}
diff --git a/urpm.pm b/urpm.pm
index eee09652..65e11e80 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -19,6 +19,10 @@ our $VERSION = '6.44';
our @ISA = qw(URPM Exporter);
our @EXPORT_OK = ('file_from_local_url', 'file_from_local_medium', 'is_local_medium');
+# Prepare exit code. If you change this, the exiting with a failure and the message given will be postponed to the end of the overall processing.
+our $postponed_msg = N("While some packages may have been installed, there were failures.\n");
+our $postponed_code = 0;
+
use URPM;
use URPM::Resolve;
diff --git a/urpmi b/urpmi
index 8fb1086a..bd1520b2 100755
--- a/urpmi
+++ b/urpmi
@@ -496,6 +496,9 @@ that are older than the installed ones:\n%s", $list);
$msg .= N("\nContinue installation anyway?");
$force || message_input_($msg . N(" (Y/n) "), boolean => 1) !~ /[$noexpr]/ or exit 17;
}
+ # Whatever option we selected, the overall installation should fail if some packages are unselected
+ $urpm::postponed_msg .= $msg . "\n";
+ $urpm::postponed_code = 17;
}
my @ask_unselect = urpm::select::unselected_packages($urpm, $state);
@@ -511,6 +514,9 @@ if (@ask_unselect) {
$msg .= N("\nContinue installation anyway?");
$force || message_input_($msg . N(" (Y/n) "), boolean => 1) !~ /[$noexpr]/ or exit 17;
}
+ # Whatever option we selected, the overall installation should fail if some packages are unselected
+ $urpm::postponed_msg .= $msg . "\n";
+ $urpm::postponed_code = 17;
}
if (my @conflicting_pkgs_msgs =
@@ -681,6 +687,9 @@ unless ($env) {
urpm::removable::try_umounting_removables($urpm);
}
+# Merge postponed exit code to the result of package installation.
+$exit_code ||= $urpm::postponed_code;
+
#- restart urpmi if needed, keep command line for that.
if ($restart_itself && !$exit_code) {
print N("restarting urpmi"), "\n";
@@ -707,4 +716,7 @@ if ($pid_err || $pid_out) {
close STDOUT;
}
+# Show postponed message before exiting
+print $urpm::postponed_msg if $urpm::postponed_code != 0;
+
exit($exit_code);