#!/usr/bonsaitools/bin/perl --
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (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.
#
# Contributor(s):
require 'tbglobals.pl';
require 'header.pl';
# Process the form arguments
%form = ();
&split_cgi_args();
$|=1;
print "Content-type: text/html\n\n";
$form{noignore} = 1; # Force us to load all build info, not
# paying any attention to ignore_builds stuff.
$maxdate = time();
$mindate = $maxdate - 24*60*60;
tb_load_data();
EmitHtmlHeader("administer tinderbox", "tree: $tree");
if (defined($tree)) {
# Sheriff
if( -r "$tree/sheriff.pl" ){
require "$tree/sheriff.pl";
$current_sheriff =~ s/\s*$//; # Trim trailing whitespace;
} else {
$current_sheriff = "";
}
# Status message.
if( -r "$tree/status.pl" ){
require "$tree/status.pl";
$status_message =~ s/\s*$//; # Trim trailing whitespace;
} else {
$status_message = "";
}
# Tree rules.
if( -r "$tree/rules.pl" ){
require "$tree/rules.pl";
$rules_message =~ s/\s*$//; # Trim trailing whitespace;
} else {
$rules_message = "";
}
#
# Change sheriff
#
print "
";
#
# Status message
#
print "
";
#
# Rules message.
#
print "
";
#
# Trim logs.
#
# Determine the collective size & age of the build logs
opendir(TRIM_DIR, "$tree") || die "opendir($tree): $!";
my @trim_files = grep { /\.(?:gz|brief\.html)$/ && -f "$tree/$_" } readdir(TRIM_DIR);
close(TRIM_DIR);
my $trim_bytes = 0;
my $now = time();
my $trim_oldest = $now;
my $size_K = 1024;
my $size_M = 1048576;
my $size_G = 1073741824;
for my $file (@trim_files) {
my @file_stat = stat("$tree/$file");
$trim_bytes += $file_stat[7];
$trim_oldest = $file_stat[9] if ($trim_oldest > $file_stat[9]);
}
$trim_days = int (($now - $trim_oldest) / 86400);
if ($trim_bytes < $size_k) {
$trim_size = "$trim_bytes b";
} elsif ($trim_bytes < $size_M) {
$trim_size = int($trim_bytes / $size_K) . " Kb";
} elsif ($trim_bytes < $size_G){
$trim_size = int($trim_bytes / $size_M) . " Mb";
} else {
$trim_size = (int($trim_bytes / $size_G * 1000)/1000) . " Gb";
}
print "
" ;
} else {
#
# Create a new tinderbox page.
#
print "
";
}
#
# Toggle scraping for builds.
#
if (defined($tree)) {
print "
Turn on log scraping. Checked builds will have the logs scanned fora token of the form TinderboxPrint:aaa,bbb,ccc. These values will show up as-is in the showbuilds.cgi output.
";
}
#
# Turn builds off.
#
if (defined($tree)) {
print "
If builds are behaving badly you can turn them off. Uncheck
the build that is misbehaving and click the button. Add &noignore=1 to
the tinderbox URL to override.
";
}
print "