sub check_files {
my $header = shift;
my $files = shift;
- my %info = @_;
my ($sig_file,$upload_file) = ($files->{"sig"}, $files->{"upload"});
my $sig_file_size = -s $sig_file;
ftp_syslog('debug', "DEBUG: "
."$upload_file size is $upload_file_size") if DEBUG;
- my @keyrings = keyring_file ($info{package},$info{directory});
- fatal("no keyring for package $info{package}",0) if ($#keyrings < 0);
+ my @keyrings = keyring_file ($header->{package},$header->{directory});
+ fatal("no keyring for package $header->{package}",0) if ($#keyrings < 0);
my $valid = 0;
foreach my $keyring (@keyrings) {
sub install_files {
my $header = shift;
my $files = shift;
- my %info = @_;
my ($sig_file,$upload_file) = ($files->{"sig"}, $files->{"upload"});
- my $destdir = "$destfinal/$info{directory}";
+ my $destdir = "$destfinal/$header->{directory}";
# File::Path is 200 lines of Perl and requires reading an external
# text file. In my mind, it is a toss-up as to whether that or
# forking the system mkdir is safer. We could debate endlessly,
# We now allow overwriting of files - without warning!!
if (-e "$destdir/$sig_file") {
- if (not exists($info{'replace'}) or ($info{'replace'} ne 'true')) {
- fatal("This signature file exists: $destdir/$sig_file, if you want to "
- ."replace the pair please use the 'replace' directive",1);
- } else {
- archive($destdir, $info{directory}, $sig_file);
+ if ($header->{options}{replace}) {
+ archive($destdir, $header->{directory}, $sig_file);
ftp_syslog('info', "archived and overwrote "
."$destdir/$sig_file with uploaded version");
$t1 = 1;
+ } else {
+ fatal("This signature file exists: $destdir/$sig_file, if you want to "
+ ."replace the pair please use the 'replace' directive",1);
}
}
if (-e "$destdir/$upload_file") {
- if (not exists($info{'replace'}) or ($info{'replace'} ne 'true')) {
- fatal("This file exists: $destdir/$upload_file, if you want to "
- ."replace the pair please use the 'replace' directive",1);
- } else {
- archive($destdir, $info{directory}, $upload_file);
+ if ($header->{options}{replace}) {
+ archive($destdir, $header->{directory}, $upload_file);
ftp_syslog('info', "overwrote "
."$destdir/$upload_file with uploaded version");
$t2 = 1;
+ } else {
+ fatal("This file exists: $destdir/$upload_file, if you want to "
+ ."replace the pair please use the 'replace' directive",1);
}
}
my $notification_str = '';
}
}
-# Actual executing of commands. Respects the cronological order
-# they were specified in, thanks to the 'order' value in the %info
-# hash
sub execute_commands {
my $oplist = shift;
my $files = shift;
- my %info = @_;
-
- # Keep the hash as temporary scaffolding for check_files & install_files
- my %originfo = %info;
ftp_abort("invalid internal operation list")
unless $oplist->[0][0] eq 'header';
my $destdir = "$destfinal/$header->{directory}";
foreach my $step (@{$oplist}[1..$#$oplist]) { # skip the header
if ($step->[0] eq 'install') {
- check_files($header, $files, %originfo);
- install_files($header, $files, %originfo);
+ check_files($header, $files);
+ install_files($header, $files);
} elsif ($step->[0] eq 'symlink') {
my $target = $step->[1];
my $linkname = $step->[2];
# do the work
execute_commands($oplist,
{directive => $directive_file, upload => $upload_file,
- sig => $sig_file, directive_only => $directive_only},
- %info);
+ sig => $sig_file, directive_only => $directive_only});
# report success
if (!$directive_only) {