5 Copyright (c) 2003-2010, Andrew Dunstan
7 See accompanying License file for license details
11 ####################################################
15 NAME: run_build - script to run exim buildfarm
19 run_build [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 our $VERSION = 'REL_0.1';
40 use Fcntl qw(:flock :seek);
48 use POSIX qw(:signal_h strftime);
50 use Cwd qw(abs_path getcwd);
53 # save a copy of the original enviroment for reporting
54 # save it early to reduce the risk of prior mangling
55 use vars qw($orig_env);
60 while (my ($k,$v) = each %ENV)
63 # report all the keys but only values for whitelisted settings
64 # this is to stop leaking of things like passwords
67 $k =~ /^PG(?!PASSWORD)|MAKE|CC|CPP|FLAG|LIBRAR|INCLUDE/
68 ||$k =~/^(HOME|LOGNAME|USER|PATH|SHELL)$/
77 use EximBuild::Options;
78 use EximBuild::WebTxn;
80 if ($0 =~ /(.*)\.pl$/) {
81 die "$0: Please use `@{[join ' ' => $1, @ARGV]}' instead.\n"
86 die "$0: please use an umask of 022\n"
90 my $orig_dir = getcwd();
95 # make sure we exit nicely on any normal interrupt
96 # so the cleanup handler gets called.
97 # that lets us stop the db if it's running and
98 # remove the inst and exim directories
99 # so the next run can start clean.
101 foreach my $sig (qw(INT TERM HUP QUIT))
103 $SIG{$sig}=\&interrupt_exit;
106 # copy command line before processing - so we can later report it
109 my @invocation_args = (@ARGV);
111 # process the command line
112 EximBuild::Options::fetch_options();
114 die "only one of --from-source and --from-source-clean allowed"
115 if ($from_source && $from_source_clean);
117 die "only one of --skip-steps and --only-steps allowed"
118 if ($skip_steps && $only_steps);
120 $verbose=1 if (defined($verbose) && $verbose==0);
121 $verbose ||= 0; # stop complaints about undefined var in numeric comparison
125 $verbose=1 unless $verbose;
132 use vars qw(%skip_steps %only_steps);
134 if ($skip_steps =~ /\S/)
136 %skip_steps = map {$_ => 1} split(/\s+/,$skip_steps);
139 if ($only_steps =~ /\S/)
141 %only_steps = map {$_ => 1} split(/(\s+|[:,])/,$only_steps);
144 # Currently only specifying a branch is actually used.
145 # Specifying a different repo is just a wishlist item .
146 use vars qw($branch $repo);
147 my ($arg1,$arg2) = (shift,shift);
148 $branch = $arg2 ? $arg2 :
151 $repo = $arg2 ? $arg1 : 'exim';
152 my $explicit_branch = $branch;
154 print_help() if ($help);
157 # process config file
161 #die Dumper \%EximBuild::conf;
164 # Does not seem to be necessary
165 #die "$0: permissions on '$EximBuild::conf{build_root}' should be >= 0775\n"
166 # if -d $EximBuild::conf{build_root}
167 # and ((stat $EximBuild::conf{build_root})[2] & 0775) != 0775;
170 # get the config data into some local variables
172 $buildroot,$target,$animal, $print_success,
173 $aux_path,$trigger_exclude,$trigger_include,$secret,
174 $keep_errs,$force_every, $make, $optional_steps,
175 $use_vpath,$tar_log_cmd, $using_msvc, $extra_config,
176 $make_jobs, $core_file_glob
179 qw(build_root target animal print_success aux_path trigger_exclude
180 trigger_include secret keep_error_builds force_every make optional_steps
181 use_vpath tar_log_cmd using_msvc extra_config make_jobs core_file_glob)
184 #default is no parallel build
187 # default core file pattern is Linux, which used to be hardcoded
188 $core_file_glob ||= 'core*';
191 if (defined($EximBuild::conf{trigger_filter}))
193 $trigger_exclude = $EximBuild::conf{trigger_filter};
196 my $scm_timeout_secs = $EximBuild::conf{scm_timeout_secs}
197 || $EximBuild::conf{cvs_timeout_secs};
199 print scalar(localtime()),": buildfarm run for $animal:$branch starting\n"
202 # Allow commandline overrides of conf variables
203 foreach my $arg ( @{$EximBuild::Options::overrides} )
205 if (my ($key,$val) = split '=', $arg)
207 $EximBuild::conf{$key} = $val;
208 printf "Commandline override: '$key' = '%s'\n", $EximBuild::conf{$key}
213 if (ref($force_every) eq 'HASH')
215 $force_every = $force_every->{$branch} || $force_every->{default};
218 my $scm = new EximBuild::SCM \%EximBuild::conf;
222 if (exists $EximBuild::conf{base_port})
224 $buildport = $EximBuild::conf{base_port};
225 if ($branch =~ /REL(\d+)_(\d+)/)
227 $buildport += (10 * ($1 - 7)) + $2;
233 # support for legacy config style
234 $buildport = $EximBuild::conf{branch_ports}->{$branch} || 5999;
237 $ENV{EXTRA_REGRESS_OPTS} = "--port=$buildport";
239 $tar_log_cmd ||= "tar -z -cf runlogs.tgz *.log";
241 my $logdirname = "lastrun-logs";
243 if ($from_source || $from_source_clean)
245 $from_source ||= $from_source_clean;
246 die "sourceroot $from_source not absolute"
247 unless $from_source =~ m!^/!;
249 # we need to know where the lock should go, so unless the path
250 # contains HEAD we require it to be specified.
251 die "must specify branch explicitly with from_source"
252 unless ($explicit_branch || $from_source =~ m!/HEAD/!);
257 $logdirname = "fromsource-logs";
261 if ($branch eq 'HEAD' || $branch ge 'REL8_4')
264 # non-C locales are not regression-safe before 8.4
265 @locales = @{$EximBuild::conf{locales}} if exists $EximBuild::conf{locales};
267 unshift(@locales,'C') unless grep {$_ eq "C"} @locales;
270 # several people have run into these
272 if ( `uname -s 2>&1 ` =~ /CYGWIN/i )
274 my @procs = `ps -ef`;
275 die "cygserver not running" unless(grep {/cygserver/} @procs);
278 if ( $ccachedir = $EximBuild::conf{build_env}->{CCACHE_DIR} )
281 # ccache is smart enough to create what you tell it is the cache dir, but
282 # not smart enough to build the whole path. mkpath croaks on error, so
286 $ccachedir = abs_path($ccachedir);
291 die "no aux_path in config file" unless $aux_path;
294 die "cannot run as root/Administrator" unless ($using_msvc or $> > 0);
296 my $devnull = $using_msvc ? "nul" : "/dev/null";
300 $scm->check_access($using_msvc);
303 my $st_prefix = "$animal.";
305 my $exim = $from_source || $scm->get_build_path($use_vpath);
307 # set environment from config
308 while (my ($envkey,$envval) = each %{$EximBuild::conf{build_env}})
310 $ENV{$envkey}=$envval;
313 # change to buildroot for this branch or die
314 die "no buildroot" unless $buildroot;
316 unless ($buildroot =~ m!^/!
317 or($using_msvc and $buildroot =~ m![a-z]:[/\\]!i ))
319 die "buildroot $buildroot not absolute";
322 die "$buildroot does not exist or is not a directory" unless -d $buildroot;
324 chdir $buildroot || die "chdir to $buildroot: $!";
326 mkdir $branch unless -d $branch;
327 chdir $branch || die "chdir to $buildroot/$branch";
329 # rename legacy status files/directories
330 foreach my $oldfile (glob("last*"))
332 move $oldfile, "$st_prefix$oldfile";
335 my $branch_root = getcwd();
337 # Normally we would require GNU Make, but allow farm
338 # configuration to override this
339 die "$make is not GNU Make - please fix config file"
343 foreach my $module (@{$EximBuild::conf{modules}})
346 # fill in the name of the module here, so use double quotes
347 # so everything BUT the module name needs to be escaped
349 require EximBuild::Modules::$module;
350 EximBuild::Modules::${module}::setup(
367 open($lockfile, ">builder.LCK") || die "opening lockfile: $!";
369 # only one builder at a time allowed per branch
370 # having another build running is not a failure, and so we do not output
371 # a failure message under this condition.
374 die "acquiring lock in $buildroot/$branch/builder.LCK"
375 unless flock($lockfile,LOCK_EX|LOCK_NB);
377 elsif ( !flock($lockfile,LOCK_EX|LOCK_NB) )
379 print "Another process holds the lock on "
380 ."$buildroot/$branch/builder.LCK. Exiting."
385 die "$buildroot/$branch has $exim or inst directories!"
386 if ((!$from_source && -d $exim) || -d "inst");
388 # we are OK to run if we get here
391 # check if file present for forced run
392 my $forcefile = $st_prefix . "force-one-run";
399 # try to allow core files to be produced.
400 # another way would be for the calling environment
401 # to call ulimit. We do this in an eval so failure is
404 require BSD::Resource;
405 BSD::Resource->import();
407 # explicit sub calls here. using & keeps compiler happy
408 my $coreok = setrlimit(&RLIMIT_CORE,&RLIM_INFINITY,&RLIM_INFINITY);
409 die "setrlimit" unless $coreok;
411 warn "failed to unlimit core size: $@" if $@ && $verbose > 1;
413 # the time we take the snapshot
415 my $installdir = "$buildroot/$branch/inst";
420 # cleanup handler for all exits
425 unlink $ENV{TEMP_CONFIG} if $extraconf;
427 # if we have the lock we must already be in the build root, so
428 # removing things there should be safe.
429 # there should only be anything to cleanup if we didn't have
431 if ( $have_lock && -d "$exim")
436 system(qq{"bin/pg_ctl" -D data stop >$devnull 2>&1});
437 foreach my $loc (@locales)
439 next unless -d "data-$loc";
440 system(qq{"bin/pg_ctl" -D "data-$loc" stop >$devnull 2>&1});
444 if ( !$from_source && $keep_errs)
446 print "moving kept error trees\n" if $verbose;
447 my $timestr = strftime "%Y-%m-%d_%H-%M-%S", localtime($now);
448 unless (move("$exim", "eximkeep.$timestr"))
450 print "error renaming '$exim' to 'eximkeep.$timestr': $!";
454 unless(move("inst", "instkeep.$timestr"))
456 print "error renaming 'inst' to 'instkeep.$timestr': $!";
462 rmtree("inst") unless $keepall;
463 rmtree("$exim") unless ($from_source || $keepall);
466 # only keep the cache in cases of success
467 rmtree("$ccachedir") if $ccachedir;
470 # get the modules to clean up after themselves
471 process_module_hooks('cleanup');
478 # vpath builds leave some stuff lying around in the
479 # source dir, unfortunately. This should clean it up.
483 unlink("builder.LCK");
487 # Prepend the DEFAULT settings (if any) to any settings for the
488 # branch. Since we're mangling this, deep clone $extra_config
489 # so the config object is kept as given. This is done using
490 # Dumper() because the MSys DTK perl doesn't have Storable. This
491 # is less efficient but it hardly matters here for this shallow
494 $extra_config = eval Dumper($extra_config);
496 if ($extra_config && $extra_config->{DEFAULT})
498 if (!exists $extra_config->{$branch})
500 $extra_config->{$branch} = $extra_config->{DEFAULT};
504 unshift(@{$extra_config->{$branch}}, @{$extra_config->{DEFAULT}});
508 if ($extra_config && $extra_config->{$branch})
511 ($extraconf,$tmpname) =File::Temp::tempfile(
513 DIR => File::Spec->tmpdir(),
516 die 'no $tmpname!' unless $tmpname;
517 $ENV{TEMP_CONFIG} = $tmpname;
518 foreach my $line (@{$extra_config->{$branch}})
520 print $extraconf "$line\n";
522 autoflush $extraconf 1;
525 use vars qw($steps_completed);
526 $steps_completed = "";
529 my @changed_since_success;
533 my $last_success_snap;
539 if ($from_source_clean)
541 print time_str(),"cleaning source in $exim ...\n";
544 elsif (!$from_source)
547 # see if we need to run the tests (i.e. if either something has changed or
548 # we have gone over the force_every heartbeat time)
550 print time_str(),"checking out source ...\n" if $verbose;
554 $timeout_pid = spawn(\&scm_timeout,$scm_timeout_secs)
555 if $scm_timeout_secs;
557 $savescmlog = $scm->checkout($branch);
558 $steps_completed = "SCM-checkout";
560 process_module_hooks('checkout',$savescmlog);
565 # don't kill me, I finished in time
566 if (kill(SIGTERM, $timeout_pid))
570 waitpid($timeout_pid,0);
574 print time_str(),"checking if build run needed ...\n" if $verbose;
576 # transition to new time processing
577 unlink "last.success";
579 # get the timestamp data
580 $last_config = find_last('config') || 0;
581 $last_status = find_last('status') || 0;
582 $last_run_snap = find_last('run.snap');
583 $last_success_snap = find_last('success.snap');
584 $forcerun = 1 unless (defined($last_run_snap));
586 # If config file changed, force a rebuild
587 ($current_config) = (stat $orig_dir.'/'.$buildconf)[9];
588 if (defined $current_config && $current_config > $last_config)
591 set_last('config',$current_config) unless $nostatus;
594 # updated by find_changed to last mtime of any file in the repo
597 # see if we need to force a build
601 &&$last_status+($force_every*3600) < $now);
602 $last_status = 0 if $forcerun;
604 # see what's changed since the last time we did work
605 $scm->find_changed(\$current_snap,$last_run_snap, $last_success_snap,
606 \@changed_files,\@changed_since_success);
608 #ignore changes to files specified by the trigger exclude filter, if any
609 if (defined($trigger_exclude))
611 @filtered_files = grep { !m[$trigger_exclude] } @changed_files;
615 @filtered_files = @changed_files;
618 #ignore changes to files NOT specified by the trigger include filter, if any
619 if (defined($trigger_include))
621 @filtered_files = grep { m[$trigger_include] } @filtered_files;
624 my $modules_need_run;
626 process_module_hooks('need-run',\$modules_need_run);
628 # if no build required do nothing
629 if ($last_status && !@filtered_files && !$modules_need_run)
632 "No build required: last status = ",scalar(gmtime($last_status)),
633 " GMT, current snapshot = ",scalar(gmtime($current_snap))," GMT,",
634 " changed files = ",scalar(@filtered_files),"\n"
640 # get version info on both changed files sets
641 # XXX modules support?
643 $scm->get_versions(\@changed_files);
644 $scm->get_versions(\@changed_since_success);
646 } # end of unless ($from_source)
650 writelog('SCM-checkout',$savescmlog) unless $from_source;
651 $scm->log_id() unless $from_source;
653 # copy/create according to vpath/scm settings
657 print time_str(),"creating vpath build dir $exim ...\n" if $verbose;
658 mkdir $exim || die "making $exim: $!";
660 elsif (!$from_source && $scm->copy_source_required())
662 print time_str(),"copying source to $exim ...\n" if $verbose;
664 $scm->copy_source($using_msvc);
667 process_module_hooks('setup-target');
671 set_last('status',$now) unless $nostatus;
672 set_last('run.snap',$current_snap) unless $nostatus;
674 my $started_times = 0;
675 print time_str(),"running configure ...\n" if $verbose;
677 # each of these routines will call send_result, which calls exit,
678 # on any error, so each step depends on success in the previous
686 make_test() if (check_optional_step('test'));
688 make_doc() if (check_optional_step('make-doc'));
690 ##check_port_is_ok($buildport,'Post');
692 # if we get here everything went fine ...
694 my $saved_config = get_config_summary();
696 rmtree("inst"); # only keep failures
697 rmtree("$exim") unless ($from_source || $keepall);
699 print(time_str(),"OK\n") if $verbose;
705 ############## end of main program ###########################
710 usage: $0 [options] [branch]
712 where options are one or more of:
714 --nosend = don't send results
715 --nostatus = don't set status files
716 --force = force a build run (ignore status files)
717 --from-source=/path = use source in path, not from SCM
719 --from-source-clean=/path = same as --from-source, run make distclean first
720 --config=/path/to/file = alternative location for config file
721 --keepall = keep directories if an error occurs
722 --verbose[=n] = verbosity (default 1) 2 or more = huge output.
723 --quiet = suppress normal error message
724 --test = short for --nosend --nostatus --verbose --force
725 --skip-steps=list = skip certain steps
726 --only-steps=list = only do certain steps, not allowed with skip-steps
727 lists can be comma, colon, or space separated
729 Default branch is HEAD. Usually only the --config option should be necessary.
737 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
738 return sprintf("[%.2d:%.2d:%.2d] ",$hour, $min, $sec);
744 return $only_steps{$step} if $only_steps;
745 return !$skip_steps{$step} if $skip_steps;
746 return 1; # default is everything is wanted
749 sub register_module_hooks
753 while (my ($hook,$func) = each %$what)
755 $module_hooks{$hook} ||= [];
756 push(@{$module_hooks{$hook}},[$func,$who]);
760 sub process_module_hooks
764 # pass remaining args (if any) to module func
765 foreach my $module (@{$module_hooks{$hook}})
767 my ($func,$module_instance) = @$module;
768 &$func($module_instance, @_);
772 sub check_optional_step
778 return undef unless ref($oconf = $optional_steps->{$step});
779 if ($oconf->{branches})
781 return undef unless grep {$_ eq $branch} @{$oconf->{branches}};
784 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
785 return undef if (exists $oconf->{min_hour} && $hour < $oconf->{min_hour});
786 return undef if (exists $oconf->{max_hour} && $hour > $oconf->{max_hour});
787 return undef if (exists $oconf->{dow}
788 &&grep {$_ eq $wday} @{$oconf->{dow}});
790 my $last_step = $last_status = find_last("$step") || 0;
791 ## If made it *to* these optional steps, we just run them and reset last time
792 #return undef unless ($forcerun ||
793 # time >$last_step + (3600 * $oconf->{min_hours_since}));
794 set_last("$step") unless $nostatus;
799 sub clean_from_source
801 if (-e "$exim/GNUmakefile")
805 my @makeout = `cd $exim && $make distclean 2>&1`;
807 writelog('distclean',\@makeout);
808 print "======== distclean log ===========\n",@makeout if ($verbose > 1);
809 send_result('distclean',$status,\@makeout) if $status;
816 print "Exiting on signal $signame\n";
822 my $lrname = $st_prefix . $logdirname;
824 mkdir "$lrname" || die "can't make $lrname dir: $!";
830 my $loglines = shift;
832 my $lrname = $st_prefix . $logdirname;
833 open($handle,">$lrname/$stage.log") || die $!;
834 print $handle @$loglines;
840 return unless step_wanted('features');
842 src/build-*/exim -C test/confs/0000 -bV `;
844 writelog('features',\@out);
845 print "======== features log ===========\n",@out if ($verbose > 1);
846 send_result('Features',$status,\@out) if $status;
847 $steps_completed .= " Features";
852 # Allow farm member to configure non-GNU make
853 my $non_gnu_make = $EximBuild::conf{non_gnu_make};
854 if (!defined $non_gnu_make ||
855 (defined $non_gnu_make && $non_gnu_make == 1)) {
858 my @out = `$make -v 2>&1`;
859 return undef unless ($? == 0 && grep {/GNU Make/} @out);
865 return unless step_wanted('make');
866 print time_str(),"running make ...\n" if $verbose;
867 my $make_args = join(' ',$EximBuild::conf{make_args});
869 my $make_cmd = $make;
870 $make_cmd = "$make -j $make_jobs"
871 if ($make_jobs > 1 && ($branch eq 'HEAD' || $branch ge 'REL9_1'));
872 @makeout = `cd $exim/src && $make_cmd $make_args 2>&1`;
874 writelog('make',\@makeout);
875 print "======== make log ===========\n",@makeout if ($verbose > 1);
876 send_result('Make',$status,\@makeout) if $status;
877 $steps_completed .= " Make";
882 return unless step_wanted('make-doc');
883 print time_str(),"running make doc ...\n" if $verbose;
886 @makeout = `cd $exim/doc/doc-docbook/ && \
887 EXIM_VER="4.82" $make everything 2>&1`;
889 writelog('make-doc',\@makeout);
890 print "======== make doc log ===========\n",@makeout if ($verbose > 1);
891 send_result('Doc',$status,\@makeout) if $status;
892 $steps_completed .= " Doc";
900 # no core = no result
901 my @cores = glob("$pgdata/$core_file_glob");
902 return () unless @cores;
905 system "gdb --version > $devnull 2>&1";
907 return () if $status;
909 my $cmdfile = "./gdbcmd";
911 open($handle, ">$cmdfile");
912 print $handle "bt\n";
917 foreach my $core (@cores)
919 my @onetrace = `gdb -x $cmdfile --batch $bindir/exim $core 2>&1`;
921 "\n\n================== stack trace: $core ==================\n",
930 sub make_install_check
933 return unless step_wanted('install-check');
934 print time_str(),"running make installcheck ($locale)...\n" if $verbose;
939 @checklog = `cd $exim/src/test/regress && $make installcheck 2>&1`;
943 chdir "$exim/src/tools/msvc";
944 @checklog = `perl vcregress.pl installcheck 2>&1`;
949 ("$exim/src/test/regress/regression.diffs","$installdir/logfile");
950 foreach my $logfile(@logfiles)
952 next unless (-e $logfile );
953 push(@checklog,"\n\n================== $logfile ==================\n");
955 open($handle,$logfile);
965 get_stack_trace("$installdir/bin","$installdir/data-$locale");
966 push(@checklog,@trace);
968 writelog("install-check-$locale",\@checklog);
969 print "======== make installcheck log ===========\n",@checklog
971 send_result("InstallCheck-$locale",$status,\@checklog) if $status;
972 $steps_completed .= " InstallCheck-$locale";
975 sub make_isolation_check
978 return unless step_wanted('isolation-check');
983 "cd $exim/src/test/isolation && $make NO_LOCALE=1 installcheck";
984 @makeout = `$cmd 2>&1`;
988 chdir "$exim/src/tools/msvc";
989 @makeout = `perl vcregress.pl isolationcheck 2>&1`;
995 # get the log files and the regression diffs
996 my @logs = glob("$exim/src/test/isolation/log/*.log");
997 push(@logs,"$installdir/logfile");
998 unshift(@logs,"$exim/src/test/isolation/regression.diffs")
999 if (-e "$exim/src/test/isolation/regression.diffs");
1000 foreach my $logfile (@logs)
1002 push(@makeout,"\n\n================== $logfile ===================\n");
1004 open($handle,$logfile);
1014 get_stack_trace("$installdir/bin","$installdir/data-$locale");
1015 push(@makeout,@trace);
1017 writelog('isolation-check',\@makeout);
1018 print "======== make isolation check logs ===========\n",@makeout
1021 send_result('IsolationCheck',$status,\@makeout) if $status;
1022 $steps_completed .= " IsolationCheck";
1027 return unless step_wanted('test');
1028 print time_str(),"running make test ...\n" if $verbose;
1029 my $tests_range = $EximBuild::conf{range_num_tests} || "1 4";
1031 @makeout =`(cd $exim/test
1032 autoconf && ./configure && $make )2>&1 `;
1033 my $status = $? >>8;
1036 my @tmp = `(WORKDIR=\$PWD
1038 ./runtest \$WORKDIR/$exim/src/build-*/exim -CONTINUE $tests_range )2>&1`;
1040 push @makeout, @tmp;
1041 # Prepend the failed summary log outputs for ease of reading
1042 my $fail_summary = "$exim/test/failed-summary.log";
1043 if (-f $fail_summary)
1045 @tmp = `cat $fail_summary`;
1047 unshift @makeout, @tmp;
1048 unshift @makeout, "Summary of failed tests:\n";
1051 writelog('test',\@makeout);
1052 print "======== make test logs ===========\n",@makeout
1055 send_result('Test',$status,\@makeout) if $status;
1056 $steps_completed .= " Test";
1061 return unless step_wanted('ecpg-check');
1063 my $ecpg_dir = "$exim/src/interfaces/ecpg";
1066 chdir "$exim/src/tools/msvc";
1067 @makeout = `perl vcregress.pl ecpgcheck 2>&1`;
1072 @makeout = `cd $ecpg_dir && $make NO_LOCALE=1 check 2>&1`;
1074 my $status = $? >>8;
1076 # get the log files and the regression diffs
1077 my @logs = glob("$ecpg_dir/test/log/*.log");
1078 unshift(@logs,"$ecpg_dir/test/regression.diffs")
1079 if (-e "$ecpg_dir/test/regression.diffs");
1080 foreach my $logfile (@logs)
1082 push(@makeout,"\n\n================== $logfile ===================\n");
1084 open($handle,$logfile);
1093 my $base = "$ecpg_dir/test/regress/tmp_check";
1095 get_stack_trace("$base/install$installdir/bin", "$base/data");
1096 push(@makeout,@trace);
1098 writelog('ecpg-check',\@makeout);
1099 print "======== make ecpg check logs ===========\n",@makeout
1102 send_result('ECPG-Check',$status,\@makeout) if $status;
1103 $steps_completed .= " ECPG-Check";
1108 return unless step_wanted('configure');
1109 print time_str(),"creating configuration ...\n" if $verbose;
1111 my $env = $EximBuild::conf{makefile_set};
1112 my $add = $EximBuild::conf{makefile_add};
1113 my $features = $EximBuild::conf{makefile_regex};
1116 while (my ($key,$val) = each %$env)
1118 $envstr .= "$key='$val'\n";
1120 while (my ($key,$val) = each %$add)
1122 $envstr .= "$key+='$val'\n";
1125 my $conf_path = "src/src/EDITME";
1126 my $local_conf = "src/Local/Makefile";
1127 my @confout = `cd $exim; mkdir -p src/Local 2>&1`;
1128 my @tmp = `cd $exim && cp $conf_path $local_conf 2>&1`;
1129 my $status = $? >> 8;
1130 push @confout, @tmp;
1133 # First, let's display some directory permissions in case
1134 # permissions are causing problems.
1135 my @dir = split('/',`pwd`);
1137 my $count = scalar @dir;
1140 while ($loop < $count)
1143 foreach my $i (0 .. $loop)
1145 $dir .= $dir[$i].'/';
1150 @tmp = `echo "Verify Directory Permissions"
1152 push @confout, @tmp;
1153 # Build the config file from the EDITME template
1154 @tmp = `cd $exim && echo '$envstr' >> $local_conf`;
1155 push @confout, @tmp;
1156 my $exim_user = $EximBuild::conf{master_exim_user} || 'exim';
1157 @tmp = `echo "Hardcoded Exim user info:"; id $exim_user
1158 cd $exim && perl -pi -e 's/^EXIM_USER=.*/EXIM_USER=$exim_user/' $local_conf`;
1159 push @confout, @tmp;
1160 my $me = `whoami`; chomp $me;
1161 @tmp = `echo "Build Farm user info:"; id $me
1162 cd $exim && perl -pi -e 's/^# CONFIGURE_OWNER=\$/CONFIGURE_OWNER=$me/' $local_conf`;
1163 push @confout, @tmp;
1164 my $testdir = `cd $exim && /bin/pwd`; chomp $testdir; $testdir .= "/test";
1165 my $trcf = "$testdir/trusted-configs";
1166 my $tecf = "$testdir/test-config";
1167 @tmp = `cd $exim && perl -pi -e "s%^# TRUSTED_CONFIG_LIST=.*%TRUSTED_CONFIG_LIST=$trcf%" $local_conf`;
1168 push @confout, @tmp;
1169 @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`;
1170 push @confout, @tmp;
1171 @tmp = `cd $exim && perl -pi -e 's/^EXIM_MONITOR=(.*)/# EXIM_MONITOR=\$1/' $local_conf`;
1172 push @confout, @tmp;
1173 for my $regex ( @$features )
1176 perl -pi -e '$regex' $local_conf 2>&1
1177 echo "Used regex: $regex" `;
1178 push @confout, @tmp;
1180 # Add the final build file to the display output
1183 echo "Contents of Local/Makefile:"
1184 egrep '^[^#]' $local_conf `;
1185 push @confout, @tmp;
1186 # Build the config_opts array to send to the server
1188 my @config_opts = grep s/(?:LOOKUP_|EXPERIMENTAL_|USE_)(\S+)=.*/$1/,
1190 push @config_opts, grep s/^(?:EXIM_)(PERL|PYTHON)=.*/$1/,
1192 # OpenSSL doesn't have a specific USE flag
1193 push @config_opts, grep s/^(TLS_LIBS.*-l(ssl|crypto)).*/OPENSSL/,
1195 $EximBuild::conf{config_opts} = \@config_opts;
1197 # Does not matter what the Exim version is, as long as it is valid.
1198 my $exim_ver = $EximBuild::conf{exim_test_version} || '4.82';
1200 echo 'EXIM_RELEASE_VERSION="$exim_ver"' > src/src/version.sh
1201 echo 'EXIM_VARIANT_VERSION=""' >> src/src/version.sh
1202 echo 'EXIM_COMPILE_NUMBER="0"' >> src/src/version.sh`;
1204 # Create a trusted-configs list file
1205 @tmp = `cd $exim && echo "$tecf" > "$trcf"`;
1206 push @confout, @tmp;
1209 print "======== configure output ===========\n",@confout
1212 writelog('configure',\@confout);
1216 send_result('Configure',$status,\@confout);
1219 $steps_completed .= " Configure";
1225 my $stname = $st_prefix . "last.$which";
1227 open($handle,$stname) or return undef;
1228 my $time = <$handle>;
1237 my $stname = $st_prefix . "last.$which";
1238 my $st_now = shift || time;
1240 open($handle,">$stname") or die "opening $stname: $!";
1241 print $handle "$st_now\n";
1248 # clean up temp file
1253 my $ts = $now || time;
1254 my $status=shift || 0;
1255 my $log = shift || [];
1256 print "======== log passed to send_result ===========\n",@$log
1260 "Last file mtime in snapshot: ",
1261 scalar(gmtime($current_snap)),
1262 " GMT\n","===================================================\n")
1263 unless ($from_source || !$current_snap);
1265 my $log_data = join("",@$log);
1267 my $changed_this_run = "";
1268 my $changed_since_success = "";
1269 $changed_this_run = join("!",@changed_files)
1271 $changed_since_success = join("!",@changed_since_success)
1272 if ($stage ne 'OK' && @changed_since_success);
1276 $confsum= $saved_config;
1278 elsif ($stage !~ /CVS|Git|SCM/ )
1280 $confsum = get_config_summary();
1284 $confsum = get_script_config_dump();
1287 my $savedata = Data::Dumper->Dump(
1289 $changed_this_run, $changed_since_success, $branch, $status,$stage,
1290 $animal, $ts,$log_data, $confsum, $target, $verbose, $secret
1293 qw(changed_this_run changed_since_success branch status stage
1294 animal ts log_data confsum target verbose secret)
1298 my $lrname = $st_prefix . $logdirname;
1300 # might happen if there is a CVS failure and have never got further
1301 mkdir $lrname unless -d $lrname;
1303 my $txfname = "$lrname/web-txn.data";
1305 open($txdhandle,">$txfname");
1306 print $txdhandle $savedata;
1309 if ($nosend || $stage eq 'CVS' || $stage eq 'CVS-status' )
1311 print "Branch: $branch\n";
1314 print "All stages succeeded\n";
1315 set_last('success.snap',$current_snap) unless $nostatus;
1320 print "Stage $stage failed with status $status\n";
1325 if ($stage !~ /CVS|Git|SCM|Pre-run-port-check/ )
1328 my @logfiles = glob("$lrname/*.log");
1329 my %mtimes = map { $_ => (stat $_)[9] } @logfiles;
1331 map { basename $_ }( sort { $mtimes{$a} <=> $mtimes{$b} } @logfiles );
1332 my $logfiles = join(' ',@logfiles);
1333 $tar_log_cmd =~ s/\*\.log/$logfiles/;
1335 system("$tar_log_cmd 2>&1 ");
1336 chdir($branch_root);
1342 # these would be from an earlier run, since we
1343 # do cleanlogs() after the cvs stage
1344 # so don't send them.
1345 unlink "$lrname/runlogs.tgz";
1350 # this should now only apply to older Msys installs. All others should
1351 # be running with perl >= 5.8 since that's required to build exim
1353 if (!$^V or $^V lt v5.8.0)
1356 unless (-x "$aux_path/run_web_txn.pl")
1358 print "Could not locate $aux_path/run_web_txn.pl\n";
1362 system("$aux_path/run_web_txn.pl $lrname");
1363 $txstatus = $? >> 8;
1367 $txstatus = EximBuild::WebTxn::run_web_txn($lrname) ? 0 : 1;
1373 print "Web txn failed with status: $txstatus\n";
1375 # if the web txn fails, restore the timestamps
1376 # so we try again the next time.
1377 set_last('status',$last_status) unless $nostatus;
1378 set_last('run.snap',$last_run_snap) unless $nostatus;
1382 unless ($stage eq 'OK' || $quiet)
1384 print "BuildFarm member $animal failed on $branch stage $stage\n";
1387 # print "Success!\n",$response->content
1388 # if $print_success;
1390 set_last('success.snap',$current_snap) if ($stage eq 'OK' && !$nostatus);
1395 sub get_config_summary
1399 # unless ($using_msvc)
1401 # open($handle,"$exim/config.log") || return undef;
1402 # my $start = undef;
1405 # if (!$start && /created by PostgreSQL configure/)
1408 # s/It was/This file was/;
1410 # next unless $start;
1411 # last if /Core tests/;
1413 # next if /= <?unknown>?/;
1415 # # split up long configure line
1416 # if (m!\$.*configure.*--with! && length > 70)
1418 # my $pos = index($_," ",70);
1419 # substr($_,$pos+1,0,"\\\n ") if ($pos > 0);
1420 # $pos = index($_," ",140);
1421 # substr($_,$pos+1,0,"\\\n ") if ($pos > 0);
1422 # $pos = index($_," ",210);
1423 # substr($_,$pos+1,0,"\\\n ") if ($pos > 0);
1429 # "\n========================================================\n";
1431 $config .= get_script_config_dump();
1435 sub get_script_config_dump
1438 %EximBuild::conf, # shallow copy
1439 script_version => $VERSION,
1440 invocation_args => \@invocation_args,
1441 steps_completed => $steps_completed,
1442 orig_env => $orig_env,
1444 delete $conf->{secret};
1446 if ($conf->{scm} eq 'git') {
1447 chomp($conf->{farm}{revision} = `git -C $Bin describe --tags --always --dirty=+`);
1448 $conf->{farm}{cwd} = getcwd();
1449 $conf->{farm}{bindir} = $Bin;
1452 $Data::Dumper::Sortkeys = 1;
1453 return Data::Dumper->Dump([$conf],['Script_Config']);
1458 my $wait_time = shift;
1459 my $who_to_kill = getpgrp(0);
1462 print "waiting $wait_time secs to time out process $who_to_kill\n"
1464 foreach my $sig (qw(INT TERM HUP QUIT))
1466 $SIG{$sig}='DEFAULT';
1469 $SIG{TERM} = 'IGNORE'; # so we don't kill ourself, we're exiting anyway
1470 # kill the whole process group
1471 unless (kill $sig,$who_to_kill)
1473 print "scm timeout kill failed\n";
1479 my $coderef = shift;
1481 if (defined($pid) && $pid == 0)