3 # This script builds the monitoringplugins 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 = `git describe --abbrev=4 HEAD`;
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 # Have the StrictHostKeyChecking=no so that a new host will automatically add hostkey without
33 # prompting. If host key changes, then will get error, so this should still be secure
34 my $Tinderbox_server = '-p 1022 -o StrictHostKeyChecking=no tinderbox2@tinderbox.opsera.com';
36 # These shouldn't really need to be changed
37 my $BuildTree = 'monitoringplug';
39 my $ConfigureArgs = $ENV{CONFIGURE_ARGS
};
42 my $OSVer = `uname -r`;
49 $OSVer = $OSVer . "." . `uname -r`;
53 if ( $OS eq 'IRIX64' ) {
57 if ( $OS eq 'SCO_SV' ) {
62 if ( "$host" ne "" ) {
63 $BuildName = $host . ' ';
65 $BuildName .= $OS . ' ' . $OSVer;
69 my $logfile = "$_.log";
72 my ($fe, @felist, $EarlyExit, $LastTime);
74 my $StartDir = getcwd
();
77 print "Starting dir is : $StartDir\n";
84 if (-e
(my $file = "monitoring-plugins.spec")) {
87 if (/^Version: trunk-(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
88 $StartTime = timegm
(0, $5, $4, $3, ($2 - 1), ($1 - 1900));
94 print "Start time is $StartTime",$/;
96 my $CurrentDir = getcwd
();
97 if ( $CurrentDir ne $StartDir ) {
98 print "startdir: $StartDir, curdir $CurrentDir\n";
99 die "curdir != startdir";
102 unlink( "$logfile" );
104 print "opening $logfile\n";
105 open( LOG
, ">$logfile" ) || print "can't open $?\n";
106 print LOG
"current dir is -- $host:$CurrentDir\n";
107 print LOG
"Build Administrator is $BuildAdministrator\n";
114 $BuildStatus = "success";
116 $BuildStatus = "test_failed";
119 $BuildStatus = "build_failed";
122 $BuildStatus = "busted";
125 print LOG
"\nBuild Status = $BuildStatus\n";
130 # TV: Leaving this in, because process mail program probably has some
131 # limitation retained
133 # this fun line added on 2/5/98. do not remove. Translated to english,
134 # that's "take any line longer than 1000 characters, and split it into less
135 # than 1000 char lines. If any of the resulting lines is
136 # a dot on a line by itself, replace that with a blank line."
137 # This is to prevent cases where a <cr>.<cr> occurs in the log file. Sendmail
138 # interprets that as the end of the mail, and truncates the log before
139 # it gets to Tinderbox. (terry weismann, chris yeh)
141 # This was replaced by a perl 'port' of the above, writen by
142 # preed@netscape.com; good things: no need for system() call, and now it's
143 # all in perl, so we don't have to do OS checking like before.
145 open(LOG
, "$logfile") || die "Couldn't open logfile: $!\n";
146 open(OUTLOG
, ">${logfile}.last") || die "Couldn't open logfile: $!\n";
149 print OUTLOG
"tinderbox: tree: $BuildTree\n";
150 print OUTLOG
"tinderbox: builddate: $StartTime\n";
151 print OUTLOG
"tinderbox: status: $BuildStatus\n";
152 print OUTLOG
"tinderbox: build: $BuildName $fe\n";
153 print OUTLOG
"tinderbox: errorparser: unix\n";
154 print OUTLOG
"tinderbox: buildfamily: unix\n";
155 print OUTLOG
"tinderbox: END\n";
163 my $Output = substr($_, $val, 1000);
165 last if $Output eq undef;
167 $Output =~ s/^\.$//g;
169 print OUTLOG
"$Output\n";
179 system( "ssh $Tinderbox_server tinderbox_receive < ${logfile}.last" )
182 Not sending logs to http://tinderbox.altinity.org
183 If you have SSH keys setup on the tinderbox server, you can manually send
184 with 'ssh $Tinderbox_server tinderbox_receive < ${logfile}.last'
189 print "Finished building for tinderbox",$/;
197 while( $i < @ARGV ) {
198 if ($ARGV[$i] eq '--version' || $ARGV[$i] eq '-v') {
199 die "$0: version $Version\n";
200 } elsif ($ARGV[$i] eq '-y') {
212 die "usage: $0 [-v | --version ] [-t do not send report to tinderbox server]\n";
217 foreach $key (keys %ENV) {
218 print LOG
"$key = $ENV{$key}\n";
219 print "$key = $ENV{$key}\n";
222 # Print the NPTest variables
223 if (-e
"/var/tmp/NPTest.cache") {
224 open F
, "/var/tmp/NPTest.cache";
225 print LOG
"NPTest variables:\n";
235 print "Path before: $Path\n";
237 # Don't alter path if we're building off a repository tree;
238 # SunOS make will be used only for snapshots and releases.
239 if ( $OS eq 'SunOS' && !( -e
'.svn' || -e
'.git' )) {
240 $ENV{'PATH'} = '/usr/ccs/bin:' . $ENV{'PATH'};
244 print "Path After: $Path\n";
249 print LOG
"./configure --enable-extra-opts --enable-libtap $ConfigureArgs 2>&1\n";
250 open (CONFIGURE
, "./configure --enable-extra-opts --enable-libtap $ConfigureArgs 2>&1 |") || die "../configure: $!\n";
251 while (<CONFIGURE
>) {
261 print LOG
"make 2>&1\n";
262 open( MAKE
, "make 2>&1 |");
273 print LOG
"LANG=C make test 2>&1 && make install DESTDIR=$TmpDir/tinderbox_build.$$ 2>&1 && make install-strip DESTDIR=$TmpDir/tinderbox_build2.$$ 2>&1\n";
274 open( MAKE
, "LANG=C make test 2>&1 && make install DESTDIR=$TmpDir/tinderbox_build.$$ 2>&1 && make install-strip DESTDIR=$TmpDir/tinderbox_build2.$$ 2>&1 |");
281 system("rm -fr $TmpDir/tinderbox_build.$$ $TmpDir/tinderbox_build2.$$");