summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-07-09 19:37:25 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-07-09 19:37:25 +0000
commit38455df4720675f5d9f8e5eee9efe541c46dac10 (patch)
tree616eeddf6f395f31f1b90c70e3940ee8577c21e0
parent082cb5c1735dbab0f967ed611f28434a8fe94c3a (diff)
downloadurpmi-38455df4720675f5d9f8e5eee9efe541c46dac10.tar
urpmi-38455df4720675f5d9f8e5eee9efe541c46dac10.tar.gz
urpmi-38455df4720675f5d9f8e5eee9efe541c46dac10.tar.bz2
urpmi-38455df4720675f5d9f8e5eee9efe541c46dac10.tar.xz
urpmi-38455df4720675f5d9f8e5eee9efe541c46dac10.zip
factorize urpme output parsing
-rw-r--r--urpm/parallel.pm34
-rw-r--r--urpm/parallel_ka_run.pm34
-rw-r--r--urpm/parallel_ssh.pm30
3 files changed, 42 insertions, 56 deletions
diff --git a/urpm/parallel.pm b/urpm/parallel.pm
index e881c09c..124b6491 100644
--- a/urpm/parallel.pm
+++ b/urpm/parallel.pm
@@ -95,4 +95,38 @@ sub find_remove_pre {
}
}
+sub parse_urpme_output {
+ my ($urpm, $state, $node, $s, $notfound, $base_to_remove, $bad_nodes, %options) = @_;
+
+ $s =~ /^\s*$/ and return;
+ $s =~ /Checking to remove the following packages/ and return;
+
+ $s =~ /To satisfy dependencies, the following packages are going to be removed/
+ and $urpm->{fatal}(1, N("node %s has an old version of urpme, please upgrade", $node));
+
+ if ($s =~ /unknown packages?:? (.*)/) {
+ #- remember unknown packages from the node, because it should not be a fatal error
+ #- if other nodes have it.
+ $notfound->{$_} = undef foreach split ", ", $1;
+ } elsif ($s =~ /The following packages contain ([^:]*): (.*)/) {
+ $options{callback_fuzzy} && $options{callback_fuzzy}->($urpm, $1, split(" ", $2))
+ or delete($state->{rejected}), return 'stop_parse';
+ } elsif ($s =~ /removing package (.*) will break your system/) {
+ $base_to_remove->{$1} = undef;
+ } elsif ($s =~ /removing \S/) {
+ #- this is log for newer urpme, so do not try to remove removing...
+ } elsif ($s =~ /Remov(?:al|ing) failed/) {
+ $bad_nodes->{$node} = [];
+ } else {
+ if (exists $bad_nodes->{$node}) {
+ $s =~ /^\s+(.+)/ and push @{$bad_nodes->{$node}}, $1;
+ } else {
+ $s =~ s/\s*\(.*//; #- remove reason (too complex to handle, needs to be removed)
+ $state->{rejected}{$s}{removed} = 1;
+ $state->{rejected}{$s}{nodes}{$node} = undef;
+ }
+ }
+ return;
+}
+
1;
diff --git a/urpm/parallel_ka_run.pm b/urpm/parallel_ka_run.pm
index e88e3a1b..543f197e 100644
--- a/urpm/parallel_ka_run.pm
+++ b/urpm/parallel_ka_run.pm
@@ -44,41 +44,17 @@ sub parallel_find_remove {
$pkgs and return @$pkgs;
my (%bad_nodes, %base_to_remove, %notfound);
- my $node;
#- now try an iteration of urpme.
$urpm->{log}("parallel_ka_run: $rshp_command -v $parallel->{options} -- urpme --no-locales --auto $test" . (join ' ', map { "'$_'" } @$l));
open my $fh, "$rshp_command -v $parallel->{options} -- urpme --no-locales --auto $test" . join(' ', map { "'$_'" } @$l) . " 2>&1 |";
local $_;
while (<$fh>) {
- chomp;
- ($node, $_) = _parse_rshp_output($_) or next;
- /^\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, N("node %s has an old version of urpme, please upgrade", $node));
- if (/unknown packages?:? (.*)/) {
- #- remember unknown packages from the node, because it should not be a fatal error
- #- if other nodes have it.
- @notfound{split ", ", $1} = ();
- } elsif (/The following packages contain ([^:]*): (.*)/) {
- $options{callback_fuzzy} && $options{callback_fuzzy}->($urpm, $1, split(" ", $2))
- or delete $state->{rejected}, last;
- } elsif (/removing package (.*) will break your system/) {
- $base_to_remove{$1} = undef;
- } elsif (/removing \S/) {
- #- this is log for newer urpme, so do not try to remove removing...
- } elsif (/Remov(?:al|ing) failed/) {
- $bad_nodes{$node} = [];
- } else {
- if (exists $bad_nodes{$node}) {
- /^\s+(.+)/ and push @{$bad_nodes{$node}}, $1;
- } else {
- s/\s*\(.*//; #- remove reason (too complex to handle, needs to be removed)
- $state->{rejected}{$_}{removed} = 1;
- $state->{rejected}{$_}{nodes}{$node} = undef;
- }
- }
+ my ($node, $s) = _parse_rshp_output($_) or next;
+
+ urpm::parallel::parse_urpme_output($urpm, $state, $node, $s,
+ \%notfound, \%base_to_remove, \%bad_nodes, %options)
+ or last;
}
close $fh or $urpm->{fatal}(1, N("rshp failed, maybe a node is unreacheable"));
diff --git a/urpm/parallel_ssh.pm b/urpm/parallel_ssh.pm
index a21c3f32..453a4cfe 100644
--- a/urpm/parallel_ssh.pm
+++ b/urpm/parallel_ssh.pm
@@ -55,33 +55,9 @@ sub parallel_find_remove {
or $urpm->{fatal}(1, "Can't fork ssh: $!");
local $_;
while (defined ($_ = <$fh>)) {
- 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, N("node %s has an old version of urpme, please upgrade", $node));
- if (/unknown packages?:? (.*)/) {
- #- remember unknown packages from the node, because it should not be a fatal error
- #- if other nodes have it.
- @notfound{split ", ", $1} = ();
- } elsif (/The following packages contain ([^:]*): (.*)/) {
- $options{callback_fuzzy} && $options{callback_fuzzy}->($urpm, $1, split(" ", $2))
- or delete $state->{rejected}, last;
- } elsif (/removing package (.*) will break your system/) {
- $base_to_remove{$1} = undef;
- } elsif (/removing \S/) {
- #- this is log for newer urpme, so do not try to remove removing...
- } elsif (/Remov(?:al|ing) failed/) {
- $bad_nodes{$node} = [];
- } else {
- if (exists $bad_nodes{$node}) {
- /^\s+(.+)/ and push @{$bad_nodes{$node}}, $1;
- } else {
- s/\s*\(.*//; #- remove reason (too complex to handle, needs to be removed)
- $state->{rejected}{$_}{removed} = 1;
- $state->{rejected}{$_}{nodes}{$node} = undef;
- }
- }
+ urpm::parallel::parse_urpme_output($urpm, $state, $node, $_,
+ \%notfound, \%base_to_remove, \%bad_nodes, %options)
+ or last;
}
close $fh;
}