Automate the maintenance of the hash of compiler-defined entries in %params

This commit is contained in:
Tom Eastep 2011-01-09 13:12:36 -08:00
parent 0dc4cd7937
commit 3392312cef
2 changed files with 23 additions and 16 deletions

View File

@ -103,6 +103,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
which which
qt qt
ensure_config_path ensure_config_path
add_param
export_params export_params
get_configuration get_configuration
require_capability require_capability
@ -125,7 +126,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
$debug $debug
%config %config
%globals %globals
%params
F_IPV4 F_IPV4
F_IPV6 F_IPV6
@ -278,6 +278,10 @@ our @openstack;
# #
our %params; our %params;
# #
# Entries that the compiler adds to %params
#
our %compiler_params;
#
# Action parameters # Action parameters
# #
our %actparms; our %actparms;
@ -718,13 +722,17 @@ sub initialize( $ ) {
$shorewall_dir = ''; #Shorewall Directory $shorewall_dir = ''; #Shorewall Directory
$debug = 0; $debug = 0;
%params = ( root => '', %params = ( root => '',
system => '', system => '',
command => '', command => '',
files => '', files => '',
destination => '' ); destination => '' );
%compiler_params = ();
$compiler_params{$_} = 1 for keys %params;
%actparms = (); %actparms = ();
} }
@ -2742,7 +2750,7 @@ sub ensure_config_path() {
open_file $f; open_file $f;
$params{CONFDIR} = $globals{CONFDIR}; add_param( CONFDIR => $globals{CONFDIR} );
while ( read_a_line ) { while ( read_a_line ) {
if ( $currentline =~ /^\s*([a-zA-Z]\w*)=(.*?)\s*$/ ) { if ( $currentline =~ /^\s*([a-zA-Z]\w*)=(.*?)\s*$/ ) {
@ -3025,25 +3033,24 @@ sub get_params() {
} }
} }
#
# Add an entry to %params
#
sub add_param( $$ ) {
my ( $param, $value ) = @_;
$params{$param} = $value;
$compiler_params{$param} = 1;
}
# #
# emit param=value for each param set in the params file # emit param=value for each param set in the params file
# #
sub export_params() { sub export_params() {
#
# These are variables that the compiler adds to the hash
#
my %exclude = ( root => 1,
system => 1,
files => 1,
destination => 1,
command => 1,
FW => 1,
CONFDIR => 1 );
my $count = 0; my $count = 0;
while ( my ( $param, $value ) = each %params ) { while ( my ( $param, $value ) = each %params ) {
next if $exclude{$param}; next if $compiler_params{$param};
# #
# Don't export pairs from %ENV # Don't export pairs from %ENV
# #

View File

@ -429,7 +429,7 @@ sub process_zone( \$ ) {
fatal_error 'Firewall zone may not be nested' if @parents; fatal_error 'Firewall zone may not be nested' if @parents;
fatal_error "Only one firewall zone may be defined ($zone)" if $firewall_zone; fatal_error "Only one firewall zone may be defined ($zone)" if $firewall_zone;
$firewall_zone = $zone; $firewall_zone = $zone;
$params{FW} = $zone; add_param( FW => $zone );
$type = FIREWALL; $type = FIREWALL;
} elsif ( $type eq 'vserver' ) { } elsif ( $type eq 'vserver' ) {
fatal_error 'Vserver zones may not be nested' if @parents; fatal_error 'Vserver zones may not be nested' if @parents;