From dd9e254b81c15fa2f3e21b98ead7cabd4ccf45cc Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Wed, 22 Mar 2023 22:37:37 -0500 Subject: [PATCH] Remove ZONE constant and rename variable --- gatekeeper.pl | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 9ae13a1..f66f77b 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -248,7 +248,7 @@ BEGIN { } BEGIN { - my $ZONE = ''; + my $Zone = ''; my $want_help = ''; my $want_version = ''; @@ -271,7 +271,7 @@ BEGIN { GetOptions('help' => \$want_help, 'version' => \$want_version, 'configfile|config|conf|c=s' => \$ConfigFile, - 'zone|z=s' => \$ZONE, + 'zone|z=s' => \$Zone, 'with-gpgv=s' => \$GPGV_Bin, 'with-lsof=s' => \$LSOF_Bin, 'tstampcheck=i' => \$TSTAMPCHECK, @@ -281,7 +281,6 @@ BEGIN { 'check-config-parse' => \$CheckConfigurationParse, ) or pod2usage(-verbose => 0, -exitval => 2); - constant->import(ZONE => $ZONE); constant->import(DEBUG => $DEBUG); constant->import(NOMAIL => $NOMAIL); constant->import(TSTAMPCHECK => $TSTAMPCHECK); @@ -342,7 +341,7 @@ BEGIN { open my $config, '<', $ConfigFile or die "gatekeeper: read config $ConfigFile: $!\n"; - my $interesting = $ZONE ? undef : \%ZoneConfig; + my $interesting = $Zone ? undef : \%ZoneConfig; while (<$config>) { chomp; next if m/^$/ || m/^\s*#/; # skip blank lines and comments @@ -352,7 +351,7 @@ BEGIN { if (m/^\[([-_.[:alnum:]]*)\]/) { # begin section if ($1 eq 'email') { $interesting = \%EmailConfig } - elsif ($1 eq 'zone.'.$ZONE) { $interesting = \%ZoneConfig } + elsif ($1 eq 'zone.'.$Zone) { $interesting = \%ZoneConfig } else { $interesting = undef } } elsif (not defined $interesting) { next @@ -366,11 +365,11 @@ BEGIN { close $config; # Check if zones are configured and/or --zone given. - if (@zonelist and $ZONE eq '') { + if (@zonelist and $Zone eq '') { die "gatekeeper: zones configured but --zone parameter not given\n" .join(' ', 'gatekeeper: known zones:', @zonelist)."\n"; - } elsif ($ZONE and not grep $_ eq $ZONE, @zonelist) { - die "gatekeeper: requested zone '$ZONE' not configured\n" + } elsif ($Zone and not grep $_ eq $Zone, @zonelist) { + die "gatekeeper: requested zone '$Zone' not configured\n" .join(' ', 'gatekeeper: known zones:', @zonelist)."\n"; } @@ -380,8 +379,8 @@ BEGIN { our $Public_Upload_Archive_Inbox = $EmailConfig{archivebox}; our $Internal_Report_Inbox = $EmailConfig{internalbox}; - our $zone_tag = $ZoneConfig{tag} || $ZONE || 'upload'; - our $Log_Tag = $ZoneConfig{logtag} || ucfirst $ZONE || 'Upload'; + our $zone_tag = $ZoneConfig{tag} || $Zone || 'upload'; + our $Log_Tag = $ZoneConfig{logtag} || ucfirst $Zone || 'Upload'; our $package_config_base = $ZoneConfig{pkgconfdir}; our $package_state_base = $ZoneConfig{pkgstatedir}; @@ -405,12 +404,12 @@ BEGIN { our $Inbox_dir; our $Scratch_dir; our $Stage_dir; our $Public_dir; our $Archive_dir; - if ($ZONE) { - print "# gatekeeper configuration as parsed for zone $ZONE:\n\n"; + if ($Zone) { + print "# gatekeeper configuration as parsed for zone $Zone:\n\n"; } else { print "# gatekeeper configuration as parsed:\n\n"; } - print "[zone.$ZONE]\n" if $ZONE; + print "[zone.$Zone]\n" if $Zone; foreach my $item ([tag => $zone_tag], [logtag => $Log_Tag], [pkgconfdir => $package_config_base], [pkgstatedir => $package_state_base], -- 2.25.1