3 # This script builds the nagiosplugins and then sends
4 # logs back to the master tinderbox server
6 # This script is based on mozilla-unix.pl which comes with tinderbox2
8 # See http://tinderbox.altinity.org for more details
17 my $Version = '$Revision$';
19 my $myhost = hostname
;
21 my ($host, $junk) = split(/\./, $myhost);
23 my $BuildAdministrator = $ENV{TINDERBOX_BUILD_ADMIN
} || "$ENV{'USER'}\@$myhost";
24 my $TmpDir = $ENV{TMPDIR
} || "/tmp";
26 #Default values of cmdline opts
27 my $ReportStatus = 0; # Do not send results to server
29 # Set these to what makes sense for your system
31 # Set these proper values for your tinderbox server
32 my $Tinderbox_server = 'tinderbox2@tinderbox.altinity.org';
34 # These shouldn't really need to be changed
35 my $BuildTree = 'nagiosplug';
37 my $ConfigureArgs = $ENV{CONFIGURE_ARGS
};
40 my $OSVer = `uname -r`;
47 $OSVer = $OSVer . "." . `uname -r`;
51 if ( $OS eq 'IRIX64' ) {
55 if ( $OS eq 'SCO_SV' ) {
60 if ( "$host" ne "" ) {
61 $BuildName = $host . ' ';
63 $BuildName .= $OS . ' ' . $OSVer;
67 my $logfile = "$_.log";
70 my ($fe, @felist, $EarlyExit, $LastTime);
72 my $StartDir = getcwd
();
75 print "Starting dir is : $StartDir\n";
82 if (-e
(my $file = "nagios-plugins.spec")) {
85 if (/^Version: HEAD-(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
86 $StartTime = timegm
(0, $5, $4, $3, ($2 - 1), ($1 - 1900));
92 print "Start time is $StartTime",$/;
94 my $CurrentDir = getcwd
();
95 if ( $CurrentDir ne $StartDir ) {
96 print "startdir: $StartDir, curdir $CurrentDir\n";
97 die "curdir != startdir";
100 unlink( "$logfile" );
102 print "opening $logfile\n";
103 open( LOG
, ">$logfile" ) || print "can't open $?\n";
104 print LOG
"current dir is -- $host:$CurrentDir\n";
105 print LOG
"Build Administrator is $BuildAdministrator\n";
112 $BuildStatus = "success";
114 $BuildStatus = "test_failed";
117 $BuildStatus = "build_failed";
120 $BuildStatus = "busted";
123 print LOG
"\nBuild Status = $BuildStatus\n";
128 # TV: Leaving this in, because process mail program probably has some
129 # limitation retained
131 # this fun line added on 2/5/98. do not remove. Translated to english,
132 # that's "take any line longer than 1000 characters, and split it into less
133 # than 1000 char lines. If any of the resulting lines is
134 # a dot on a line by itself, replace that with a blank line."
135 # This is to prevent cases where a <cr>.<cr> occurs in the log file. Sendmail
136 # interprets that as the end of the mail, and truncates the log before
137 # it gets to Tinderbox. (terry weismann, chris yeh)
139 # This was replaced by a perl 'port' of the above, writen by
140 # preed@netscape.com; good things: no need for system() call, and now it's
141 # all in perl, so we don't have to do OS checking like before.
143 open(LOG
, "$logfile") || die "Couldn't open logfile: $!\n";
144 open(OUTLOG
, ">${logfile}.last") || die "Couldn't open logfile: $!\n";
147 print OUTLOG
"tinderbox: tree: $BuildTree\n";
148 print OUTLOG
"tinderbox: builddate: $StartTime\n";
149 print OUTLOG
"tinderbox: status: $BuildStatus\n";
150 print OUTLOG
"tinderbox: build: $BuildName $fe\n";
151 print OUTLOG
"tinderbox: errorparser: unix\n";
152 print OUTLOG
"tinderbox: buildfamily: unix\n";
153 print OUTLOG
"tinderbox: END\n";
161 my $Output = substr($_, $val, 1000);
163 last if $Output eq undef;
165 $Output =~ s/^\.$//g;
167 print OUTLOG
"$Output\n";
177 system( "ssh $Tinderbox_server tinderbox_receive < ${logfile}.last" )
180 Not sending logs to http://tinderbox.altinity.org
181 If you have SSH keys setup on the tinderbox server, you can manually send
182 with 'ssh $Tinderbox_server tinderbox_receive < ${logfile}.last'
187 print "Finished building for tinderbox",$/;
195 while( $i < @ARGV ) {
196 if ($ARGV[$i] eq '--version' || $ARGV[$i] eq '-v') {
197 die "$0: version $Version\n";
198 } elsif ($ARGV[$i] eq '-y') {
210 die "usage: $0 [-v | --version ] [-t do not send report to tinderbox server]\n";
215 foreach $key (keys %ENV) {
216 print LOG
"$key = $ENV{$key}\n";
217 print "$key = $ENV{$key}\n";
220 # Print the NPTest variables
221 if (-e
"/var/tmp/NPTest.cache") {
222 open F
, "/var/tmp/NPTest.cache";
223 print LOG
"NPTest variables:\n";
233 print "Path before: $Path\n";
235 if ( $OS eq 'SunOS' ) {
236 $ENV{'PATH'} = '/usr/ccs/bin:' . $ENV{'PATH'};
240 print "Path After: $Path\n";
245 print LOG
"./configure $ConfigureArgs\n";
246 open (CONFIGURE
, "./configure $ConfigureArgs 2>&1 |") || die "../configure: $!\n";
247 while (<CONFIGURE
>) {
257 print LOG
"make 2>&1\n";
258 open( MAKE
, "make 2>&1 |");
269 print LOG
"LANG=C make test 2>&1\n";
270 open( MAKE
, "LANG=C make test && make install DESTDIR=$TmpDir/tinderbox_build.$$ && make install-strip DESTDIR=$TmpDir/tinderbox_build2.$$ 2>&1 |");
277 system("rm -fr $TmpDir/tinderbox_build.$$ $TmpDir/tinderbox_build2.$$");