summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm')
-rw-r--r--urpm/parallel_ka_run.pm70
-rw-r--r--urpm/parallel_ssh.pm71
2 files changed, 133 insertions, 8 deletions
diff --git a/urpm/parallel_ka_run.pm b/urpm/parallel_ka_run.pm
index 93d90e9d..9aa74497 100644
--- a/urpm/parallel_ka_run.pm
+++ b/urpm/parallel_ka_run.pm
@@ -15,6 +15,71 @@ 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);
+ local (*F, $_);
+
+ #- keep in mind if the previous selection is still active, it avoid
+ #- to re-start urpme --test on each node.
+ if ($options{find_packages_to_remove}) {
+ delete $state->{ask_remove};
+ 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->{ask_remove}};
+ $test = '';
+ }
+
+ #- now try an iteration of urpmq.
+ $urpm->{log}("parallel_ka_run: rshp -v $parallel->{options} -- urpme --no-locales --auto $test".(join ' ', map { "'$_'" } @$l));
+ open F, "rshp -v $parallel->{options} -- urpme --no-locales --auto $test".join(' ', map { "'$_'" } @$l)." |";
+ while (defined ($_ = <F>)) {
+ chomp;
+ s/<([^>]*)>.*:->:(.*)/$2/ and $node = $1;
+ /^\s*$/ and next;
+ /Checking to remove the following packages/ and next;
+ /To satisfy dependencies, the following packages are going to be removed/
+ and $urpm->{fatal}(1, ("node %s has bad version of urpme, please upgrade", $node));
+ if (/unknown packages?:? (.*)/) {
+ $options{callback_notfound} and $options{callback_notfound}->($urpm, split ", ", $1)
+ or delete $state->{ask_remove}, last;
+ } elsif (/The following packages contain ([^:]*): (.*)/) {
+ $options{callback_fuzzy} and $options{callback_fuzzy}->($urpm, $1, split " ", $2)
+ or delete $state->{ask_remove}, last;
+ } elsif (/removing package (.*) will break your system/) {
+ $base_to_remove{$1} = undef;
+ } elsif (/Removing failed/) {
+ $bad_nodes{$node} = [];
+ } else {
+ if (exists $bad_nodes{$node}) {
+ /^\s+(.*)/ and push @{$bad_nodes{$node}}, $1;
+ } else {
+ $state->{ask_remove}{$_}{$node} = undef;
+ }
+ }
+ }
+ close F or $urpm->{fatal}(1, _("rshp failed, maybe a node is unreacheable"));
+
+ #- check base, which has been delayed until there.
+ $options{callback_base} and %base_to_remove and $options{callback_base}->($urpm, keys %base_to_remove)
+ || return ();
+
+ #- build error list contains all the error returned by each node.
+ $urpm->{error_remove} = [];
+ foreach (keys %bad_nodes) {
+ my $msg = _("on node %s", $_);
+ foreach (@{$bad_nodes{$_}}) {
+ push @{$urpm->{error_remove}}, "$msg, $_";
+ }
+ }
+
+ keys %{$state->{ask_remove}};
+}
+
#- parallel resolve_dependencies
sub parallel_resolve_dependencies {
my ($parallel, $synthesis, $urpm, $state, $requested, %options) = @_;
@@ -91,7 +156,7 @@ sub parallel_resolve_dependencies {
}
}
} else {
- my $pkg = $urpm->search($_) or next; #TODO
+ my $pkg = $urpm->search($_) or next;
$state->{selected}{$pkg->id}{$node} = $_;
}
}
@@ -102,9 +167,6 @@ sub parallel_resolve_dependencies {
#- keep trace of what has been chosen finally (if any).
$parallel->{line} = "$line ".join(' ', keys %chosen);
-
- #- update ask_remove, ask_unselect too along with provided value.
- #TODO
}
#- parallel install.
diff --git a/urpm/parallel_ssh.pm b/urpm/parallel_ssh.pm
index 4d66b372..f5c29405 100644
--- a/urpm/parallel_ssh.pm
+++ b/urpm/parallel_ssh.pm
@@ -18,6 +18,72 @@ 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);
+ local (*F, $_);
+
+ #- keep in mind if the previous selection is still active, it avoid
+ #- to re-start urpme --test on each node.
+ if ($options{find_packages_to_remove}) {
+ delete $state->{ask_remove};
+ 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->{ask_remove}};
+ $test = '';
+ }
+
+ #- now try an iteration of urpme.
+ foreach my $node (keys %{$parallel->{nodes}}) {
+ $urpm->{log}("parallel_ssh: ssh $node urpme --no-locales --auto $test".(join ' ', map { "'$_'" } @$l));
+ open F, "ssh 2>&1 $node urpme --no-locales --auto $test".(join ' ', map { "'$_'" } @$l)." |";
+ while (defined ($_ = <F>)) {
+ chomp;
+ /^\s*$/ and next;
+ /Checking to remove the following packages/ and next;
+ /To satisfy dependencies, the following packages are going to be removed/
+ and $urpm->{fatal}(1, ("node %s has bad version of urpme, please upgrade", $node));
+ if (/unknown packages?:? (.*)/) {
+ $options{callback_notfound} and $options{callback_notfound}->($urpm, split ", ", $1)
+ or delete $state->{ask_remove}, last;
+ } elsif (/The following packages contain ([^:]*): (.*)/) {
+ $options{callback_fuzzy} and $options{callback_fuzzy}->($urpm, $1, split " ", $2)
+ or delete $state->{ask_remove}, last;
+ } elsif (/removing package (.*) will break your system/) {
+ $base_to_remove{$1} = undef;
+ } elsif (/Removing failed/) {
+ $bad_nodes{$node} = [];
+ } else {
+ if (exists $bad_nodes{$node}) {
+ /^\s+(.*)/ and push @{$bad_nodes{$node}}, $1;
+ } else {
+ $state->{ask_remove}{$_}{$node} = undef;
+ }
+ }
+ }
+ close F;
+ }
+
+ #- check base, which has been delayed until there.
+ $options{callback_base} and %base_to_remove and $options{callback_base}->($urpm, keys %base_to_remove)
+ || return ();
+
+ #- build error list contains all the error returned by each node.
+ $urpm->{error_remove} = [];
+ foreach (keys %bad_nodes) {
+ my $msg = _("on node %s", $_);
+ foreach (@{$bad_nodes{$_}}) {
+ push @{$urpm->{error_remove}}, "$msg, $_";
+ }
+ }
+
+ keys %{$state->{ask_remove}};
+}
+
#- parallel resolve_dependencies
sub parallel_resolve_dependencies {
my ($parallel, $synthesis, $urpm, $state, $requested, %options) = @_;
@@ -74,7 +140,7 @@ sub parallel_resolve_dependencies {
foreach my $node (keys %{$parallel->{nodes}}) {
$urpm->{log}("parallel_ssh: ssh $node urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen));
open F, "ssh $node urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen)." |";
- while ($_ = <F>) {
+ while (defined ($_ = <F>)) {
chomp;
if (/^\@removing\@(.*)/) {
$state->{ask_remove}{$1}{$node} = undef;
@@ -106,9 +172,6 @@ sub parallel_resolve_dependencies {
#- keep trace of what has been chosen finally (if any).
$parallel->{line} .= "$line ".join(' ', keys %chosen);
-
- #- update ask_remove, ask_unselect too along with provided value.
- #TODO
}
#- parallel install.