Remove ZONE constant and rename variable
authorJacob Bachmeyer <jcb@gnu.org>
Thu, 23 Mar 2023 03:37:37 +0000 (22:37 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Thu, 23 Mar 2023 03:37:37 +0000 (22:37 -0500)
gatekeeper.pl

index 9ae13a132bbc99edcb5f28044c9771a1fcb374d1..f66f77b8b5a27b799a0919fab036fb2cbe504a67 100755 (executable)
@@ -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],