-
Notifications
You must be signed in to change notification settings - Fork 70
/
buildbot_ready
54 lines (43 loc) · 1.12 KB
/
buildbot_ready
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl -w
use strict;
my $command = shift @ARGV;
my $perl = shift @ARGV;
my $syncfile = shift @ARGV;
if ($command eq 'quickstart') {
quickstart();
}
elsif ($command eq 'start') {
quickstart();
if ($syncfile)
{
# sleep until it disappears, or times out.
# on second thoughts, just sleep a little bit if it exists,
# don't wait for it to disappear entirely. this just gives us
# a little delay, to avoid overloading, without totally screwing
# up if a lockfile gets left lying around...
if (-f $syncfile && mtime_age_secs($syncfile) < 60*60) {
print "$syncfile exists with age ".mtime_age_secs($syncfile).", sleeping\n";
sleep 60*3 + rand(60*5);
}
open (TOUCH, ">$syncfile"); close TOUCH;
}
# ensure we're in a safe state to build
system ("$perl Makefile.PL < /dev/null");
system ("make distclean");
system ("rm -rf Mail-SpamAssassin*");
}
elsif ($command eq 'stop') {
if ($syncfile) {
unlink ($syncfile);
print "$syncfile removed\n";
}
}
exit;
sub mtime_age_secs {
my $f = shift;
my @s = stat($f);
return (time - $s[9]);
}
sub quickstart {
# TODO
}