Revise global storage for serials file name
authorJacob Bachmeyer <jcb@gnu.org>
Thu, 23 Mar 2023 04:06:40 +0000 (23:06 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Thu, 23 Mar 2023 04:06:40 +0000 (23:06 -0500)
The serials file is now stored in the package state directory and is
named relative to that directory in the configuration.

gatekeeper.pl

index f66f77b8b5a27b799a0919fab036fb2cbe504a67..75d11cb51e7db969dd4dbe2f109502f06201a92e 100755 (executable)
@@ -326,7 +326,7 @@ BEGIN {
 
       our $package_config_base =File::Spec->catdir($base, 'packages');
       our $package_state_base = $base;
-      our $serials_path           =    File::Spec->catfile($base, 'serial.txt');
+      our $serials_name           =    'serial.txt';
 
       our $Inbox_dir   =       File::Spec->catdir($base, 'inbox');
       our $Scratch_dir =       File::Spec->catdir($base, 'scratch');
@@ -384,10 +384,7 @@ BEGIN {
 
       our $package_config_base = $ZoneConfig{pkgconfdir};
       our $package_state_base = $ZoneConfig{pkgstatedir};
-      our $serials_path;
-      $serials_path= File::Spec->catfile($ZoneConfig{pkgstatedir},
-                                        $ZoneConfig{serials})
-       if $ZoneConfig{pkgstatedir} && $ZoneConfig{serials};
+      our $serials_name = $ZoneConfig{serials};
 
       our $Inbox_dir = $ZoneConfig{inboxdir};
       our $Scratch_dir = $ZoneConfig{scratchdir};
@@ -399,7 +396,7 @@ BEGIN {
     if ($CheckConfigurationParse) {
       our $email_blacklist; our $maintainers_bypkg;
       our $Public_Upload_Archive_Inbox; our $Internal_Report_Inbox;
-      our $zone_tag; our $Log_Tag; our $serials_path;
+      our $zone_tag; our $Log_Tag; our $serials_name;
       our $package_config_base; our $package_state_base;
       our $Inbox_dir; our $Scratch_dir;
       our $Stage_dir; our $Public_dir; our $Archive_dir;
@@ -413,8 +410,7 @@ BEGIN {
       foreach my $item ([tag => $zone_tag], [logtag => $Log_Tag],
                        [pkgconfdir => $package_config_base],
                        [pkgstatedir => $package_state_base],
-                       [serials => $serials_path
-                        ? (File::Spec->splitpath($serials_path))[2] : undef],
+                       [serials => $serials_name],
                        [inboxdir => $Inbox_dir], [scratchdir => $Scratch_dir],
                        [stagedir => $Stage_dir], [publicdir => $Public_dir],
                        [archivedir => $Archive_dir])
@@ -482,7 +478,6 @@ our $zone_tag;
 our $package_config_base;
 our $email_blacklist;
 our $maintainers_bypkg;
-our $serials_path;
 
 # syslog destination
 use constant SYSLOG_APP_IDENT => 'gatekeeper';
@@ -2385,6 +2380,11 @@ sub advance_timestamp_ratchet {
   my $full_filename = shift;
   my $new_epoch = shift;
 
+  # scaffolding
+  our $package_state_base; our $serials_name;
+  return unless defined $serials_name;
+  my $serials_path = File::Spec->catfile($package_state_base, $serials_name);
+
   # Now we need to flock the our 'serials' file;
   # verify the epoch value there/update it, etc.
   my %serials = ();