#!/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. use lib '../bonsai'; require 'globals.pl'; require 'lloydcgi.pl'; require 'imagelog.pl'; require 'header.pl'; $|=1; # Hack this until I can figure out how to do get default root. -slamm $default_root = '/cvsroot'; # Show 12 hours by default # $nowdate = time; if (not defined($maxdate = $form{maxdate})) { $maxdate = $nowdate; } if ($form{showall}) { $mindate = 0; } else { $default_hours = 12; $hours = $default_hours; $hours = $form{hours} if $form{hours}; $mindate = $maxdate - ($hours*60*60); } %colormap = ( success => '00ff00', busted => 'red', building => 'yellow', testfailed => 'orange' ); %images = ( flames => '1afi003r.gif', star => 'star.gif' ); $tree = $form{tree}; if (exists $form{rebuildguilty} or exists $form{showall}) { system ("./buildwho.pl -days 7 $tree > /dev/null"); undef $form{rebuildguilty}; } &show_tree_selector, exit if $form{tree} eq ''; &do_quickparse, exit if $form{quickparse}; &do_express, exit if $form{express}; &do_rdf, exit if $form{rdf}; &do_static, exit if $form{static}; &do_flash, exit if $form{flash}; &do_panel, exit if $form{panel}; &do_tinderbox, exit; # end of main #===================================================================== sub make_tree_list { my @result; while(<*>) { if( -d $_ && $_ ne 'data' && $_ ne 'CVS' && -f "$_/treedata.pl") { push @result, $_; } } return @result; } sub show_tree_selector { print "Content-type: text/html\n\n"; EmitHtmlHeader("tinderbox"); print "

"; print ""; print "
Select one of the following trees:
\n"; print "
    \n"; my @list = make_tree_list(); foreach (@list) { print "
  • $_\n"; } print "
"; print "

"; print ""; print "
"; print "Administer one of the following trees:
\n"; print "
    \n"; foreach (@list) { print "
  • $_\n"; } print "
"; } sub do_static { local *OUT; $form{nocrap}=1; my @pages = ( ['index.html', 'do_tinderbox'], ['flash.rdf', 'do_flash'], ['panel.html', 'do_panel'] ); $rel_path = '../'; while (($key, $value) = each %images) { $images{$key} = "$rel_path/$value"; } my $oldfh = select; foreach $pair (@pages) { my ($page, $call) = @{$pair}; my $outfile = "$form{tree}/$page"; open(OUT,">$outfile.$$"); select OUT; eval "$call"; close(OUT); system "mv $outfile.$$ $outfile"; } select $oldfh; } sub do_tinderbox { &load_data; &print_page_head; &print_table_header; &print_table_body; &print_table_footer; } sub print_page_head { print "Content-type: text/html", ($nowdate eq $maxdate ? "\nRefresh: 900" : ''), "\n\n\n" unless $form{static}; # Get the message of the day only on the first pageful do "$tree/mod.pl" if $nowdate eq $maxdate; $treename = $tree . ($tree2 ne '' ? " and $tree2" : ''); use POSIX; # Print time in format, "HH:MM timezone" my $now = strftime("%H:%M %Z", localtime); EmitHtmlTitleAndHeader("tinderbox: $treename", "tinderbox", "tree: $treename ($now)"); &print_javascript; print "$message_of_day\n"; # Quote and Lengend # unless ($form{nocrap}) { my ($imageurl,$imagewidth,$imageheight,$quote) = &get_image; print qq{


$quote

L= Show Build Log
= Show Log comments
Successful Build
Build in Progress
Successful Build, but Tests Failed
Build Failed
}; } if ($bonsai_tree) { print "The tree is currently "; print (&tree_open ? 'OPEN' : 'CLOSED'); print "\n"; } } sub print_table_body { for (my $tt=1; $tt <= $time_count; $tt++) { last if $build_time_times->[$tt] < $mindate; print_table_row($tt); } } sub print_table_row { my ($tt) = @_; # Time column # my $query_link = ''; my $end_query = ''; my $pretty_time = &print_time($build_time_times->[$tt]); ($hour) = $pretty_time =~ /(\d\d):/; if ($tree2 eq '' and ($lasthour != $hour or &has_who_list($tt))) { $query_link = &query_ref($td1, $build_time_times->[$tt]); $end_query = ''; } if ($lasthour == $hour) { $pretty_time =~ s/^.* //; } else { $lasthour = $hour; } my $hour_color = ''; $hour_color = ' bgcolor=#e7e7e7' if $build_time_times->[$tt] % 7200 <= 3600; print "", "$query_link\n$pretty_time$end_query\n"; if ($tree2 ne '') { print "\n"; $query_link = &query_ref( $td1, $build_time_times->[$tt]); print "$query_link\n"; } # Guilty # print ''; for $who (sort keys %{$who_list->[$tt]} ){ $qr = &who_menu($td1, $build_time_times->[$tt], $build_time_times->[$tt-1],$who); $who =~ s/%.*$//; print " ${qr}$who\n"; } print ''; if ($tree2 ne '') { print "\n"; $qr = &query_ref( $td2, $build_time_times->[$tt]); print "${qr}\n"; print "\n"; for $who (sort keys %{$who_list2->[$tt]} ){ $qr = &who_menu($td2, $build_time_times->[$tt], $build_time_times->[$tt-1],$who); print " ${qr}$who\n"; } print ''; } # Build Status # for ($bn=1; $bn <= $name_count; $bn++) { if (not defined($br = $build_table->[$tt][$bn])) { # No build data for this time print "\n"; next; } next if $br == -1; # rowspan has covered this row $hasnote = $br->{hasnote}; $noteid = $hasnote ? $br->{noteid} : 0; $rowspan = $br->{rowspan}; $rowspan = $mindate_time_count - $tt + 1 if $tt + $rowspan - 1 > $mindate_time_count; $color = $colormap{$br->{buildstatus}}; $status = $br->{buildstatus}; print "\n"; $logfile = $br->{logfile}; $errorparser = $br->{errorparser}; $buildname = $br->{buildname}; if( $tree2 ne "" ){ $buildname =~ s/^[^ ]* //; } $buildtime = $br->{buildtime}; $buildtree = $br->{td}->{name}; print "\n"; # Build Note # $buildname = &url_encode($buildname); my $logurl = "${rel_path}showlog.cgi?logfile=$logfile\&tree=$buildtree" ."&errorparser=$errorparser&buildname=$buildname" ."&buildtime=$buildtime"; if ($hasnote) { print "", "\n"; } # Build Log # print ""; print "L"; # What Changed # if( $br->{previousbuildtime} ){ my $previous_br = $build_table->[$tt+$rowspan][$bn]; my $previous_rowspan = $previous_br->{rowspan}; if (&has_who_list($tt+$rowspan, $tt+$rowspan+$previous_rowspan-1)) { print "\n", &query_ref($br->{td}, $br->{previousbuildtime}, $br->{buildtime}); print "C"; } } if ($br->{binaryname} ne '') { $binfile = "$buildtree/bin/$buildtime/$br->{buildname}/" ."$br->{binaryname}"; $binfile =~ s/ //g; print " B"; } print "\n"; } print "\n"; } sub print_table_header { my $ii, $nspan; print "\n"; print "\n"; print ""; $nspan = ($tree2 ne '' ? 4 : 1); print ""; for ($ii=1; $ii <= $name_count; $ii++) { my $bn = $build_name_names->[$ii]; $bn =~ s/Clobber/Clbr/g; $bn =~ s/Depend/Dep/g; if( $form{narrow} ){ $bn =~ s/([^:])/$1
/g; $bn = "$bn"; } else { $bn = "$bn"; } my $last_status = &last_status($ii); if ($last_status eq 'busted') { if ($form{nocrap}) { print ""; } else { print ""; } } else { print ""; } } print "\n"; print "\n"; if ($tree2 ne '') { print "\n"; print "\n"; } else { print "\n"; } print "\n"; } sub print_table_footer { print "
Click time to
see changes
", "since time
", "Click name to see what they did"; print "
", &open_showbuilds_href(rebuildguilty=>'1'), "Rebuild guilty list
$bn"; print "$bn$bn
Build Time$td1->{name}$td2->{name}Guilty
\n"; my $nextdate = $maxdate - $hours*60*60; print &open_showbuilds_href(maxdate=>"$nextdate", nocrap=>'1') ."Show next $hours hours"; if (open(FOOTER, "<$data_dir/footer.html")) { while (