summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-07-09 19:03:10 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-07-09 19:03:10 +0000
commit568e51a65c52ddebe015cec9462a44f7cf5011df (patch)
treef5bfbb787fa3f0a2bc1cb4f51a1b961c818024d6
parente60d47449744866c1cc78079b8048dbc482d9b08 (diff)
downloadurpmi-568e51a65c52ddebe015cec9462a44f7cf5011df.tar
urpmi-568e51a65c52ddebe015cec9462a44f7cf5011df.tar.gz
urpmi-568e51a65c52ddebe015cec9462a44f7cf5011df.tar.bz2
urpmi-568e51a65c52ddebe015cec9462a44f7cf5011df.tar.xz
urpmi-568e51a65c52ddebe015cec9462a44f7cf5011df.zip
factorize code into urpm::parallel::find_remove_pre()
-rw-r--r--urpm/parallel.pm19
-rw-r--r--urpm/parallel_ka_run.pm18
-rw-r--r--urpm/parallel_ssh.pm16
3 files changed, 26 insertions, 27 deletions
diff --git a/urpm/parallel.pm b/urpm/parallel.pm
index 441da68a..e881c09c 100644
--- a/urpm/parallel.pm
+++ b/urpm/parallel.pm
@@ -76,4 +76,23 @@ sub post_register_rpms {
map { "$urpm->{cachedir}/rpms/" . basename($_) } @files);
}
+sub find_remove_pre {
+ my ($urpm, $state, %options) = @_;
+
+ #- keep in mind if the previous selection is still active, it avoids
+ #- to re-start urpme --test on each node.
+ if ($options{find_packages_to_remove}) {
+ delete $state->{rejected};
+ delete $urpm->{error_remove};
+ '--test ';
+ } elsif (@{$urpm->{error_remove} || []}) {
+ undef, $urpm->{error_remove};
+ } elsif ($options{test}) {
+ #- no need to restart what has been started before.
+ undef, [ keys %{$state->{rejected}} ];
+ } else {
+ '--force ';
+ }
+}
+
1;
diff --git a/urpm/parallel_ka_run.pm b/urpm/parallel_ka_run.pm
index d351e90a..ba00e05c 100644
--- a/urpm/parallel_ka_run.pm
+++ b/urpm/parallel_ka_run.pm
@@ -39,20 +39,10 @@ sub parallel_register_rpms {
#- parallel find_packages_to_remove
sub parallel_find_remove {
my ($parallel, $urpm, $state, $l, %options) = @_;
- my ($test, $node, %bad_nodes, %base_to_remove, %notfound);
-
- #- keep in mind if the previous selection is still active, it avoids
- #- to re-start urpme --test on each node.
- if ($options{find_packages_to_remove}) {
- delete $state->{rejected};
- delete $urpm->{error_remove};
- $test = '--test ';
- } else {
- @{$urpm->{error_remove} || []} and return @{$urpm->{error_remove}};
- #- no need to restart what has been started before.
- $options{test} and return keys %{$state->{rejected}};
- $test = '--force ';
- }
+ my ($node, %bad_nodes, %base_to_remove, %notfound);
+
+ my ($test, $pkgs) = urpm::parallel::find_remove_pre($urpm, $state, %options);
+ $pkgs and return @$pkgs;
#- now try an iteration of urpme.
$urpm->{log}("parallel_ka_run: $rshp_command -v $parallel->{options} -- urpme --no-locales --auto $test" . (join ' ', map { "'$_'" } @$l));
diff --git a/urpm/parallel_ssh.pm b/urpm/parallel_ssh.pm
index 35b6e79a..d43c2fb8 100644
--- a/urpm/parallel_ssh.pm
+++ b/urpm/parallel_ssh.pm
@@ -41,20 +41,10 @@ sub parallel_register_rpms {
#- parallel find_packages_to_remove
sub parallel_find_remove {
my ($parallel, $urpm, $state, $l, %options) = @_;
- my ($test, %bad_nodes, %base_to_remove, %notfound);
+ my (%bad_nodes, %base_to_remove, %notfound);
- #- keep in mind if the previous selection is still active, it avoids
- #- to re-start urpme --test on each node.
- if ($options{find_packages_to_remove}) {
- delete $state->{rejected};
- delete $urpm->{error_remove};
- $test = '--test ';
- } else {
- @{$urpm->{error_remove} || []} and return @{$urpm->{error_remove}};
- #- no need to restart what has been started before.
- $options{test} and return keys %{$state->{rejected}};
- $test = '--force ';
- }
+ my ($test, $pkgs) = urpm::parallel::find_remove_pre($urpm, $state, %options);
+ $pkgs and return @$pkgs;
#- now try an iteration of urpme.
foreach my $node (keys %{$parallel->{nodes}}) {