Set up path for local modules
[buildfarm-client.git] / run_build
index 77c6de0241fb81d5898153fe3a13493405d91f80..c5584c92b1108c9cf34b69aa7520fb1c0b0cdc84 100755 (executable)
--- a/run_build
+++ b/run_build
@@ -36,6 +36,7 @@ our $VERSION = 'REL_0.1';
 
 use strict;
 use warnings;
+use 5.010;
 use Config;
 use Fcntl qw(:flock :seek);
 use File::Path;
@@ -43,7 +44,7 @@ use File::Copy;
 use File::Basename;
 use File::Temp;
 use File::Spec;
-use FindBin qw'$Bin';
+use FindBin qw'$RealBin';
 use IO::Handle;
 use POSIX qw(:signal_h strftime);
 use Data::Dumper;
@@ -71,6 +72,7 @@ BEGIN
             : 'xxxxxx'
         );
     }
+    push @INC, getcwd();
 }
 
 use EximBuild::SCM;
@@ -83,14 +85,13 @@ if ($0 =~ /(.*)\.pl$/) {
     exec $1, @ARGV;
 }
 
-die "$0: please use an umask of 022\n"
-    if umask > 022;
+if (umask != 022) {
+    umask 022;
+    say "$0: forced umask to 022" if -t;
+}
 
 my %module_hooks;
 my $orig_dir = getcwd();
-push @INC, $orig_dir;
-
-umask 022;
 
 # make sure we exit nicely on any normal interrupt
 # so the cleanup handler gets called.
@@ -173,14 +174,22 @@ my (
     $aux_path,$trigger_exclude,$trigger_include,$secret,
     $keep_errs,$force_every, $make, $optional_steps,
     $use_vpath,$tar_log_cmd, $using_msvc, $extra_config,
-    $make_jobs, $core_file_glob
+    $make_jobs, $core_file_glob, $global_lock_dir
   )
   =@EximBuild::conf{
     qw(build_root target animal print_success aux_path trigger_exclude
       trigger_include secret keep_error_builds force_every make optional_steps
-      use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob)
+      use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob global_lock_dir)
   };
 
+# This should be done more generally, for all the scripts
+# including the $buildconf. For now this is duplicated
+# in a similiar war in run_branches.
+$global_lock_dir //= $buildroot // die "$0: need global_lock_dir\n";
+
+die "$0: need read/write permissions on '$global_lock_dir': $!\n"
+    if not -r -w $global_lock_dir;
+
 #default is no parallel build
 $make_jobs ||= 1;
 
@@ -1444,9 +1453,9 @@ sub get_script_config_dump
     delete $conf->{secret};
 
     if ($conf->{scm} eq 'git') {
-        chomp($conf->{farm}{revision} = `git -C $Bin describe --tags --always --dirty=+`);
+        chomp($conf->{farm}{revision} = `cd $RealBin && git describe --tags --always --dirty=+`);
        $conf->{farm}{cwd} = getcwd();
-       $conf->{farm}{bindir} = $Bin;
+       $conf->{farm}{bindir} = $RealBin;
     }
 
     $Data::Dumper::Sortkeys = 1;