5 Copyright (c) 2003-2010, Andrew Dunstan
7 See accompanying License file for license details
11 ####################################################
15 NAME: run_build.pl - script to run exim buildfarm
19 run_build.pl [option ...] [branchname]
21 AUTHOR: Andrew Dunstan
25 See http://wiki.exim.org/wiki/PostgreSQL_Buildfarm_Howto
29 https://github.com/EximBuildFarm/client-code
33 ###################################################
35 use vars qw($VERSION); $VERSION = 'REL_0.1';
40 use Fcntl qw(:flock :seek);
47 use POSIX qw(:signal_h strftime);
49 use Cwd qw(abs_path getcwd);
52 # save a copy of the original enviroment for reporting
53 # save it early to reduce the risk of prior mangling
54 use vars qw($orig_env);
59 while (my ($k,$v) = each %ENV)
62 # report all the keys but only values for whitelisted settings
63 # this is to stop leaking of things like passwords
66 $k =~ /^PG(?!PASSWORD)|MAKE|CC|CPP|FLAG|LIBRAR|INCLUDE/
67 ||$k =~/^(HOME|LOGNAME|USER|PATH|SHELL)$/
76 use EximBuild::Options;
77 use EximBuild::WebTxn;
80 my $orig_dir = getcwd();
83 # make sure we exit nicely on any normal interrupt
84 # so the cleanup handler gets called.
85 # that lets us stop the db if it's running and
86 # remove the inst and exim directories
87 # so the next run can start clean.
89 foreach my $sig (qw(INT TERM HUP QUIT))
91 $SIG{$sig}=\&interrupt_exit;
94 # copy command line before processing - so we can later report it
97 my @invocation_args = (@ARGV);
99 # process the command line
100 EximBuild::Options::fetch_options();
102 die "only one of --from-source and --from-source-clean allowed"
103 if ($from_source && $from_source_clean);
105 die "only one of --skip-steps and --only-steps allowed"
106 if ($skip_steps && $only_steps);
108 $verbose=1 if (defined($verbose) && $verbose==0);
109 $verbose ||= 0; # stop complaints about undefined var in numeric comparison
113 $verbose=1 unless $verbose;
120 use vars qw(%skip_steps %only_steps);
122 if ($skip_steps =~ /\S/)
124 %skip_steps = map {$_ => 1} split(/\s+/,$skip_steps);
127 if ($only_steps =~ /\S/)
129 %only_steps = map {$_ => 1} split(/\s+/,$only_steps);
132 # Currently only specifying a branch is actually used.
133 # Specifying a different repo is just a wishlist item .
134 use vars qw($branch $repo);
135 my ($arg1,$arg2) = (shift,shift);
136 $branch = $arg2 ? $arg2 :
139 $repo = $arg2 ? $arg1 : 'exim';
140 my $explicit_branch = $branch;
142 print_help() if ($help);
145 # process config file
149 # get the config data into some local variables
151 $buildroot,$target,$animal, $print_success,
152 $aux_path,$trigger_exclude,$trigger_include,$secret,
153 $keep_errs,$force_every, $make, $optional_steps,
154 $use_vpath,$tar_log_cmd, $using_msvc, $extra_config,
155 $make_jobs, $core_file_glob
158 qw(build_root target animal print_success aux_path trigger_exclude
159 trigger_include secret keep_error_builds force_every make optional_steps
160 use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob)
163 #default is no parallel build
166 # default core file pattern is Linux, which used to be hardcoded
167 $core_file_glob ||= 'core*';
170 if (defined($EximBuild::conf{trigger_filter}))
172 $trigger_exclude = $EximBuild::conf{trigger_filter};
175 my $scm_timeout_secs = $EximBuild::conf{scm_timeout_secs}
176 || $EximBuild::conf{cvs_timeout_secs};
178 print scalar(localtime()),": buildfarm run for $animal:$branch starting\n"
181 if (ref($force_every) eq 'HASH')
183 $force_every = $force_every->{$branch} || $force_every->{default};
186 my $config_opts = $EximBuild::conf{config_opts};
187 my $scm = new EximBuild::SCM \%EximBuild::conf;
191 if (exists $EximBuild::conf{base_port})
193 $buildport = $EximBuild::conf{base_port};
194 if ($branch =~ /REL(\d+)_(\d+)/)
196 $buildport += (10 * ($1 - 7)) + $2;
202 # support for legacy config style
203 $buildport = $EximBuild::conf{branch_ports}->{$branch} || 5999;
206 $ENV{EXTRA_REGRESS_OPTS} = "--port=$buildport";
208 $tar_log_cmd ||= "tar -z -cf runlogs.tgz *.log";
210 my $logdirname = "lastrun-logs";
212 if ($from_source || $from_source_clean)
214 $from_source ||= $from_source_clean;
215 die "sourceroot $from_source not absolute"
216 unless $from_source =~ m!^/!;
218 # we need to know where the lock should go, so unless the path
219 # contains HEAD we require it to be specified.
220 die "must specify branch explicitly with from_source"
221 unless ($explicit_branch || $from_source =~ m!/HEAD/!);
226 $logdirname = "fromsource-logs";
230 if ($branch eq 'HEAD' || $branch ge 'REL8_4')
233 # non-C locales are not regression-safe before 8.4
234 @locales = @{$EximBuild::conf{locales}} if exists $EximBuild::conf{locales};
236 unshift(@locales,'C') unless grep {$_ eq "C"} @locales;
239 # several people have run into these
241 if ( `uname -s 2>&1 ` =~ /CYGWIN/i )
243 my @procs = `ps -ef`;
244 die "cygserver not running" unless(grep {/cygserver/} @procs);
247 if ( $ccachedir = $EximBuild::conf{build_env}->{CCACHE_DIR} )
250 # ccache is smart enough to create what you tell it is the cache dir, but
251 # not smart enough to build the whole path. mkpath croaks on error, so
255 $ccachedir = abs_path($ccachedir);
260 die "no aux_path in config file" unless $aux_path;
263 die "cannot run as root/Administrator" unless ($using_msvc or $> > 0);
265 my $devnull = $using_msvc ? "nul" : "/dev/null";
269 $scm->check_access($using_msvc);
272 my $st_prefix = "$animal.";
274 my $exim = $from_source || $scm->get_build_path($use_vpath);
276 # set environment from config
277 while (my ($envkey,$envval) = each %{$EximBuild::conf{build_env}})
279 $ENV{$envkey}=$envval;
282 # change to buildroot for this branch or die
283 die "no buildroot" unless $buildroot;
285 unless ($buildroot =~ m!^/!
286 or($using_msvc and $buildroot =~ m![a-z]:[/\\]!i ))
288 die "buildroot $buildroot not absolute";
291 die "$buildroot does not exist or is not a directory" unless -d $buildroot;
293 chdir $buildroot || die "chdir to $buildroot: $!";
295 mkdir $branch unless -d $branch;
296 chdir $branch || die "chdir to $buildroot/$branch";
298 # rename legacy status files/directories
299 foreach my $oldfile (glob("last*"))
301 move $oldfile, "$st_prefix$oldfile";
304 my $branch_root = getcwd();
306 # make sure we are using GNU make
307 die "$make is not GNU Make - please fix config file"
311 foreach my $module (@{$EximBuild::conf{modules}})
314 # fill in the name of the module here, so use double quotes
315 # so everything BUT the module name needs to be escaped
317 require EximBuild::Modules::$module;
318 EximBuild::Modules::${module}::setup(
335 open($lockfile, ">builder.LCK") || die "opening lockfile: $!";
337 # only one builder at a time allowed per branch
338 # having another build running is not a failure, and so we do not output
339 # a failure message under this condition.
342 die "acquiring lock in $buildroot/$branch/builder.LCK"
343 unless flock($lockfile,LOCK_EX|LOCK_NB);
345 elsif ( !flock($lockfile,LOCK_EX|LOCK_NB) )
347 print "Another process holds the lock on "
348 ."$buildroot/$branch/builder.LCK. Exiting."
353 die "$buildroot/$branch has $exim or inst directories!"
354 if ((!$from_source && -d $exim) || -d "inst");
356 # we are OK to run if we get here
359 # check if file present for forced run
360 my $forcefile = $st_prefix . "force-one-run";
367 # try to allow core files to be produced.
368 # another way would be for the calling environment
369 # to call ulimit. We do this in an eval so failure is
372 require BSD::Resource;
373 BSD::Resource->import();
375 # explicit sub calls here. using & keeps compiler happy
376 my $coreok = setrlimit(&RLIMIT_CORE,&RLIM_INFINITY,&RLIM_INFINITY);
377 die "setrlimit" unless $coreok;
379 warn "failed to unlimit core size: $@" if $@ && $verbose > 1;
381 # the time we take the snapshot
383 my $installdir = "$buildroot/$branch/inst";
388 # cleanup handler for all exits
393 unlink $ENV{TEMP_CONFIG} if $extraconf;
395 # if we have the lock we must already be in the build root, so
396 # removing things there should be safe.
397 # there should only be anything to cleanup if we didn't have
399 if ( $have_lock && -d "$exim")
404 system(qq{"bin/pg_ctl" -D data stop >$devnull 2>&1});
405 foreach my $loc (@locales)
407 next unless -d "data-$loc";
408 system(qq{"bin/pg_ctl" -D "data-$loc" stop >$devnull 2>&1});
412 if ( !$from_source && $keep_errs)
414 print "moving kept error trees\n" if $verbose;
415 my $timestr = strftime "%Y-%m-%d_%H-%M-%S", localtime($now);
416 unless (move("$exim", "eximkeep.$timestr"))
418 print "error renaming '$exim' to 'eximkeep.$timestr': $!";
422 unless(move("inst", "instkeep.$timestr"))
424 print "error renaming 'inst' to 'instkeep.$timestr': $!";
430 rmtree("inst") unless $keepall;
431 rmtree("$exim") unless ($from_source || $keepall);
434 # only keep the cache in cases of success
435 rmtree("$ccachedir") if $ccachedir;
438 # get the modules to clean up after themselves
439 process_module_hooks('cleanup');
446 # vpath builds leave some stuff lying around in the
447 # source dir, unfortunately. This should clean it up.
451 unlink("builder.LCK");
455 # Prepend the DEFAULT settings (if any) to any settings for the
456 # branch. Since we're mangling this, deep clone $extra_config
457 # so the config object is kept as given. This is done using
458 # Dumper() because the MSys DTK perl doesn't have Storable. This
459 # is less efficient but it hardly matters here for this shallow
462 $extra_config = eval Dumper($extra_config);
464 if ($extra_config && $extra_config->{DEFAULT})
466 if (!exists $extra_config->{$branch})
468 $extra_config->{$branch} = $extra_config->{DEFAULT};
472 unshift(@{$extra_config->{$branch}}, @{$extra_config->{DEFAULT}});
476 if ($extra_config && $extra_config->{$branch})
479 ($extraconf,$tmpname) =File::Temp::tempfile(
481 DIR => File::Spec->tmpdir(),
484 die 'no $tmpname!' unless $tmpname;
485 $ENV{TEMP_CONFIG} = $tmpname;
486 foreach my $line (@{$extra_config->{$branch}})
488 print $extraconf "$line\n";
490 autoflush $extraconf 1;
493 use vars qw($steps_completed);
494 $steps_completed = "";
497 my @changed_since_success;
500 my $last_success_snap;
505 if ($from_source_clean)
507 print time_str(),"cleaning source in $exim ...\n";
510 elsif (!$from_source)
513 # see if we need to run the tests (i.e. if either something has changed or
514 # we have gone over the force_every heartbeat time)
516 print time_str(),"checking out source ...\n" if $verbose;
520 $timeout_pid = spawn(\&scm_timeout,$scm_timeout_secs)
521 if $scm_timeout_secs;
523 $savescmlog = $scm->checkout($branch);
524 $steps_completed = "SCM-checkout";
526 process_module_hooks('checkout',$savescmlog);
531 # don't kill me, I finished in time
532 if (kill(SIGTERM, $timeout_pid))
536 waitpid($timeout_pid,0);
540 print time_str(),"checking if build run needed ...\n" if $verbose;
542 # transition to new time processing
543 unlink "last.success";
545 # get the timestamp data
546 $last_status = find_last('status') || 0;
547 $last_run_snap = find_last('run.snap');
548 $last_success_snap = find_last('success.snap');
549 $forcerun = 1 unless (defined($last_run_snap));
551 # updated by find_changed to last mtime of any file in the repo
554 # see if we need to force a build
558 &&$last_status+($force_every*3600) < $now);
559 $last_status = 0 if $forcerun;
561 # see what's changed since the last time we did work
562 $scm->find_changed(\$current_snap,$last_run_snap, $last_success_snap,
563 \@changed_files,\@changed_since_success);
565 #ignore changes to files specified by the trigger exclude filter, if any
566 if (defined($trigger_exclude))
568 @filtered_files = grep { !m[$trigger_exclude] } @changed_files;
572 @filtered_files = @changed_files;
575 #ignore changes to files NOT specified by the trigger include filter, if any
576 if (defined($trigger_include))
578 @filtered_files = grep { m[$trigger_include] } @filtered_files;
581 my $modules_need_run;
583 process_module_hooks('need-run',\$modules_need_run);
585 # if no build required do nothing
586 if ($last_status && !@filtered_files && !$modules_need_run)
589 "No build required: last status = ",scalar(gmtime($last_status)),
590 " GMT, current snapshot = ",scalar(gmtime($current_snap))," GMT,",
591 " changed files = ",scalar(@filtered_files),"\n"
597 # get version info on both changed files sets
598 # XXX modules support?
600 $scm->get_versions(\@changed_files);
601 $scm->get_versions(\@changed_since_success);
603 } # end of unless ($from_source)
607 writelog('SCM-checkout',$savescmlog) unless $from_source;
608 $scm->log_id() unless $from_source;
610 # copy/create according to vpath/scm settings
614 print time_str(),"creating vpath build dir $exim ...\n" if $verbose;
615 mkdir $exim || die "making $exim: $!";
617 elsif (!$from_source && $scm->copy_source_required())
619 print time_str(),"copying source to $exim ...\n" if $verbose;
621 $scm->copy_source($using_msvc);
624 process_module_hooks('setup-target');
628 set_last('status',$now) unless $nostatus;
629 set_last('run.snap',$current_snap) unless $nostatus;
631 my $started_times = 0;
632 print time_str(),"running configure ...\n" if $verbose;
634 # each of these routines will call send_result, which calls exit,
635 # on any error, so each step depends on success in the previous
643 make_test() if (check_optional_step('make_test'));
645 make_doc() if (check_optional_step('build_docs'));
647 ##check_port_is_ok($buildport,'Post');
649 # if we get here everything went fine ...
651 my $saved_config = get_config_summary();
653 rmtree("inst"); # only keep failures
654 rmtree("$exim") unless ($from_source || $keepall);
656 print(time_str(),"OK\n") if $verbose;
662 ############## end of main program ###########################
667 usage: $0 [options] [branch]
669 where options are one or more of:
671 --nosend = don't send results
672 --nostatus = don't set status files
673 --force = force a build run (ignore status files)
674 --from-source=/path = use source in path, not from SCM
676 --from-source-clean=/path = same as --from-source, run make distclean first
677 --config=/path/to/file = alternative location for config file
678 --keepall = keep directories if an error occurs
679 --verbose[=n] = verbosity (default 1) 2 or more = huge output.
680 --quiet = suppress normal error message
681 --test = short for --nosend --nostatus --verbose --force
682 --skip-steps=list = skip certain steps
683 --only-steps=list = only do certain steps, not allowed with skip-steps
685 Default branch is HEAD. Usually only the --config option should be necessary.
693 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
694 return sprintf("[%.2d:%.2d:%.2d] ",$hour, $min, $sec);
700 return $only_steps{$step} if $only_steps;
701 return !$skip_steps{$step} if $skip_steps;
702 return 1; # default is everything is wanted
705 sub register_module_hooks
709 while (my ($hook,$func) = each %$what)
711 $module_hooks{$hook} ||= [];
712 push(@{$module_hooks{$hook}},[$func,$who]);
716 sub process_module_hooks
720 # pass remaining args (if any) to module func
721 foreach my $module (@{$module_hooks{$hook}})
723 my ($func,$module_instance) = @$module;
724 &$func($module_instance, @_);
728 sub check_optional_step
734 return undef unless ref($oconf = $optional_steps->{$step});
735 if ($oconf->{branches})
737 return undef unless grep {$_ eq $branch} @{$oconf->{branches}};
740 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
741 return undef if (exists $oconf->{min_hour} && $hour < $oconf->{min_hour});
742 return undef if (exists $oconf->{max_hour} && $hour > $oconf->{max_hour});
743 return undef if (exists $oconf->{dow}
744 &&grep {$_ eq $wday} @{$oconf->{dow}});
746 my $last_step = $last_status = find_last("$step") || 0;
748 return undef unless ($forcerun ||
749 time >$last_step + (3600 * $oconf->{min_hours_since}));
750 set_last("$step") unless $nostatus;
755 sub clean_from_source
757 if (-e "$exim/GNUmakefile")
761 my @makeout = `cd $exim && $make distclean 2>&1`;
763 writelog('distclean',\@makeout);
764 print "======== distclean log ===========\n",@makeout if ($verbose > 1);
765 send_result('distclean',$status,\@makeout) if $status;
772 print "Exiting on signal $signame\n";
778 my $lrname = $st_prefix . $logdirname;
780 mkdir "$lrname" || die "can't make $lrname dir: $!";
786 my $loglines = shift;
788 my $lrname = $st_prefix . $logdirname;
789 open($handle,">$lrname/$stage.log") || die $!;
790 print $handle @$loglines;
797 src/build-*/exim -C test/confs/0000 -bV `;
799 writelog('features',\@out);
800 print "======== features log ===========\n",@out if ($verbose > 1);
801 send_result('Features',$status,\@out) if $status;
802 $steps_completed .= " Features";
807 my @out = `$make -v 2>&1`;
808 return undef unless ($? == 0 && grep {/GNU Make/} @out);
814 return unless step_wanted('make');
815 print time_str(),"running make ...\n" if $verbose;
816 my $make_args = join(' ',$EximBuild::conf{make_args});
818 my $make_cmd = $make;
819 $make_cmd = "$make -j $make_jobs"
820 if ($make_jobs > 1 && ($branch eq 'HEAD' || $branch ge 'REL9_1'));
821 @makeout = `cd $exim/src && $make_cmd $make_args 2>&1`;
823 writelog('make',\@makeout);
824 print "======== make log ===========\n",@makeout if ($verbose > 1);
825 send_result('Make',$status,\@makeout) if $status;
826 $steps_completed .= " Make";
831 return unless step_wanted('make-doc');
832 print time_str(),"running make doc ...\n" if $verbose;
835 @makeout = `cd $exim/doc/doc-docbook/ && \
836 EXIM_VER="4.82" $make everything 2>&1`;
838 writelog('make-doc',\@makeout);
839 print "======== make doc log ===========\n",@makeout if ($verbose > 1);
840 send_result('Doc',$status,\@makeout) if $status;
841 $steps_completed .= " Doc";
849 # no core = no result
850 my @cores = glob("$pgdata/$core_file_glob");
851 return () unless @cores;
854 system "gdb --version > $devnull 2>&1";
856 return () if $status;
858 my $cmdfile = "./gdbcmd";
860 open($handle, ">$cmdfile");
861 print $handle "bt\n";
866 foreach my $core (@cores)
868 my @onetrace = `gdb -x $cmdfile --batch $bindir/exim $core 2>&1`;
870 "\n\n================== stack trace: $core ==================\n",
879 sub make_install_check
882 return unless step_wanted('install-check');
883 print time_str(),"running make installcheck ($locale)...\n" if $verbose;
888 @checklog = `cd $exim/src/test/regress && $make installcheck 2>&1`;
892 chdir "$exim/src/tools/msvc";
893 @checklog = `perl vcregress.pl installcheck 2>&1`;
898 ("$exim/src/test/regress/regression.diffs","$installdir/logfile");
899 foreach my $logfile(@logfiles)
901 next unless (-e $logfile );
902 push(@checklog,"\n\n================== $logfile ==================\n");
904 open($handle,$logfile);
914 get_stack_trace("$installdir/bin","$installdir/data-$locale");
915 push(@checklog,@trace);
917 writelog("install-check-$locale",\@checklog);
918 print "======== make installcheck log ===========\n",@checklog
920 send_result("InstallCheck-$locale",$status,\@checklog) if $status;
921 $steps_completed .= " InstallCheck-$locale";
924 sub make_isolation_check
927 return unless step_wanted('isolation-check');
932 "cd $exim/src/test/isolation && $make NO_LOCALE=1 installcheck";
933 @makeout = `$cmd 2>&1`;
937 chdir "$exim/src/tools/msvc";
938 @makeout = `perl vcregress.pl isolationcheck 2>&1`;
944 # get the log files and the regression diffs
945 my @logs = glob("$exim/src/test/isolation/log/*.log");
946 push(@logs,"$installdir/logfile");
947 unshift(@logs,"$exim/src/test/isolation/regression.diffs")
948 if (-e "$exim/src/test/isolation/regression.diffs");
949 foreach my $logfile (@logs)
951 push(@makeout,"\n\n================== $logfile ===================\n");
953 open($handle,$logfile);
963 get_stack_trace("$installdir/bin","$installdir/data-$locale");
964 push(@makeout,@trace);
966 writelog('isolation-check',\@makeout);
967 print "======== make isolation check logs ===========\n",@makeout
970 send_result('IsolationCheck',$status,\@makeout) if $status;
971 $steps_completed .= " IsolationCheck";
976 return unless step_wanted('test');
977 print time_str(),"running make test ...\n" if $verbose;
978 my $tests_range = $EximBuild::conf{range_num_tests} || "1 4";
980 @makeout =`(cd $exim/test
981 autoconf && ./configure && $make )2>&1 `;
985 my @tmp = `(WORKDIR=\$PWD
987 ./runtest \$WORKDIR/$exim/src/build-*/exim -CONTINUE $tests_range )2>&1`;
991 writelog('test',\@makeout);
992 print "======== make test logs ===========\n",@makeout
995 send_result('Test',$status,\@makeout) if $status;
996 $steps_completed .= " Test";
1001 return unless step_wanted('ecpg-check');
1003 my $ecpg_dir = "$exim/src/interfaces/ecpg";
1006 chdir "$exim/src/tools/msvc";
1007 @makeout = `perl vcregress.pl ecpgcheck 2>&1`;
1012 @makeout = `cd $ecpg_dir && $make NO_LOCALE=1 check 2>&1`;
1014 my $status = $? >>8;
1016 # get the log files and the regression diffs
1017 my @logs = glob("$ecpg_dir/test/log/*.log");
1018 unshift(@logs,"$ecpg_dir/test/regression.diffs")
1019 if (-e "$ecpg_dir/test/regression.diffs");
1020 foreach my $logfile (@logs)
1022 push(@makeout,"\n\n================== $logfile ===================\n");
1024 open($handle,$logfile);
1033 my $base = "$ecpg_dir/test/regress/tmp_check";
1035 get_stack_trace("$base/install$installdir/bin", "$base/data");
1036 push(@makeout,@trace);
1038 writelog('ecpg-check',\@makeout);
1039 print "======== make ecpg check logs ===========\n",@makeout
1042 send_result('ECPG-Check',$status,\@makeout) if $status;
1043 $steps_completed .= " ECPG-Check";
1050 foreach my $c_opt (@$config_opts)
1052 if ($c_opt =~ /['"]/)
1054 push(@quoted_opts,$c_opt);
1058 push(@quoted_opts,"'$c_opt'");
1062 my $env = $EximBuild::conf{makefile_set};
1063 my $add = $EximBuild::conf{makefile_add};
1064 my $features = $EximBuild::conf{config_features};
1067 while (my ($key,$val) = each %$env)
1069 $envstr .= "$key='$val'\n";
1071 while (my ($key,$val) = each %$add)
1073 $envstr .= "$key+='$val'\n";
1076 my $conf_path = "src/src/EDITME";
1077 my $local_conf = "src/Local/Makefile";
1078 my @confout = `cd $exim; mkdir -p src/Local 2>&1`;
1079 my @tmp = `cd $exim && cp $conf_path $local_conf 2>&1`;
1080 my $status = $? >> 8;
1081 push @confout, @tmp;
1084 # First, let's display some directory permissions in case
1085 # permissions are causing problems.
1086 my @dir = split('/',`pwd`);
1088 my $count = scalar @dir;
1091 while ($loop < $count)
1094 foreach my $i (0 .. $loop)
1096 $dir .= $dir[$i].'/';
1101 @tmp = `echo "Verify Directory Permissions"
1103 push @confout, @tmp;
1104 # Build the config file from the EDITME template
1105 @tmp = `cd $exim && echo '$envstr' >> $local_conf`;
1106 push @confout, @tmp;
1107 my $exim_user = $EximBuild::conf{master_exim_user} || 'exim';
1108 @tmp = `echo "Hardcoded Exim user info:"; id $exim_user
1109 cd $exim && perl -pi -e 's/^EXIM_USER=.*/EXIM_USER=$exim_user/' $local_conf`;
1110 push @confout, @tmp;
1111 my $me = `whoami`; chomp $me;
1112 @tmp = `echo "Build Farm user info:"; id $me
1113 cd $exim && perl -pi -e 's/^# CONFIGURE_OWNER=\$/CONFIGURE_OWNER=$me/' $local_conf`;
1114 push @confout, @tmp;
1115 @tmp = `cd $exim && perl -pi -e 's/^# TRUSTED_CONFIG_LIST=/TRUSTED_CONFIG_LIST=/' $local_conf`;
1116 push @confout, @tmp;
1117 @tmp = `cd $exim && perl -pi -e 's/^# WHITELIST_D_MACROS=.*/WHITELIST_D_MACROS=DIR:EXIM_PATH:AA:ACL:ACLRCPT:ACL_MAIL:ACL_PREDATA:ACL_RCPT:AFFIX:ALLOW:ARG1:ARG2:AUTHF:AUTHS:AUTH_ID_DOMAIN:BAD:BANNER:BB:BR:BRB:CERT:COM:COMMAND_USER:CONNECTCOND:CONTROL:CREQCIP:CREQMAC:CRL:CSS:D6:DATA:DCF:DDF:DEFAULTDWC:DELAY:DETAILS:DRATELIMIT:DYNAMIC_OPTION:ELI:ERROR_DETAILS:ERT:FAKE:FALLBACK:FILTER:FILTER_PREPEND_HOME:FORBID:FORBID_SMTP_CODE:FUSER:HAI:HAP:HARDLIMIT:HEADER_LINE_MAXSIZE:HEADER_MAXSIZE:HELO_MSG:HL:HOSTS:HOSTS_AVOID_TLS:HOSTS_MAX_TRY:HVH:IFACE:IGNORE_QUOTA:INC:INSERT:IP1:IP2:LAST:LDAPSERVERS:LENCHECK:LIMIT:LIST:LOG_SELECTOR:LS:MAXNM:MESSAGE_LOGS:MSIZE:NOTDAEMON:ONCE:ONLY:OPT:OPTION:ORDER:PAH:PEX:PORT:PTBC:QDG:QOLL:QUOTA:QUOTA_FILECOUNT:QWM:RCPT_MSG:REMEMBER:REQUIRE:RETRY:RETRY1:RETRY2:RETURN:RETURN_ERROR_DETAILS:REWRITE:ROUTE_DATA:RRATELIMIT:RT:S:SELECTOR:SELF:SERVER:SERVERS:SREQCIP:SREQMAC:SRV:STD:STRICT:SUB:SUBMISSION_OPTIONS:TIMEOUTDEFER:TIMES:TRUSTED:TRYCLEAR:UL:USE_SENDER:UTF8:VALUE:WMF:X:Y/' $local_conf`;
1118 push @confout, @tmp;
1119 @tmp = `cd $exim && perl -pi -e 's/^EXIM_MONITOR=(.*)/# EXIM_MONITOR=\$1/' $local_conf`;
1120 push @confout, @tmp;
1121 for my $feature ( @$features )
1124 perl -pi -e '$feature' $local_conf 2>&1
1125 echo "Changed feature: $feature" `;
1126 push @confout, @tmp;
1128 # Add the final build file to the display output
1131 echo "Contents of Local/Makefile:"
1132 egrep '^[^#]' $local_conf `;
1133 push @confout, @tmp;
1134 # Does not matter what the Exim version is, as long as it is valid.
1135 my $exim_ver = $EximBuild::conf{exim_test_version} || '4.82';
1137 echo 'EXIM_RELEASE_VERSION="$exim_ver"' > src/src/version.sh
1138 echo 'EXIM_VARIANT_VERSION=""' >> src/src/version.sh
1139 echo 'EXIM_COMPILE_NUMBER="0"' >> src/src/version.sh`;
1142 print "======== configure output ===========\n",@confout
1145 writelog('configure',\@confout);
1149 send_result('Configure',$status,\@confout);
1152 $steps_completed .= " Configure";
1158 my $stname = $st_prefix . "last.$which";
1160 open($handle,$stname) or return undef;
1161 my $time = <$handle>;
1170 my $stname = $st_prefix . "last.$which";
1171 my $st_now = shift || time;
1173 open($handle,">$stname") or die "opening $stname: $!";
1174 print $handle "$st_now\n";
1181 # clean up temp file
1186 my $ts = $now || time;
1187 my $status=shift || 0;
1188 my $log = shift || [];
1189 print "======== log passed to send_result ===========\n",@$log
1193 "Last file mtime in snapshot: ",
1194 scalar(gmtime($current_snap)),
1195 " GMT\n","===================================================\n")
1196 unless ($from_source || !$current_snap);
1198 my $log_data = join("",@$log);
1200 my $changed_this_run = "";
1201 my $changed_since_success = "";
1202 $changed_this_run = join("!",@changed_files)
1204 $changed_since_success = join("!",@changed_since_success)
1205 if ($stage ne 'OK' && @changed_since_success);
1209 $confsum= $saved_config;
1211 elsif ($stage !~ /CVS|Git|SCM/ )
1213 $confsum = get_config_summary();
1217 $confsum = get_script_config_dump();
1220 my $savedata = Data::Dumper->Dump(
1222 $changed_this_run, $changed_since_success, $branch, $status,$stage,
1223 $animal, $ts,$log_data, $confsum, $target, $verbose, $secret
1226 qw(changed_this_run changed_since_success branch status stage
1227 animal ts log_data confsum target verbose secret)
1231 my $lrname = $st_prefix . $logdirname;
1233 # might happen if there is a CVS failure and have never got further
1234 mkdir $lrname unless -d $lrname;
1236 my $txfname = "$lrname/web-txn.data";
1238 open($txdhandle,">$txfname");
1239 print $txdhandle $savedata;
1242 if ($nosend || $stage eq 'CVS' || $stage eq 'CVS-status' )
1244 print "Branch: $branch\n";
1247 print "All stages succeeded\n";
1248 set_last('success.snap',$current_snap) unless $nostatus;
1253 print "Stage $stage failed with status $status\n";
1258 if ($stage !~ /CVS|Git|SCM|Pre-run-port-check/ )
1261 my @logfiles = glob("$lrname/*.log");
1262 my %mtimes = map { $_ => (stat $_)[9] } @logfiles;
1264 map { basename $_ }( sort { $mtimes{$a} <=> $mtimes{$b} } @logfiles );
1265 my $logfiles = join(' ',@logfiles);
1266 $tar_log_cmd =~ s/\*\.log/$logfiles/;
1268 system("$tar_log_cmd 2>&1 ");
1269 chdir($branch_root);
1275 # these would be from an earlier run, since we
1276 # do cleanlogs() after the cvs stage
1277 # so don't send them.
1278 unlink "$lrname/runlogs.tgz";
1283 # this should now only apply to older Msys installs. All others should
1284 # be running with perl >= 5.8 since that's required to build exim
1286 if (!$^V or $^V lt v5.8.0)
1289 unless (-x "$aux_path/run_web_txn.pl")
1291 print "Could not locate $aux_path/run_web_txn.pl\n";
1295 system("$aux_path/run_web_txn.pl $lrname");
1296 $txstatus = $? >> 8;
1300 $txstatus = EximBuild::WebTxn::run_web_txn($lrname) ? 0 : 1;
1306 print "Web txn failed with status: $txstatus\n";
1308 # if the web txn fails, restore the timestamps
1309 # so we try again the next time.
1310 set_last('status',$last_status) unless $nostatus;
1311 set_last('run.snap',$last_run_snap) unless $nostatus;
1315 unless ($stage eq 'OK' || $quiet)
1317 print "BuildFarm member $animal failed on $branch stage $stage\n";
1320 # print "Success!\n",$response->content
1321 # if $print_success;
1323 set_last('success.snap',$current_snap) if ($stage eq 'OK' && !$nostatus);
1328 sub get_config_summary
1332 # unless ($using_msvc)
1334 # open($handle,"$exim/config.log") || return undef;
1335 # my $start = undef;
1338 # if (!$start && /created by PostgreSQL configure/)
1341 # s/It was/This file was/;
1343 # next unless $start;
1344 # last if /Core tests/;
1346 # next if /= <?unknown>?/;
1348 # # split up long configure line
1349 # if (m!\$.*configure.*--with! && length > 70)
1351 # my $pos = index($_," ",70);
1352 # substr($_,$pos+1,0,"\\\n ") if ($pos > 0);
1353 # $pos = index($_," ",140);
1354 # substr($_,$pos+1,0,"\\\n ") if ($pos > 0);
1355 # $pos = index($_," ",210);
1356 # substr($_,$pos+1,0,"\\\n ") if ($pos > 0);
1362 # "\n========================================================\n";
1364 $config .= get_script_config_dump();
1368 sub get_script_config_dump
1371 %EximBuild::conf, # shallow copy
1372 script_version => $VERSION,
1373 invocation_args => \@invocation_args,
1374 steps_completed => $steps_completed,
1375 orig_env => $orig_env,
1377 delete $conf->{secret};
1378 return Data::Dumper->Dump([$conf],['Script_Config']);
1383 my $wait_time = shift;
1384 my $who_to_kill = getpgrp(0);
1387 print "waiting $wait_time secs to time out process $who_to_kill\n"
1389 foreach my $sig (qw(INT TERM HUP QUIT))
1391 $SIG{$sig}='DEFAULT';
1394 $SIG{TERM} = 'IGNORE'; # so we don't kill ourself, we're exiting anyway
1395 # kill the whole process group
1396 unless (kill $sig,$who_to_kill)
1398 print "scm timeout kill failed\n";
1404 my $coderef = shift;
1406 if (defined($pid) && $pid == 0)