diff options
Diffstat (limited to 'lib/sbin/ConfigurationParser.pl')
-rw-r--r-- | lib/sbin/ConfigurationParser.pl | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/sbin/ConfigurationParser.pl b/lib/sbin/ConfigurationParser.pl index c9e1dcb7..533ecde0 100644 --- a/lib/sbin/ConfigurationParser.pl +++ b/lib/sbin/ConfigurationParser.pl @@ -73,6 +73,34 @@ sub CreateConfigurationDatabase $cfg{"\U$thorn\E USES THORNS"} .= $cfg{"\U$thorn\E REQUIRES THORNS"} . ' '; } + # Turn optional capabilities into required capabilities, if the + # capability is provided. This way we don't have to treat required + # and optional requirements differently. + my %providedcaps; + foreach my $thorn (sort keys %thorns) + { + if ($cfg{"\U$thorn\E PROVIDES"}) + { + foreach my $providedcap (split (' ', $cfg{"\U$thorn\E PROVIDES"})) + { + $providedcaps{$providedcap} = 1; + } + } + } + foreach my $thorn (sort keys %thorns) + { + if ($cfg{"\U$thorn\E OPTIONAL"}) + { + foreach my $optionalcap (split (' ', $cfg{"\U$thorn\E OPTIONAL"})) + { + if ($providedcaps{$optionalcap}) + { + $cfg{"\U$thorn\E REQUIRES"} .= "$optionalcap "; + } + } + } + } + foreach my $thorn (sort keys %thorns) { # verify that all required capabilities are there in the ThornList @@ -130,6 +158,34 @@ sub CreateConfigurationDatabase &CST_error(0, $message); } + # Turn optional capabilities into required capabilities, if the + # capability is provided. This way we don't have to treat required + # and optional requirements differently. + my %providedcaps; + foreach my $thorn (sort keys %thorns) + { + if ($cfg{"\U$thorn\E PROVIDES"}) + { + foreach my $providedcap (split (' ', $cfg{"\U$thorn\E PROVIDES"})) + { + $providedcaps{$providedcap} = 1; + } + } + } + foreach my $thorn (sort keys %thorns) + { + if ($cfg{"\U$thorn\E OPTIONAL"}) + { + foreach my $optionalcap (split (' ', $cfg{"\U$thorn\E OPTIONAL"})) + { + if ($providedcaps{$optionalcap}) + { + $cfg{"\U$thorn\E REQUIRES"} .= " $optionalcap"; + } + } + } + } + return \%cfg; } |