summaryrefslogtreecommitdiffstats
path: root/urpm/main_loop.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-06-08 18:51:49 +0000
committerThierry Vignaud <tv@mageia.org>2012-06-08 18:51:49 +0000
commitf96d429cacf8ba76cb733b1e1d9e84ec70a44cf6 (patch)
tree269e2e76f6e4d21afcefa98a6dca2334d458999a /urpm/main_loop.pm
parentcbe40c51e61163d3e73dd2832fd7ea62beba60db (diff)
downloadurpmi-f96d429cacf8ba76cb733b1e1d9e84ec70a44cf6.tar
urpmi-f96d429cacf8ba76cb733b1e1d9e84ec70a44cf6.tar.gz
urpmi-f96d429cacf8ba76cb733b1e1d9e84ec70a44cf6.tar.bz2
urpmi-f96d429cacf8ba76cb733b1e1d9e84ec70a44cf6.tar.xz
urpmi-f96d429cacf8ba76cb733b1e1d9e84ec70a44cf6.zip
(_run_transaction) split it out of run()
Diffstat (limited to 'urpm/main_loop.pm')
-rw-r--r--urpm/main_loop.pm101
1 files changed, 57 insertions, 44 deletions
diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm
index f63e9d99..09f6644e 100644
--- a/urpm/main_loop.pm
+++ b/urpm/main_loop.pm
@@ -226,6 +226,61 @@ sub _run_parallel_transaction {
);
}
+sub _run_transaction {
+ my ($urpm, $state, $callbacks, $set, $transaction_sources_install, $transaction_sources, $errors) = @_;
+
+ my $to_remove = $urpm->{options}{'allow-force'} ? [] : $set->{remove} || [];
+
+ $urpm->{log}("starting installing packages");
+
+ urpm::orphans::add_unrequested($urpm, $state) if !$test;
+
+ my %install_options_common = _init_common_options($urpm, $state, $callbacks);
+
+ install:
+ my @l = urpm::install::install($urpm,
+ $to_remove,
+ $transaction_sources_install, $transaction_sources,
+ %install_options_common,
+ );
+
+ if (!@l) {
+ ++$ok;
+ return 1;
+ }
+
+ my ($raw_error, $translated) = partition { /^(badarch|bados|installed|badrelocate|conflicts|installed|diskspace|disknodes|requires|conflicts|unknown)\@/ } @l;
+ @l = @$translated;
+ my $fatal = find { /^disk/ } @$raw_error;
+ my $no_question = $fatal || $urpm->{options}{auto};
+
+ #- Warning : the following message is parsed in urpm::parallel_*
+ my $msg = N("Installation failed:") . "\n" . join("\n", map { "\t$_" } @l) . "\n";
+ if (!$no_question && !$install_options_common{nodeps} && ($urpm->{options}{'allow-nodeps'} || $urpm->{options}{'allow-force'})) {
+ if ($callbacks->{ask_yes_or_no}->(N("Installation failed"),
+ $msg . N("Try installation without checking dependencies?"))) {
+ $urpm->{log}("starting installing packages without deps");
+ $install_options_common{nodeps} = 1;
+ # try again:
+ goto install;
+ }
+ } elsif (!$no_question && !$install_options_common{force} && $urpm->{options}{'allow-force'}) {
+ if ($callbacks->{ask_yes_or_no}->(N("Installation failed"),
+ $msg . N("Try harder to install (--force)?"))) {
+ $urpm->{log}("starting force installing packages without deps");
+ $install_options_common{force} = 1;
+ # try again:
+ goto install;
+ }
+ }
+ $urpm->{log}($msg);
+
+ ++$nok;
+ push @$errors, @l;
+
+ !$fatal;
+}
+
# locking is left to callers
sub run {
my ($urpm, $state, $something_was_to_be_done, $ask_unselect, $_requested, $callbacks) = @_;
@@ -327,52 +382,10 @@ sub run {
if ($options{verbose} >= 0) {
_log_installing($urpm, \%transaction_sources_install, $transaction_sources);
}
- my $to_remove = $urpm->{options}{'allow-force'} ? [] : $set->{remove} || [];
bug_log(scalar localtime(), " ", join(' ', values %transaction_sources_install, values %$transaction_sources), "\n");
- $urpm->{log}("starting installing packages");
- my %install_options_common = _init_common_options($urpm, $state, $callbacks);
-
- urpm::orphans::add_unrequested($urpm, $state) if !$test;
-
- install:
- my @l = urpm::install::install($urpm,
- $to_remove,
- \%transaction_sources_install, $transaction_sources,
- %install_options_common,
- );
- if (@l) {
- my ($raw_error, $translated) = partition { /^(badarch|bados|installed|badrelocate|conflicts|installed|diskspace|disknodes|requires|conflicts|unknown)\@/ } @l;
- @l = @$translated;
- my $fatal = find { /^disk/ } @$raw_error;
- my $no_question = $fatal || $urpm->{options}{auto};
-
- #- Warning : the following message is parsed in urpm::parallel_*
- my $msg = N("Installation failed:") . "\n" . join("\n", map { "\t$_" } @l) . "\n";
- if (!$no_question && !$install_options_common{nodeps} && ($urpm->{options}{'allow-nodeps'} || $urpm->{options}{'allow-force'})) {
- if ($callbacks->{ask_yes_or_no}->(N("Installation failed"),
- $msg . N("Try installation without checking dependencies?"))) {
- $urpm->{log}("starting installing packages without deps");
- $install_options_common{nodeps} = 1;
- # try again:
- goto install;
- }
- } elsif (!$no_question && !$install_options_common{force} && $urpm->{options}{'allow-force'}) {
- if ($callbacks->{ask_yes_or_no}->(N("Installation failed"),
- $msg . N("Try harder to install (--force)?"))) {
- $urpm->{log}("starting force installing packages without deps");
- $install_options_common{force} = 1;
- # try again:
- goto install;
- }
- }
- $urpm->{log}($msg);
- ++$nok;
- push @errors, @l;
- $fatal and last;
- } else {
- ++$ok;
- }
+ _run_transaction($urpm, $state, $callbacks, $set, \%transaction_sources_install, $transaction_sources, \@errors)
+ or last;
}
}
if ($callbacks->{is_canceled}) {