summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-07-09 21:48:15 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-07-09 21:48:15 +0000
commit252a346cbf6ab008d766fc91992f7d3c1fddd3f1 (patch)
tree92d6337658bbc8e68bdbffe643d0dcfbaa74e4c4
parent7270c2d845845ccaf97d2a1fe3c45f2f4c530913 (diff)
downloadurpmi-252a346cbf6ab008d766fc91992f7d3c1fddd3f1.tar
urpmi-252a346cbf6ab008d766fc91992f7d3c1fddd3f1.tar.gz
urpmi-252a346cbf6ab008d766fc91992f7d3c1fddd3f1.tar.bz2
urpmi-252a346cbf6ab008d766fc91992f7d3c1fddd3f1.tar.xz
urpmi-252a346cbf6ab008d766fc91992f7d3c1fddd3f1.zip
move duplicated code into urpm::parallel::parse_urpmq_output()
-rw-r--r--urpm/parallel.pm29
-rw-r--r--urpm/parallel_ka_run.pm25
-rw-r--r--urpm/parallel_ssh.pm25
3 files changed, 31 insertions, 48 deletions
diff --git a/urpm/parallel.pm b/urpm/parallel.pm
index 3a6aa899..809a9391 100644
--- a/urpm/parallel.pm
+++ b/urpm/parallel.pm
@@ -129,6 +129,35 @@ sub parse_urpme_output {
return;
}
+sub parse_urpmq_output {
+ my ($urpm, $state, $node, $s, $cont, $chosen, %options) = @_;
+
+ if (my ($action, $what) = $s =~ /^\@([^\@]*)\@(.*)/) {
+ if ($action eq 'removing') {
+ $state->{rejected}{$what}{removed} = 1;
+ $state->{rejected}{$what}{nodes}{$node} = undef;
+ }
+ } elsif ($s =~ /\|/) {
+ #- distant urpmq returned a choices, check if it has already been chosen
+ #- or continue iteration to make sure no more choices are left.
+ $$cont ||= 1; #- invalid transitory state (still choices is strange here if next sentence is not executed).
+ unless (grep { exists $chosen->{$_} } split /\|/, $s) {
+ my $choice = $options{callback_choices}->($urpm, undef, $state, [ map { $urpm->search($_) } split /\|/, $s ]);
+ if ($choice) {
+ $chosen->{scalar $choice->fullname} = $choice;
+ #- it has not yet been chosen so need to ask user.
+ $$cont = 2;
+ } else {
+ #- no choices resolved, so forget it (no choices means no choices at all).
+ $$cont = 0;
+ }
+ }
+ } else {
+ my $pkg = $urpm->search($s) or return; #TODO
+ $state->{selected}{$pkg->id}{$node} = $s;
+ }
+}
+
#- compute command line of urpm? tools.
sub simple_resolve_dependencies {
my ($parallel, $urpm, $state, $requested, %options) = @_;
diff --git a/urpm/parallel_ka_run.pm b/urpm/parallel_ka_run.pm
index e8ae8b9c..93b1d959 100644
--- a/urpm/parallel_ka_run.pm
+++ b/urpm/parallel_ka_run.pm
@@ -117,30 +117,7 @@ sub parallel_resolve_dependencies {
while (<$fh>) {
chomp;
(my $node, $_) = _parse_rshp_output($_) or next;
- if (my ($action, $what) = /^\@([^\@]*)\@(.*)/) {
- if ($action eq 'removing') {
- $state->{rejected}{$what}{removed} = 1;
- $state->{rejected}{$what}{nodes}{$node} = undef;
- }
- } elsif (/\|/) {
- #- distant urpmq returned a choices, check if it has already been chosen
- #- or continue iteration to make sure no more choices are left.
- $cont ||= 1; #- invalid transitory state (still choices is strange here if next sentence is not executed).
- unless (grep { exists $chosen{$_} } split /\|/, $_) {
- my $choice = $options{callback_choices}->($urpm, undef, $state, [ map { $urpm->search($_) } split /\|/, $_ ]);
- if ($choice) {
- $chosen{scalar $choice->fullname} = $choice;
- #- it has not yet been chosen so need to ask user.
- $cont = 2;
- } else {
- #- no choices resolved, so forget it (no choices means no choices at all).
- $cont = 0;
- }
- }
- } else {
- my $pkg = $urpm->search($_) or next; #TODO
- $state->{selected}{$pkg->id}{$node} = $_;
- }
+ urpm::parallel::parse_urpmq_output($urpm, $state, $node, $_, \$cont, \%chosen, %options);
}
close $fh or $urpm->{fatal}(1, N("rshp failed, maybe a node is unreacheable"));
#- check for internal error of resolution.
diff --git a/urpm/parallel_ssh.pm b/urpm/parallel_ssh.pm
index b8ed7bbb..3275efcd 100644
--- a/urpm/parallel_ssh.pm
+++ b/urpm/parallel_ssh.pm
@@ -129,30 +129,7 @@ sub parallel_resolve_dependencies {
or $urpm->{fatal}(1, "Can't fork ssh: $!");
while (defined ($_ = <$fh>)) {
chomp;
- if (my ($action, $what) = /^\@([^\@]*)\@(.*)/) {
- if ($action eq 'removing') {
- $state->{rejected}{$what}{removed} = 1;
- $state->{rejected}{$what}{nodes}{$node} = undef;
- }
- } elsif (/\|/) {
- #- distant urpmq returned a choices, check if it has already been chosen
- #- or continue iteration to make sure no more choices are left.
- $cont ||= 1; #- invalid transitory state (still choices is strange here if next sentence is not executed).
- unless (grep { exists $chosen{$_} } split /\|/, $_) {
- my $choice = $options{callback_choices}->($urpm, undef, $state, [ map { $urpm->search($_) } split /\|/, $_ ]);
- if ($choice) {
- $chosen{scalar $choice->fullname} = $choice;
- #- it has not yet been chosen so need to ask user.
- $cont = 2;
- } else {
- #- no choices resolved, so forget it (no choices means no choices at all).
- $cont = 0;
- }
- }
- } else {
- my $pkg = $urpm->search($_) or next; #TODO
- $state->{selected}{$pkg->id}{$node} = $_;
- }
+ urpm::parallel::parse_urpmq_output($urpm, $state, $node, $_, \$cont, \%chosen, %options);
}
close $fh or $urpm->{fatal}(1, N("host %s does not have a good version of urpmi (%d)", $node, $? >> 8));
}