# Settings to configure:
my $package_config_base = "/home/gatekpr/packages";
-# where ftpd deposits the files for us to look at:
-my $incoming_dir = "/home/upload/incoming/$m_style";
-# private dir on SAME FILESYSTEM as $incoming_dir:
-my $incoming_tmp = "/var/tmp/$m_style-in";
-# top-level public ftp dir for installing files:
-my $destfinal = "/home/$m_style/gnu";
-$destfinal = "/home/ftp/$m_style"
- if ($m_style eq 'gnu+linux-distros'); # The distros go here
-# private dir on SAME FILESYSTEM as $destfinal:
-my $olddestfinal = "/home/gatekpr/$m_style-archived";
-# private dir on SAME FILESYSTEM as $destfinal:
-my $desttmp = "/var/tmp/$m_style-out";
+{
+ # where ftpd deposits the files for us to look at:
+ our $Inbox_dir = "/home/upload/incoming/$m_style";
+ # private dir on SAME FILESYSTEM as $Inbox_dir:
+ our $Scratch_dir = "/var/tmp/$m_style-in";
+ # top-level public ftp dir for installing files:
+ our $Public_dir = "/home/$m_style/gnu";
+ $Public_dir = "/home/ftp/$m_style"
+ if ($m_style eq 'gnu+linux-distros'); # The distros go here
+ # private dir on SAME FILESYSTEM as $Public_dir:
+ our $Archive_dir = "/home/gatekpr/$m_style-archived";
+ # private dir on SAME FILESYSTEM as $Public_dir:
+ our $Stage_dir = "/var/tmp/$m_style-out";
+}
# We sometimes want to exclude e-mail addresses from being emailed.
# Specifically, e-mail addresses we import from gpg keys - keys are still
$package_config_base = File::Spec->catdir($base, 'packages');
- $incoming_dir = File::Spec->catdir($base, 'incoming');
- $incoming_tmp = File::Spec->catdir($base, 'in-stage');
- $desttmp = File::Spec->catdir($base, 'stage');
- $destfinal = File::Spec->catdir($base, 'pub');
- $olddestfinal = File::Spec->catdir($base, 'archive');
+ our $Inbox_dir = File::Spec->catdir($base, 'incoming');
+ our $Scratch_dir = File::Spec->catdir($base, 'in-stage');
+ our $Stage_dir = File::Spec->catdir($base, 'stage');
+ our $Public_dir = File::Spec->catdir($base, 'pub');
+ our $Archive_dir = File::Spec->catdir($base, 'archive');
$email_blacklist = File::Spec->catfile($base, 'email.blacklist');
$maintainers_bypkg = File::Spec->catfile($base, 'm.bypkg');
# make sure our directories all exist, or it's hopeless.
# Use die instead of fatal - this error should "never" happen.
-for my $dir ($package_config_base, $incoming_dir, $incoming_tmp,
- $destfinal, $desttmp) {
- ftp_abort("FATAL: configuration problem, $dir is not a directory")
- unless -d $dir;
+{
+ our $Inbox_dir; our $Scratch_dir; our $Public_dir; our $Stage_dir;
+ for my $dir ($package_config_base, $Inbox_dir, $Scratch_dir,
+ $Public_dir, $Stage_dir) {
+ ftp_abort("FATAL: configuration problem, $dir is not a directory")
+ unless -d $dir;
+ }
}
\f
my $subdir = shift;
my $file = shift;
+ our $Public_dir; our $Archive_dir;
+
# Abort if file to archive doesn't exist
fatal("$subdir/$file does not exist - can not archive",1)
- if (!-e "$destfinal/$subdir/$file");
+ if (!-e "$Public_dir/$subdir/$file");
my $timestamp = strftime "%Y-%m-%d_%H-%M-%S", localtime;
# Add a large random number for good measure
$timestamp .= sprintf("_%09d",rand(1000000000));
# Abort if a file with same name exists in the archive
fatal("$subdir/$file exists in archive - can not overwrite",1)
- if (-e "$olddestfinal/$subdir/$timestamp" . "_$file");
+ if (-e "$Archive_dir/$subdir/$timestamp" . "_$file");
- my @mkdir_args = ("/bin/mkdir","-p","$olddestfinal/$subdir");
+ my @mkdir_args = ("/bin/mkdir","-p","$Archive_dir/$subdir");
fatal("@mkdir_args failed",0) if system (@mkdir_args) != 0;
my @mv_args = ("/bin/mv", "$dir/$file",
- "$olddestfinal/$subdir/$timestamp"."_$file");
+ "$Archive_dir/$subdir/$timestamp"."_$file");
fatal("@mv_args failed",0) if system (@mv_args) != 0;
ftp_syslog('info',
- "archived $dir/$file to $olddestfinal/$subdir/$timestamp"
+ "archived $dir/$file to $Archive_dir/$subdir/$timestamp"
."_$file");
}
-# Install both SIG_FILE and UPLOAD_FILE in $destfinal/$info{directory}.
+# Install both SIG_FILE and UPLOAD_FILE in $Public_dir/$info{directory}.
# Make the directory if it doesn't exist (for, e.g., a new gcc/x.y.z
# subdir). When the destination file exists, archive it automatically first.
#
-# TODO: - currently assumes files are located in $incoming_tmp
+# TODO: - currently assumes files are located in $Scratch_dir
# - factor out final staging
sub install_files {
my $header = shift;
my $step = shift; # [ install => $filename ]
+ our $Stage_dir; our $Public_dir;
+
my $destdir = File::Spec->catdir
- ($destfinal, File::Spec::Unix->splitdir($header->{directory}));
+ ($Public_dir, File::Spec::Unix->splitdir($header->{directory}));
my $install_as = $step->[1];
my $upload_file = $header->{filename};
my $sig_file = $header->{filename}.'.sig';
- my $stage_upload = File::Spec->catfile($desttmp, $upload_file);
- my $stage_signature = File::Spec->catfile($desttmp, $sig_file);
+ my $stage_upload = File::Spec->catfile($Stage_dir, $upload_file);
+ my $stage_signature = File::Spec->catfile($Stage_dir, $sig_file);
my $final_upload = File::Spec->catfile($destdir, $install_as);
my $final_signature = File::Spec->catfile($destdir, $install_as.'.sig');
mail ($notification_str) if ($notification_str ne '');
- # Do we need a subdirectory on $desttmp as well? Can't quite picture
+ # Do we need a subdirectory on $Stage_dir as well? Can't quite picture
# when we'd have a collision, so skip that for now.
#
+ our $Scratch_dir;
for my $f (($sig_file, $upload_file)) {
- my $stage = File::Spec->catfile($desttmp, $f);
- my @mv_args = ("/bin/mv", File::Spec->catfile($incoming_tmp, $f), $stage);
+ my $stage = File::Spec->catfile($Stage_dir, $f);
+ my @mv_args = ("/bin/mv", File::Spec->catfile($Scratch_dir, $f), $stage);
fatal("@mv_args failed",0) if system (@mv_args) != 0;
chmod 0644, $stage;
}
sub execute_commands {
my $oplist = shift;
+ our $Scratch_dir; our $Public_dir;
+
ftp_abort("invalid internal operation list")
unless $oplist->[0][0] eq 'header';
my $header = $oplist->[0][1];
- my $destdir = "$destfinal/$header->{directory}";
+ my $destdir = "$Public_dir/$header->{directory}";
foreach my $step (@{$oplist}[1..$#$oplist]) { # skip the header
if ($step->[0] eq 'install') {
- check_files($incoming_tmp, $header);
+ check_files($Scratch_dir, $header);
install_files($header, $step);
} elsif ($step->[0] eq 'symlink') {
my $target = $step->[1];
}
sub cleanup {
- for my $dir ($incoming_dir, $incoming_tmp, $desttmp) {
+ our $Inbox_dir; our $Scratch_dir; our $Stage_dir;
+ for my $dir ($Inbox_dir, $Scratch_dir, $Stage_dir) {
for my $f (@_) {
ftp_syslog('debug',"DEBUG: cleaning up $dir/$f\n")
if (DEBUG > 1);
my @packets;
{
local $Phase = 'SC';
- @packets = gather_packets($incoming_dir, $incoming_tmp);
+ our $Inbox_dir; our $Scratch_dir;
+ @packets = gather_packets($Inbox_dir, $Scratch_dir);
}
-# we've moved the files to work on to a new directory.
-chdir ($incoming_tmp)
- or ftp_abort("FATAL: chdir($incoming_tmp) failed: $!");
+{
+ our $Scratch_dir;
+ # we've moved the files to work on to a new directory.
+ chdir ($Scratch_dir)
+ or ftp_abort("FATAL: chdir($Scratch_dir) failed: $!");
+}
foreach my $packet (@packets) { # each list element is an array reference
my $stem = substr $packet->[0],0,-(length '.directive.asc');
ftp_syslog('info',"found directive: $packet->[0]");
# variables preserved for the report if an exception is thrown
- my $directive_text; my $directive; my $sig_info; my $oplist; my $op_header;
+ my $directive_text; my $directive; my $oplist; my $op_header; my $sig_info;
+ my @email_addresses; # addresses to receive copies of report
my $complete = 0; # direct flag to indicate successful processing
# scaffolding to be cleaned up as the internal API is improved
ftp_syslog('info', "Updated ftpindex");
}
-# Clean up the incoming directory and the incoming tmp directory - remove files older than a day
-cleanup_dir($incoming_dir);
-cleanup_dir($incoming_tmp);
+{
+ our $Inbox_dir; our $Scratch_dir;
+
+ # Clean up the incoming directory and the incoming tmp directory - remove files older than a day
+ cleanup_dir($Inbox_dir);
+ cleanup_dir($Scratch_dir);
+}
exit 0;