diff options
author | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2009-06-18 18:53:18 +0000 |
---|---|---|
committer | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2009-06-18 18:53:18 +0000 |
commit | 2e496d3dfb0ea33c1582683be296c26e781d8b6d (patch) | |
tree | 88e08c7b1b18e6dd803fe52c8efae8af664aa945 | |
parent | 6419b041a7df54b0cbc304a24db02480f21834ac (diff) |
Order thorns topologically when executing configurations scripts. If
thorn A requires a feature provided by thorn B, then thorn B's
configuration script is executed first.
Make environment variables that are defined in configuration scripts
available immediately, so that scripts (from other thorns) whicn are
execute later can access them.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4561 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rw-r--r-- | lib/sbin/ProcessConfiguration.pl | 70 |
1 files changed, 59 insertions, 11 deletions
diff --git a/lib/sbin/ProcessConfiguration.pl b/lib/sbin/ProcessConfiguration.pl index d0a1e898..27706b38 100644 --- a/lib/sbin/ProcessConfiguration.pl +++ b/lib/sbin/ProcessConfiguration.pl @@ -120,22 +120,70 @@ sub ProcessConfiguration # Ok, can now run the configuration scripts. - foreach $thorn (sort keys %thorns) + my %thorns_todo = (); + map { $thorns_todo{"\U$_\E"} = 1; } sort keys %thorns; + my %requirements_done = (); + +# print "DEBUG: Processing thorn provisions:\n"; + while (keys %thorns_todo) { - foreach $provides (split(' ',$config_database->{"\U$thorn\E PROVIDES"})) +# print "DEBUG: Thorns left to do: " . scalar(%thorns_todo) . "\n"; +# map { print "DEBUG: - $_\n"; } sort keys %thorns_todo; + my $made_progress = 0; + THORN: foreach $thorn (sort keys %thorns_todo) { - my $script = $config_database->{"\U$thorn\E PROVIDES \U$provides\E SCRIPT"}; - my $lang = $config_database->{"\U$thorn\E PROVIDES \U$provides\E LANG"}; - - if ($script) +# print "DEBUG: Checking thorn $thorn\n"; + my @provides_list = split(' ',$config_database->{"\U$thorn\E PROVIDES"}); +# print "DEBUG: Provides: @provides_list\n"; + my @requires_list = split(' ',$config_database->{"\U$thorn\E REQUIRES"}); +# print "DEBUG: Requires: @requires_list\n"; + + my %need = (); + map { $need{"\U$_\E"} = 1; } @requires_list; + map { delete $need{"\U$_\E"}; } @provides_list; + map { next THORN unless exists $requirements_done{"\U$_\E"}; } keys %need; + +# print "DEBUG: Processing thorn $thorn\n"; + foreach my $provides (@provides_list) { - print "Running configuration script '$script'\n"; - - &ParseConfigScript($config_dir, $provides, $lang, $script, - $thorn, $config_database); - print "\n"; +# print "DEBUG: Processing provision $provides\n"; + my $script = $config_database->{"\U$thorn\E PROVIDES \U$provides\E SCRIPT"}; + my $lang = $config_database->{"\U$thorn\E PROVIDES \U$provides\E LANG"}; + + if ($script) + { +# print "DEBUG: Running configuration script '$script'\n"; + + &ParseConfigScript($config_dir, $provides, $lang, $script, + $thorn, $config_database); +# print "DEBUG: \n"; + } + + # Add make definitions to the environment, so that they are + # available to the following scripts + my $config = $config_database->{"\U$thorn $provides\E MAKE_DEFINITION"}; + my %options = $config =~ /^\s*(\w+)\s*=(.*)$/mg; + foreach my $option (keys %options) + { + my $value = $options{$option}; + $value =~ s/^\s*//; + $value =~ s/\s*$//; +# print "DEBUG: Thorn $thorn, providing $provides, setting \$ENV{$option}=\"$value\"\n"; + $ENV{$option} = $value; + } + + $requirements_done{"\U$provides\E"} = 1; } + + delete $thorns_todo{"\U$thorn\E"}; + $made_progress = 1; } +# if (! $made_progress) +# { +# print "DEBUG: Provided requirements: " . scalar($requirements_done) . "\n"; +# map { print "DEBUG: - $_\n"; } sort keys %requirements_done; +# } + die unless $made_progress; } } |