From efa13359dff4f7bbef2611c5091041d236838f36 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 10 Nov 2006 13:13:59 +0000 Subject: create _configure_parallel() out of configure() --- urpm.pm | 70 +++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'urpm.pm') diff --git a/urpm.pm b/urpm.pm index f0fe2118..d5f82b4e 100644 --- a/urpm.pm +++ b/urpm.pm @@ -423,6 +423,39 @@ sub write_config { delete $urpm->{modified}; } +sub _configure_parallel { + my ($urpm, $alias) = @_; + my ($parallel_options, $parallel_handler); + #- read parallel configuration + foreach (cat_("/etc/urpmi/parallel.cfg")) { + chomp; s/#.*$//; s/^\s*//; s/\s*$//; + /\s*([^:]*):(.*)/ or $urpm->{error}(N("unable to parse \"%s\" in file [%s]", $_, "/etc/urpmi/parallel.cfg")), next; + $1 eq $alias and $parallel_options = ($parallel_options && "\n") . $2; + } + #- if a configuration option has been found, use it; else fatal error. + if ($parallel_options) { + foreach my $dir (grep { -d $_ } map { "$_/urpm" } @INC) { + foreach my $pm (grep { -f $_ } glob("$dir/parallel*.pm")) { + #- load parallel modules + $urpm->{log}->(N("examining parallel handler in file [%s]", $pm)); + # perl_checker: require urpm::parallel_ka_run + # perl_checker: require urpm::parallel_ssh + eval { require $pm; $parallel_handler = $urpm->handle_parallel_options($parallel_options) }; + $parallel_handler and last; + } + $parallel_handler and last; + } + } + if ($parallel_handler) { + if ($parallel_handler->{nodes}) { + $urpm->{log}->(N("found parallel handler for nodes: %s", join(', ', keys %{$parallel_handler->{nodes}}))); + } + $urpm->{parallel_handler} = $parallel_handler; + } else { + $urpm->{fatal}(1, N("unable to use parallel option \"%s\"", $alias)); + } +} + #- read urpmi.cfg file as well as necessary synthesis files #- options : #- callback @@ -448,38 +481,11 @@ sub configure { $options{parallel} && $options{usedistrib} and $urpm->{fatal}(1, N("Can't use parallel mode with use-distrib mode")); if ($options{parallel}) { - my ($parallel_options, $parallel_handler); - #- read parallel configuration - foreach (cat_("/etc/urpmi/parallel.cfg")) { - chomp; s/#.*$//; s/^\s*//; s/\s*$//; - /\s*([^:]*):(.*)/ or $urpm->{error}(N("unable to parse \"%s\" in file [%s]", $_, "/etc/urpmi/parallel.cfg")), next; - $1 eq $options{parallel} and $parallel_options = ($parallel_options && "\n") . $2; - } - #- if a configuration option has been found, use it; else fatal error. - if ($parallel_options) { - foreach my $dir (grep { -d $_ } map { "$_/urpm" } @INC) { - foreach my $pm (grep { -f $_ } glob("$dir/parallel*.pm")) { - #- load parallel modules - $urpm->{log}->(N("examining parallel handler in file [%s]", $pm)); - # perl_checker: require urpm::parallel_ka_run - # perl_checker: require urpm::parallel_ssh - eval { require $pm; $parallel_handler = $urpm->handle_parallel_options($parallel_options) }; - $parallel_handler and last; - } - $parallel_handler and last; - } - } - if ($parallel_handler) { - if ($parallel_handler->{nodes}) { - $urpm->{log}->(N("found parallel handler for nodes: %s", join(', ', keys %{$parallel_handler->{nodes}}))); - } - if (!$options{media} && $parallel_handler->{media}) { - $options{media} = $parallel_handler->{media}; - $urpm->{log}->(N("using associated media for parallel mode: %s", $options{media})); - } - $urpm->{parallel_handler} = $parallel_handler; - } else { - $urpm->{fatal}(1, N("unable to use parallel option \"%s\"", $options{parallel})); + _configure_parallel($urpm, $options{parallel}); + + if (!$options{media} && $urpm->{parallel_handler}{media}) { + $options{media} = $urpm->{parallel_handler}{media}; + $urpm->{log}->(N("using associated media for parallel mode: %s", $options{media})); } } else { #- parallel is exclusive against root options. -- cgit v1.2.1