From 0ef76bb1e2629713898631b9a3380d02d41c60ad Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 6 Apr 2020 09:33:11 -0400 Subject: [PATCH] Try harder to remove old run artefacts First, recursively set the permissions to 0700 so that rmtree shouldn't fail. Then, if rmtree does fail (i.e. if the directories still exist) die and don't proceed with the run. --- run_build.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/run_build.pl b/run_build.pl index 103480b..2ef835c 100755 --- a/run_build.pl +++ b/run_build.pl @@ -485,8 +485,20 @@ BEGIN exit(0); } +my $installdir = "$buildroot/$branch/inst"; + +# recursively fix any permissions that might stop us removing the directories +# then remove old run artefacts if any, die if not possible +my $fix_perms = sub { chmod 0700, $_; }; +File::Find::find( $fix_perms, "inst"); rmtree("inst"); -rmtree("$pgsql") unless ($from_source && !$use_vpath); +die "$installdir exists!" if -e "inst"; +unless ($from_source && !$use_vpath) +{ + File::Find::find($fix_perms, "$pgsql"); + rmtree($pgsql); + die "$pgsql exists!" if -e $pgsql; +} # we are OK to run if we get here $have_lock = 1; @@ -522,7 +534,6 @@ BEGIN use vars qw($now); BEGIN { $now = time; } -my $installdir = "$buildroot/$branch/inst"; my $dbstarted; my $extraconf;