1998-06-17 01:43:24 +04:00
|
|
|
#!/usr/bonsaitools/bin/perl --
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Netscape Public License
|
|
|
|
# Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
# compliance with the License. You may obtain a copy of the License at
|
|
|
|
# http://www.mozilla.org/NPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS IS"
|
|
|
|
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing rights and limitations
|
|
|
|
# under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is the Tinderbox build tool.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are Copyright (C) 1998
|
|
|
|
# Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
use lib '../bonsai';
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
require 'globals.pl';
|
|
|
|
require 'lloydcgi.pl';
|
|
|
|
require 'header.pl';
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
#############################################################
|
|
|
|
# Global variables
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
$LINES_AFTER_ERROR = 5;
|
|
|
|
$LINES_BEFORE_ERROR = 30;
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
# These variables are set by the error parser functions:
|
|
|
|
# has_error(), has_warning(), and has_errorline().
|
1998-06-17 01:43:24 +04:00
|
|
|
$error_file = '';
|
|
|
|
$error_file_ref = '';
|
|
|
|
$error_line = 0;
|
|
|
|
$error_guess = 0;
|
|
|
|
|
|
|
|
$next_err = 0;
|
|
|
|
@log_errors = ();
|
1999-03-19 23:37:07 +03:00
|
|
|
$log_line = 0;
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
#############################################################
|
|
|
|
# CGI inputs
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-07-07 01:23:32 +04:00
|
|
|
if (defined($args = $form{log}) or defined($args = $form{exerpt})) {
|
|
|
|
|
1999-06-28 22:22:24 +04:00
|
|
|
($full_logfile, $linenum) = split /:/, $args;
|
|
|
|
($tree, $logfile) = split /\//, $full_logfile;
|
|
|
|
|
|
|
|
my $br = find_build_record($tree, $logfile);
|
|
|
|
$errorparser = $br->{errorparser};
|
|
|
|
$buildname = $br->{buildname};
|
|
|
|
$buildtime = $br->{buildtime};
|
|
|
|
|
|
|
|
$numlines = 50;
|
|
|
|
$numlines = $form{numlines} if exists $form{numlines};
|
|
|
|
} else {
|
|
|
|
$tree = $form{tree};
|
|
|
|
$errorparser = $form{errorparser};
|
|
|
|
$logfile = $form{logfile};
|
|
|
|
$buildname = $form{buildname};
|
|
|
|
$buildtime = $form{buildtime};
|
|
|
|
}
|
1999-07-07 02:37:17 +04:00
|
|
|
$fulltext = $form{fulltext};
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
$enc_buildname = &url_encode($buildname);
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
die "the \"tree\" parameter must be provided\n" unless $tree;
|
|
|
|
require "$tree/treedata.pl";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
$time_str = print_time( $buildtime );
|
|
|
|
|
|
|
|
$|=1;
|
|
|
|
|
1999-06-25 03:30:08 +04:00
|
|
|
if ($linenum) {
|
|
|
|
|
|
|
|
&print_fragment;
|
|
|
|
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
&print_header;
|
|
|
|
&print_notes;
|
|
|
|
|
1999-06-25 03:30:08 +04:00
|
|
|
# Dynamically load the error parser
|
|
|
|
#
|
|
|
|
die "the \"errorparser\" parameter must be provided\n" unless $errorparser;
|
|
|
|
require "ep_${errorparser}.pl";
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
if ($fulltext)
|
|
|
|
{
|
|
|
|
&print_summary;
|
|
|
|
&print_log;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$brief_filename = $logfile;
|
|
|
|
$brief_filename =~ s/.gz$/.brief.html/;
|
1999-03-26 02:15:40 +03:00
|
|
|
if (-T "$tree/$brief_filename" and -M _ > -M $tree/$logfile)
|
1999-03-19 23:37:07 +03:00
|
|
|
{
|
|
|
|
open (BRIEFFILE, "<$tree/$brief_filename");
|
|
|
|
print while (<BRIEFFILE>)
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-03-26 02:15:40 +03:00
|
|
|
open (BRIEFFILE, ">$tree/$brief_filename");
|
1999-03-19 23:37:07 +03:00
|
|
|
|
|
|
|
&print_summary;
|
|
|
|
&print_log;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# end of main
|
|
|
|
############################################################
|
|
|
|
|
1999-06-25 03:30:08 +04:00
|
|
|
sub print_fragment {
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
|
|
|
|
print "<META HTTP-EQUIV=\"EXPIRES\" CONTENT=\"1\">\n";
|
|
|
|
|
|
|
|
my $heading = "Build Log (Fragment)";
|
|
|
|
my $subheading = "$buildname on $time_str";
|
|
|
|
my $title = "$heading - $subheading";
|
|
|
|
|
|
|
|
EmitHtmlTitleAndHeader($title, $heading, $subheading);
|
|
|
|
|
|
|
|
print "<a href='showlog.cgi?tree=$tree&errorparser=$errorparser&logfile=$logfile&buildtime=$buildtime&buildname=$enc_buildname&fulltext=1'>Show Full Build Log</a>";
|
|
|
|
|
|
|
|
open(BUILD_IN, "$gzip -d -c $tree/$logfile|");
|
|
|
|
|
|
|
|
my $first_line = $linenum - ($numlines/2);
|
|
|
|
my $last_line = $linenum + ($numlines/2);
|
|
|
|
|
|
|
|
print "<pre><b>.<br>.<br>.<br></b>";
|
|
|
|
while(<BUILD_IN>) {
|
|
|
|
next if $. < $first_line;
|
|
|
|
last if $. > $last_line;
|
|
|
|
print "<b><font color='red'>" if $. == $linenum;
|
|
|
|
print;
|
|
|
|
print "</font></b>" if $. == $linenum;
|
|
|
|
}
|
|
|
|
print "<b>.<br>.<br>.<br></b></pre>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
sub print_header {
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
|
|
|
|
if( $fulltext ){
|
1998-06-17 01:43:24 +04:00
|
|
|
$s = 'Show <b>Brief</b> Log';
|
|
|
|
$s1 = '';
|
|
|
|
$s2 = 'Full';
|
1999-03-19 23:37:07 +03:00
|
|
|
}
|
|
|
|
else {
|
1998-06-17 01:43:24 +04:00
|
|
|
$s = 'Show <b>Full</b> Log';
|
|
|
|
$s1 = 1;
|
|
|
|
$s2 = 'Brief';
|
1999-03-19 23:37:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
print "<META HTTP-EQUIV=\"EXPIRES\" CONTENT=\"1\">\n";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
my $heading = "Build Log ($s2)";
|
|
|
|
my $subheading = "$buildname on $time_str";
|
|
|
|
my $title = "$heading - $subheading";
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
EmitHtmlTitleAndHeader($title, $heading, $subheading);
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
print "
|
1998-06-17 01:43:24 +04:00
|
|
|
<font size=+1>
|
1999-03-19 23:37:07 +03:00
|
|
|
<dt><a href='showlog.cgi?tree=$tree&errorparser=$errorparser&logfile=$logfile&buildtime=$buildtime&buildname=$enc_buildname&fulltext=$s1'>$s</a>
|
|
|
|
<dt><a href=\"showbuilds.cgi?tree=$tree\">Return to the Build Page</a>
|
1998-06-17 01:43:24 +04:00
|
|
|
<dt><a href=\"addnote.cgi?tree=$tree\&buildname=$enc_buildname\&buildtime=$buildtime\&logfile=$logfile\&errorparser=$errorparser\">
|
|
|
|
Add a Comment to the Log</a>
|
|
|
|
</font>
|
|
|
|
";
|
1999-03-19 23:37:07 +03:00
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
sub print_notes {
|
|
|
|
#
|
|
|
|
# Print notes
|
|
|
|
#
|
|
|
|
$found_note = 0;
|
|
|
|
open(NOTES,"<$tree/notes.txt")
|
|
|
|
or print "<h2>warning: Couldn't open $tree/notes.txt </h2>\n";
|
1999-06-25 03:30:08 +04:00
|
|
|
print "$buildtime, $buildname<br>\n";
|
1999-03-19 23:37:07 +03:00
|
|
|
while(<NOTES>){
|
1998-06-17 01:43:24 +04:00
|
|
|
chop;
|
|
|
|
($nbuildtime,$nbuildname,$nwho,$nnow,$nenc_note) = split(/\|/);
|
|
|
|
#print "$_<br>\n";
|
|
|
|
if( $nbuildtime == $buildtime && $nbuildname eq $buildname ){
|
1999-03-19 23:37:07 +03:00
|
|
|
if( !$found_note ){
|
|
|
|
print "<H2>Build Comments</H2>\n";
|
|
|
|
$found_note = 1;
|
|
|
|
}
|
|
|
|
$now_str = &print_time($nnow);
|
|
|
|
$note = &url_decode($nenc_note);
|
|
|
|
print "<pre>\n[<b><a href=mailto:$nwho>$nwho</a> - $now_str</b>]\n$note\n</pre>";
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
1999-03-19 23:37:07 +03:00
|
|
|
}
|
|
|
|
close(NOTES);
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
1999-03-19 04:52:36 +03:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
sub print_summary {
|
|
|
|
#
|
|
|
|
# Print the summary first
|
|
|
|
#
|
|
|
|
logprint('<H2>Build Error Summary</H2><PRE>');
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
$log_line = 0;
|
|
|
|
open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
|
|
|
|
while( $line = <BUILD_IN> ){
|
|
|
|
&output_summary_line( $line );
|
|
|
|
}
|
|
|
|
close( BUILD_IN );
|
|
|
|
push @log_errors, 9999999;
|
1999-03-19 04:52:36 +03:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
logprint('</PRE>');
|
1999-03-18 05:53:54 +03:00
|
|
|
}
|
1999-03-19 04:52:36 +03:00
|
|
|
|
1999-06-25 03:30:08 +04:00
|
|
|
sub print_log_section {
|
|
|
|
my ($tree, $logfile, $line_of_interest, $num_lines) = shift;
|
|
|
|
local $_;
|
|
|
|
|
|
|
|
my $first_line = $line_of_interest - $num_lines / 2;
|
|
|
|
my $last_line = $first_line + $num_lines;
|
|
|
|
|
|
|
|
print "<a href='showlog.cgi?tree=$tree&logfile=$logfile&line="
|
|
|
|
.($line_of_interest-$num_lines)."&numlines=$num_lines'>"
|
|
|
|
."Previous $num_lines</a>";
|
|
|
|
print "<font size='+1'><b>.<br>.<br>.<br></b></font>";
|
|
|
|
print "<pre>";
|
|
|
|
my $ii = 0;
|
|
|
|
open BUILD_IN, "$gzip -d -c $tree/$logfile|";
|
|
|
|
while (<BUILD_IN>) {
|
|
|
|
$ii++;
|
|
|
|
next if $ii < $first_line;
|
|
|
|
last if $ii > $last_line;
|
|
|
|
if ($ii == $line_of_intested) {
|
|
|
|
print "<b>$_</b>";
|
|
|
|
} else {
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close BUILD_IN;
|
|
|
|
print "</pre>";
|
|
|
|
print "<font size='+1'><b>.<br>.<br>.<br></b></font>";
|
|
|
|
print "<a href='showlog.cgi?tree=$tree&logfile=$logfile&line="
|
|
|
|
.($line_of_interest+$num_lines)."&numlines=$num_lines'>"
|
|
|
|
."Next $num_lines</a>";
|
|
|
|
}
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
sub print_log {
|
|
|
|
#
|
|
|
|
# reset the error counter
|
|
|
|
#
|
|
|
|
$next_err = 0;
|
|
|
|
|
|
|
|
logprint('<H2>Build Error Log</H2><pre>');
|
|
|
|
|
|
|
|
$log_line = 0;
|
|
|
|
open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
|
|
|
|
while( $line = <BUILD_IN> ){
|
|
|
|
&output_log_line( $line );
|
|
|
|
}
|
|
|
|
close( BUILD_IN );
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
logprint('</PRE><p>'
|
|
|
|
."<font size=+1><a name=\"err$next_err\">No More Errors</a></font>"
|
|
|
|
.'<br><br><br>');
|
|
|
|
}
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 04:52:36 +03:00
|
|
|
sub output_summary_line {
|
1999-03-19 23:37:07 +03:00
|
|
|
my( $line ) = $_[0];
|
|
|
|
my( $has_error );
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 04:52:36 +03:00
|
|
|
$has_error = &has_error( $line );
|
1998-06-17 01:43:24 +04:00
|
|
|
|
1999-03-19 04:52:36 +03:00
|
|
|
$line =~ s/&/&/g;
|
|
|
|
$line =~ s/</</g;
|
|
|
|
|
|
|
|
if( $has_error ){
|
1999-03-19 23:37:07 +03:00
|
|
|
push @log_errors, $log_line + $LINES_AFTER_ERROR;
|
1999-03-19 04:52:36 +03:00
|
|
|
if( ! $last_was_error ) {
|
1999-03-19 23:37:07 +03:00
|
|
|
logprint("<a href=\"#err$next_err\">$line</a>");
|
1999-03-19 04:52:36 +03:00
|
|
|
$next_err++;
|
|
|
|
}
|
|
|
|
$last_was_error = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$last_was_error = 0;
|
|
|
|
}
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
$log_line++;
|
1999-03-19 04:52:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub output_log_line {
|
1999-03-19 23:37:07 +03:00
|
|
|
my( $line ) = $_[0];
|
|
|
|
my( $has_error, $dur, $dur_min,$dur_sec, $dur_str, $logline );
|
1999-03-19 04:52:36 +03:00
|
|
|
|
|
|
|
$has_error = &has_error( $line );
|
|
|
|
$has_warning = &has_warning( $line );
|
1998-06-17 01:43:24 +04:00
|
|
|
|
|
|
|
$line =~ s/&/&/g;
|
|
|
|
$line =~ s/</</g;
|
|
|
|
|
|
|
|
$logline = '';
|
|
|
|
|
|
|
|
if( ($has_error || $has_warning) && &has_errorline( $line ) ) {
|
|
|
|
$q = quotemeta( $error_file );
|
|
|
|
#$goto_line = ($error_line ? 10 > $error_line - 10 : 1 );
|
|
|
|
$goto_line = ($error_line > 10 ? $error_line - 10 : 1 );
|
|
|
|
$cvsblame = ($error_guess ? "cvsguess.cgi" : "cvsblame.cgi");
|
|
|
|
$line =~ s@$q@<a href=../bonsai/$cvsblame?file=$error_file_ref&rev=$cvs_branch&mark=$error_line#$goto_line $source_target>$error_file</a>@
|
|
|
|
}
|
|
|
|
|
1999-03-18 05:16:57 +03:00
|
|
|
|
1999-03-19 04:52:36 +03:00
|
|
|
if( $has_error ){
|
1998-06-17 01:43:24 +04:00
|
|
|
if( ! $last_was_error ) {
|
|
|
|
$logline .= "<a name=\"err$next_err\"></a>";
|
|
|
|
$next_err++;
|
|
|
|
$logline .= "<a href=\"#err$next_err\">NEXT</a> ";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$logline .= " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
$logline .= "<font color=\"000080\">$line</font>";
|
|
|
|
|
|
|
|
$last_was_error = 1;
|
|
|
|
}
|
|
|
|
elsif( $has_warning ){
|
|
|
|
$logline .= " ";
|
|
|
|
$logline .= "<font color=000080>$line</font>";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$logline .= " $line";
|
|
|
|
$last_was_error = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&push_log_line( $logline );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub push_log_line {
|
1999-03-19 23:37:07 +03:00
|
|
|
my( $line ) = $_[0];
|
1998-06-17 01:43:24 +04:00
|
|
|
if( $fulltext ){
|
1999-03-19 23:37:07 +03:00
|
|
|
logprint($line);
|
1998-06-17 01:43:24 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
if( $log_line > $log_errors[$cur_error] ){
|
1998-06-17 01:43:24 +04:00
|
|
|
$cur_error++;
|
|
|
|
}
|
|
|
|
|
1999-03-19 23:37:07 +03:00
|
|
|
if( $log_line >= $log_errors[$cur_error] - $LINES_BEFORE_ERROR ){
|
1998-06-17 01:43:24 +04:00
|
|
|
if( $log_skip != 0 ){
|
1999-03-19 23:37:07 +03:00
|
|
|
logprint("\n<i><font size=+1> Skipping $log_skip Lines...</i></font>\n\n");
|
1998-06-17 01:43:24 +04:00
|
|
|
$log_skip = 0;
|
|
|
|
}
|
1999-03-19 23:37:07 +03:00
|
|
|
logprint($line);
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$log_skip++;
|
|
|
|
}
|
1999-03-19 23:37:07 +03:00
|
|
|
$log_line++;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub logprint {
|
|
|
|
my $line = $_[0];
|
|
|
|
print $line;
|
|
|
|
print BRIEFFILE $line if not $fulltext;
|
1998-06-17 01:43:24 +04:00
|
|
|
}
|