2003-10-14 02:11:16 +04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# vim:sw=4:et:ts=4:ai:
|
|
|
|
|
|
|
|
use strict;
|
2005-01-20 01:46:59 +03:00
|
|
|
use Cwd;
|
2003-10-14 02:11:16 +04:00
|
|
|
|
|
|
|
sub PrintUsage() {
|
|
|
|
die <<END_USAGE
|
|
|
|
usage: $0 [options]
|
|
|
|
Options:
|
|
|
|
--example-config Instead of running, print an example
|
|
|
|
'multi-config.pl' to help get started.
|
|
|
|
END_USAGE
|
|
|
|
}
|
|
|
|
|
|
|
|
sub PrintExample() {
|
|
|
|
print <<END_EXAMPLE
|
|
|
|
# multi-config.pl
|
|
|
|
\$BuildSleep = 10; # minutes
|
2005-06-11 02:58:13 +04:00
|
|
|
\$Tinderboxes = [
|
|
|
|
{ tree => "SeaMonkey", args => "--depend --mozconfig mozconfig" },
|
|
|
|
{ tree => "SeaMonkey-Branch", args => "--depend --mozconfig mozconfig" },
|
|
|
|
];
|
2003-10-14 02:11:16 +04:00
|
|
|
END_EXAMPLE
|
|
|
|
;
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub HandleArgs() {
|
|
|
|
return if ($#ARGV == -1);
|
|
|
|
PrintUsage() if ($#ARGV != 0 || $ARGV[0] ne "--example-config");
|
|
|
|
PrintExample();
|
|
|
|
}
|
|
|
|
|
|
|
|
sub LoadConfig() {
|
|
|
|
if (-r 'multi-config.pl') {
|
|
|
|
no strict 'vars';
|
|
|
|
|
|
|
|
open CONFIG, 'multi-config.pl' or
|
|
|
|
print "can't open multi-config.pl, $?\n";
|
|
|
|
|
2005-06-11 02:55:31 +04:00
|
|
|
local $/ = undef;
|
|
|
|
my $config = <CONFIG>;
|
2003-10-14 02:11:16 +04:00
|
|
|
close CONFIG;
|
2005-06-11 02:55:31 +04:00
|
|
|
|
|
|
|
package Settings;
|
2005-12-21 05:27:47 +03:00
|
|
|
eval $config or
|
|
|
|
die "Malformed multi-config.pl: $@\n";
|
2005-06-11 02:55:31 +04:00
|
|
|
|
2003-10-14 02:11:16 +04:00
|
|
|
} else {
|
|
|
|
warn "Error: Need tinderbox config file, multi-config.pl\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub Run() {
|
2004-03-24 04:53:10 +03:00
|
|
|
my $start_time = time();
|
2005-01-20 01:20:27 +03:00
|
|
|
OUTER: while (1) {
|
2003-10-14 02:11:16 +04:00
|
|
|
foreach my $treeentry (@{$Settings::Tinderboxes}) {
|
2005-08-18 07:40:18 +04:00
|
|
|
my $multidir = getcwd();
|
2003-10-14 02:11:16 +04:00
|
|
|
chdir($treeentry->{tree}) or
|
|
|
|
die "Tree $treeentry->{tree} does not exist";
|
|
|
|
system("./build-seamonkey.pl --once $treeentry->{args}");
|
2005-01-20 01:46:59 +03:00
|
|
|
chdir($multidir);
|
2005-01-20 01:20:27 +03:00
|
|
|
|
2005-08-18 07:40:18 +04:00
|
|
|
# We sleep 15 seconds to open up a window for stopping a build.
|
|
|
|
sleep 15;
|
2005-01-20 01:20:27 +03:00
|
|
|
|
2005-08-18 07:40:18 +04:00
|
|
|
# Provide a fall-over technique that stops the multi-tinderbox
|
|
|
|
# script once the current build cycle has completed.
|
|
|
|
if ( -e "fall-over" ) {
|
|
|
|
system("mv fall-over fall-over.$$.done");
|
|
|
|
last OUTER;
|
|
|
|
}
|
2003-10-14 02:11:16 +04:00
|
|
|
}
|
2004-03-24 04:53:10 +03:00
|
|
|
|
2005-08-18 07:36:55 +04:00
|
|
|
# $BuildSleep is the minimum amount of time a build is allowed to take.
|
|
|
|
# It prevents sending too many messages to the tinderbox server when
|
|
|
|
# something is broken.
|
2004-03-24 04:53:10 +03:00
|
|
|
my $sleep_time = ($Settings::BuildSleep * 60) - (time() - $start_time);
|
|
|
|
if ($sleep_time > 0) {
|
|
|
|
print "\n\nSleeping $sleep_time seconds ...\n";
|
|
|
|
sleep $sleep_time;
|
|
|
|
}
|
|
|
|
$start_time = time();
|
2003-10-14 02:11:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HandleArgs();
|
|
|
|
LoadConfig();
|
|
|
|
Run();
|