From: Jacob Bachmeyer Date: Sat, 5 Nov 2022 21:02:36 +0000 (-0500) Subject: Revise install_files X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9de322a14fd7e0eb0891860beb6d1810aedff265;p=gatekeeper.git Revise install_files - eliminate unneeded intermediate variable - add separate variable for external public file name - adjust layout - replace call to fatal with structured exception The message produced for an existing file is changed and shortened; the testsuite is adjusted accordingly. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index 98f2202..975b440 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -2407,8 +2407,6 @@ sub install_files { our $Stage_dir; our $Public_dir; my @directory = File::Spec::Unix->splitdir($header->{directory}); - my $destdir = File::Spec->catdir - ($Public_dir, @directory); my $install_as = $step->[1]; my $upload_file = $header->{filename}; @@ -2417,8 +2415,11 @@ sub install_files { 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'); + my $pubfinal = File::Spec::Unix->catfile(@directory, $install_as); + my $final_upload = File::Spec->catfile + ($Public_dir, @directory, $install_as); + my $final_signature = File::Spec->catfile + ($Public_dir, @directory, $install_as.'.sig'); mkdir_p $Public_dir, @directory; @@ -2433,8 +2434,8 @@ sub install_files { $notification_str .= "Archived and overwrote $final_upload with uploaded version\n"; } else { - fatal("This file exists: $final_upload, if you want to " - ."replace the pair please use the 'replace' directive",1); + throw processing_error => command => $step, + summary => $pubfinal." exists and 'replace' was not selected"; } } diff --git a/testsuite/lib/gatekeeper.exp b/testsuite/lib/gatekeeper.exp index 94ed7f3..9e6a734 100644 --- a/testsuite/lib/gatekeeper.exp +++ b/testsuite/lib/gatekeeper.exp @@ -834,7 +834,7 @@ proc analyze_log { base_dir name assess } { # TODO: move CVE checks to VL phase -re {^gatekeeper\[[0-9]+\]: \(Test\) \[EX\]\ - This file exists: [^\r\n]+} { + [^ ]+ exists and 'replace' was not selected} { # from install_files, if target exists and replace not set set A(install,target-file-exists) 1 exp_continue