From 917f16c6496e32ad38173b143775769a1074d1f6 Mon Sep 17 00:00:00 2001 From: "cls%seawood.org" Date: Sat, 27 May 2006 00:18:42 +0000 Subject: [PATCH] Remove tinderbox dependency upon obsolete bonsai scripts Bug #273441 r=bear --- webtools/tinderbox/Makefile | 70 ++++++++++++++++++++++------- webtools/tinderbox/addimage.cgi | 1 - webtools/tinderbox/addnote.cgi | 6 +-- webtools/tinderbox/admintree.cgi | 7 +-- webtools/tinderbox/buildwho.pl | 2 +- webtools/tinderbox/bustagestats.cgi | 7 +-- webtools/tinderbox/doadmin.cgi | 25 ++++++----- webtools/tinderbox/header.pl | 66 +++++++++++++++++++++++++++ webtools/tinderbox/processbuild.pl | 4 +- webtools/tinderbox/showbuilds.cgi | 12 ++--- webtools/tinderbox/showimages.cgi | 7 +-- webtools/tinderbox/showlog.cgi | 7 +-- webtools/tinderbox/tbglobals.pl | 67 +++++++++++++++++++++++++++ webtools/tinderbox/viewallnotes.cgi | 6 ++- webtools/tinderbox/warnings.pl | 3 +- 15 files changed, 237 insertions(+), 53 deletions(-) create mode 100644 webtools/tinderbox/header.pl diff --git a/webtools/tinderbox/Makefile b/webtools/tinderbox/Makefile index 54b15c6c9b52..8fa5a81c5180 100755 --- a/webtools/tinderbox/Makefile +++ b/webtools/tinderbox/Makefile @@ -20,18 +20,32 @@ # Contributor(s): -# This Makefile helps you install Tinderbox. Define PERL and MYSQLTCL to -# the full pathnames of where you have these utilities. Define PREFIX -# to where you will install the running Tinderbox. Then "make install" should -# copy things for you. +# This Makefile helps you install Tinderbox. +# Set the variables below to their proper locations. +# TINDERBOX_DIR is the full path to where you want to install tinderbox +# BONSAI_DIR is the full path to your local bonsai installation +# BONSAI_URL is the root URL to your bonsai install (e.g. ../bonsai) +# The other variables contain full paths to the utitlies required to +# use tinderbox. + +# Then "make install" should copy the files to the tinderbox location +# specified by TINDERBOX_DIR + +#TINDERBOX_DIR = /var/www/html/tinderbox +#BONSAI_DIR = /var/www/html/bonsai +#BONSAI_URL = /bonsai + +# Set these if you want to tighten permissions +#TINDERBOX_USER = tinderbox +#TINDERBOX_GROUP = tinderbox -#BONSAI = /home/httpd/html/bonsai #CVSROOT = /cvsroot #GZIP = /usr/bin/gzip #PERL = /usr/bin/perl -#PREFIX = /home/httpd/html/tinderbox #UUDECODE = /usr/bin/uudecode +ALL_UTILS = GZIP PERL UUDECODE + FILES = \ Backwards.pm \ addimage.cgi \ @@ -45,6 +59,7 @@ ep_unix.pl \ ep_windows.pl \ fixupimages.pl \ handlemail.pl \ +header.pl \ imagelog.pl \ processbuild.pl \ showbuilds.cgi \ @@ -54,7 +69,6 @@ tbglobals.pl \ Empty.html \ faq.html \ index.html \ -examples/build-moz-smoke.pl \ examples/buildit.config \ examples/mozilla-unix.pl \ examples/mozilla-windows.pl @@ -63,9 +77,22 @@ PICS = \ 1afi003r.gif \ star.gif +# Sanity check +ifeq (,$(strip $(TINDERBOX_DIR))) +$(error TINDERBOX_DIR must be set to the tinderbox install location) +endif + +ifeq (,$(strip $(BONSAI_DIR))) +$(error BONSAI_DIR must be set for bonsai support to work) +endif +ifeq (,$(strip $(BONSAI_URL))) +$(error BONSAI_URL must be set for bonsai support to work) +endif + install: - mkdir -p $(PREFIX) && \ - mkdir -p $(PREFIX)/examples && + $(foreach u,$(ALL_UTILS),$(if $($u),,$(error $u must be set to the full path of the utility))) + mkdir -p $(TINDERBOX_DIR)/examples + set -e ; \ for I in $(FILES); do \ echo Installing $$I && \ sed -e s#/usr/bonsaitools/bin/perl#$(PERL)#g \ @@ -73,11 +100,24 @@ install: -e s#/m/src#$(CVSROOT)#g \ -e s#/usr/local/bin/gzip#$(GZIP)#g \ -e s#/tools/ns/bin/uudecode#$(UUDECODE)#g \ - -e s#/d/webdocs/projects/bonsai#$(BONSAI)#g \ - $$I > $(PREFIX)/$$I && \ - chmod 755 $(PREFIX)/$$I; done && \ + -e s#/d/webdocs/projects/bonsai#$(BONSAI_DIR)#g \ + -e s#\.\./bonsai#$(BONSAI_URL)#g \ + $$I > $(TINDERBOX_DIR)/$$I && \ + chmod 755 $(TINDERBOX_DIR)/$$I; \ + done + set -e ; \ for I in $(PICS); do \ echo Installing $$I && \ - cp -f $$I $(PREFIX) && \ - chmod 755 $(PREFIX)/$$I; done - + cp $$I $(TINDERBOX_DIR) && \ + chmod 755 $(TINDERBOX_DIR)/$$I; \ + done + mkdir -p $(TINDERBOX_DIR)/data +ifneq (,$(TINDERBOX_USER)$(TINDERBOX_GROUP)) + chown -R $(TINDERBOX_USER) $(TINDERBOX_DIR) + chgrp -R $(TINDERBOX_GROUP) $(TINDERBOX_DIR) + chmod 755 $(TINDERBOX_DIR) + chmod 775 $(TINDERBOX_DIR)/data +else + chmod 777 $(TINDERBOX_DIR) + chmod 777 $(TINDERBOX_DIR)/data +endif diff --git a/webtools/tinderbox/addimage.cgi b/webtools/tinderbox/addimage.cgi index 28305e2b6552..39d613ef84b8 100755 --- a/webtools/tinderbox/addimage.cgi +++ b/webtools/tinderbox/addimage.cgi @@ -22,7 +22,6 @@ use Socket; -use lib "../bonsai"; require 'header.pl'; print "Content-type: text/html\n\n"; diff --git a/webtools/tinderbox/addnote.cgi b/webtools/tinderbox/addnote.cgi index bbdaab969aec..8702b792e96e 100755 --- a/webtools/tinderbox/addnote.cgi +++ b/webtools/tinderbox/addnote.cgi @@ -20,14 +20,14 @@ # # Contributor(s): -use lib '../bonsai'; use Fcntl; require 'tbglobals.pl'; -require 'lloydcgi.pl'; # Process the form arguments -# +%form = (); +&split_cgi_args(); + if (defined($args = $form{log})) { # Use simplified arguments that uses the logfile as a key. ($tree, $logfile) = split /\//, $args; diff --git a/webtools/tinderbox/admintree.cgi b/webtools/tinderbox/admintree.cgi index d784657caf5a..5dcf8ce8c506 100755 --- a/webtools/tinderbox/admintree.cgi +++ b/webtools/tinderbox/admintree.cgi @@ -20,12 +20,13 @@ # # Contributor(s): -use lib "../bonsai"; - -require 'lloydcgi.pl'; require 'tbglobals.pl'; require 'header.pl'; +# Process the form arguments +%form = (); +&split_cgi_args(); + $|=1; print "Content-type: text/html\n\n\n"; diff --git a/webtools/tinderbox/buildwho.pl b/webtools/tinderbox/buildwho.pl index e2a2414bd21b..302aa6b85338 100755 --- a/webtools/tinderbox/buildwho.pl +++ b/webtools/tinderbox/buildwho.pl @@ -24,7 +24,7 @@ use FileHandle; use File::Copy 'move'; use Fcntl qw(:DEFAULT :flock); -use lib "../bonsai"; +use lib "/d/webdocs/projects/bonsai"; require 'tbglobals.pl'; $F_DEBUG=1; diff --git a/webtools/tinderbox/bustagestats.cgi b/webtools/tinderbox/bustagestats.cgi index 8be04254bf67..355d7da88cbc 100755 --- a/webtools/tinderbox/bustagestats.cgi +++ b/webtools/tinderbox/bustagestats.cgi @@ -20,9 +20,6 @@ # # Contributor(s): -use lib "../bonsai"; - -require 'lloydcgi.pl'; require 'tbglobals.pl'; require 'header.pl'; @@ -31,6 +28,10 @@ use Date::Format; my $TIMEFORMAT = "%D %T"; +# Process the form arguments +%form = (); +&split_cgi_args(); + $|=1; print "Content-type: text/html\n\n\n"; diff --git a/webtools/tinderbox/doadmin.cgi b/webtools/tinderbox/doadmin.cgi index 4659dd4ca346..ff50e66a5512 100755 --- a/webtools/tinderbox/doadmin.cgi +++ b/webtools/tinderbox/doadmin.cgi @@ -21,12 +21,14 @@ # Contributor(s): -use lib "../bonsai"; -require 'lloydcgi.pl'; require 'tbglobals.pl'; -umask O666; +umask 0666; +$perm = "0775"; # Permission of created files & dirs +# Process the form arguments +%form = (); +&split_cgi_args(); $|=1; @@ -122,10 +124,10 @@ sub create_tree { $bonsaitreename = $form{'bonsaitreename'}; if( -r $treename ){ - chmod 0777, $treename; + chmod(oct($perm), $treename); } else { - mkdir( $treename, 0777 ) || die "

Cannot mkdir $treename

"; + mkdir( $treename, oct($perm)) || die "

Cannot mkdir $treename

"; } open( F, ">$treename/treedata.pl" ); print F "\$cvs_module='$modulename';\n"; @@ -134,6 +136,7 @@ sub create_tree { if ($repository ne "") { print F "\$cvs_root='$repository';\n"; } + print F "1;\n"; close( F ); open( F, ">$treename/build.dat" ); @@ -145,7 +148,7 @@ sub create_tree { open( F, ">$treename/notes.txt" ); close( F ); - chmod 0777, "$treename/build.dat", "$treename/who.dat", "$treename/notes.txt", + chmod oct($perm), "$treename/build.dat", "$treename/who.dat", "$treename/notes.txt", "$treename/treedata.pl"; print "

Tree created or modified

\n"; @@ -179,7 +182,7 @@ sub disable_builds { } print IGNORE "\t};\n"; - chmod( 0777, "$tree/ignorebuilds.pl"); + chmod( oct($perm), "$tree/ignorebuilds.pl"); print "

Build state Changed

\n"; } @@ -211,7 +214,7 @@ sub scrape_builds { } print SCRAPE "\t};\n"; - chmod( 0777, "$tree/scrapebuilds.pl"); + chmod( oct($perm), "$tree/scrapebuilds.pl"); print "

Build state Changed

\n"; } @@ -222,7 +225,7 @@ sub set_sheriff { open(SHERIFF, ">$tree/sheriff.pl"); print SHERIFF "\$current_sheriff = '$m';\n1;"; close(SHERIFF); - chmod( 0777, "$tree/sheriff.pl"); + chmod( oct($perm), "$tree/sheriff.pl"); print "

Sheriff Changed.

\n"; } @@ -233,7 +236,7 @@ sub set_status_message { open(TREESTATUS, ">$tree/status.pl"); print TREESTATUS "\$status_message = \'$m\'\;\n1;"; close(TREESTATUS); - chmod( 0777, "$tree/status.pl"); + chmod( oct($perm), "$tree/status.pl"); print "

Status message changed.

\n"; } @@ -244,7 +247,7 @@ sub set_rules_message { open(RULES, ">$tree/rules.pl"); print RULES "\$rules_message = \'$m\';\n1;"; close(RULES); - chmod( 0777, "$tree/rules.pl"); + chmod( oct($perm), "$tree/rules.pl"); print "

Rule message changed.

\n"; } diff --git a/webtools/tinderbox/header.pl b/webtools/tinderbox/header.pl new file mode 100644 index 000000000000..01a6e1288445 --- /dev/null +++ b/webtools/tinderbox/header.pl @@ -0,0 +1,66 @@ +# -*- 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 Bonsai CVS 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): + + +sub EmitHtmlTitleAndHeader { + my($doctitle,$heading,$subheading) = @_; + + print "$doctitle"; + print ""; + print ""; + print ""; + + if (open(BANNER, ") { print; } + close BANNER; + } elsif (open(BANNER, "<../bonsai/data/banner.html")) { + while () { print; } + close BANNER; + } + + print ""; + print " \n"; + print " \n"; + print "
\n"; + print " \n"; + print " \n"; + print "
\n"; + print " $heading\n"; + print "
\n"; + print " $subheading\n"; + print "
\n"; + print "
\n"; + + if (open(BLURB, ") { print; } + close BLURB; + } + + print "
\n"; +} + +sub EmitHtmlHeader { + my($heading,$subheading) = @_; + EmitHtmlTitleAndHeader($heading,$heading,$subheading); +} + +1; diff --git a/webtools/tinderbox/processbuild.pl b/webtools/tinderbox/processbuild.pl index feec92a16cd6..90b21579ed2b 100755 --- a/webtools/tinderbox/processbuild.pl +++ b/webtools/tinderbox/processbuild.pl @@ -71,7 +71,9 @@ unlink $mail_file; # Who data # -system("./buildwho.pl", "$tinderbox{tree}"); +if ("$tinderbox{bonsai_tree}" ne "") { + system("./buildwho.pl", "$tinderbox{tree}"); +} # Warnings diff --git a/webtools/tinderbox/showbuilds.cgi b/webtools/tinderbox/showbuilds.cgi index dbdda5c586e3..8e4daf615e61 100755 --- a/webtools/tinderbox/showbuilds.cgi +++ b/webtools/tinderbox/showbuilds.cgi @@ -20,12 +20,14 @@ # # Contributor(s): -use lib '../bonsai'; require 'tbglobals.pl'; -require 'lloydcgi.pl'; require 'imagelog.pl'; require 'header.pl'; +# Process the form arguments +%form = (); +&split_cgi_args(); + # Hack this until I can figure out how to do get default root. -slamm $default_root = '/cvsroot'; @@ -623,12 +625,12 @@ BEGIN { local $_; $::BatchID=''; - eval qq(require "../bonsai/data/$bonsai_tree/batchid.pl"); + eval qq(require "/d/webdocs/projects/bonsai/data/$bonsai_tree/batchid.pl"); if ($::BatchID eq '') { - warn "No BatchID in ../bonsai/data/$bonsai_tree/batchid.pl\n"; + warn "No BatchID in /d/webdocs/projects/bonsai/data/$bonsai_tree/batchid.pl\n"; return; } - open(BATCH, "<../bonsai/data/$bonsai_tree/batch-$::BatchID.pl") + open(BATCH, ""; while () { if (/^\$::TreeOpen = '(\d+)';/) { diff --git a/webtools/tinderbox/showimages.cgi b/webtools/tinderbox/showimages.cgi index 4dd1406fa7c5..820d28981887 100755 --- a/webtools/tinderbox/showimages.cgi +++ b/webtools/tinderbox/showimages.cgi @@ -23,13 +23,14 @@ $| = 1; -use lib "../bonsai"; - require 'tbglobals.pl'; require 'imagelog.pl'; -require 'lloydcgi.pl'; require 'header.pl'; +# Process the form arguments +%form = (); +&split_cgi_args(); + tb_check_password(); print "Content-type: text/html\n\n"; diff --git a/webtools/tinderbox/showlog.cgi b/webtools/tinderbox/showlog.cgi index 62131f490271..699a7b7029bb 100755 --- a/webtools/tinderbox/showlog.cgi +++ b/webtools/tinderbox/showlog.cgi @@ -20,12 +20,13 @@ # # Contributor(s): -use lib '../bonsai'; - require 'tbglobals.pl'; -require 'lloydcgi.pl'; require 'header.pl'; +# Process the form arguments +%form = (); +&split_cgi_args(); + ############################################################# # Global variables diff --git a/webtools/tinderbox/tbglobals.pl b/webtools/tinderbox/tbglobals.pl index 1f54aabcf653..1b49252b5512 100755 --- a/webtools/tinderbox/tbglobals.pl +++ b/webtools/tinderbox/tbglobals.pl @@ -728,4 +728,71 @@ sub load_notes { close NOTES; } +sub split_cgi_args { + local (@args, $pair, $key, $value, $s); + + if ($ENV{"REQUEST_METHOD"} eq 'POST') { + $s .= $_ while (<>); + } + else { + $s = $ENV{"QUERY_STRING"}; + } + + $s =~ tr/+/ /; + @args= split(/\&/, $s ); + + for $pair (@args) { + ($key, $value) = split(/=/, $pair); + $key =~ s/%([a-fA-F0-9]{2})/pack("C", hex($1))/eg; + $value =~ s/%([a-fA-F0-9]{2})/pack("C", hex($1))/eg; + $form{$key} = $value; + } + + # extract the cookies from the HTTP_COOKIE environment + %cookie_jar = split('[;=] *',$ENV{'HTTP_COOKIE'}); +} + +sub make_cgi_args { + local($k,$v,$ret); + for $k (sort keys %form){ + $ret .= ($ret eq "" ? '?' : '&'); + $v = $form{$k}; + $ret .= &url_encode2($k); + $ret .= '='; + $ret .= &url_encode2($v); + } + return $ret; +} + +sub url_encode2 { + local( $s ) = @_; + + $s =~ s/\%/\%25/g; + $s =~ s/\=/\%3d/g; + $s =~ s/\?/\%3f/g; + $s =~ s/ /\%20/g; + $s =~ s/\n/\%0a/g; + $s =~ s/\r//g; + $s =~ s/\"/\%22/g; + $s =~ s/\'/\%27/g; + $s =~ s/\|/\%7c/g; + $s =~ s/\&/\%26/g; + $s =~ s/\+/\%2b/g; + return $s; +} + +@weekdays = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); +@months = ('Jan','Feb','Mar','Apr','May','Jun', + 'Jul','Aug','Sep','Oct','Nov','Dec'); + +sub toGMTString { + local ($seconds) = $_[0]; + + local ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) + = gmtime($seconds); + $year += 1900; + + sprintf('%s, %02d-%s-%d %02d:%02d:%02d GMT', + $weekdays[$wday],$mday,$months[$mon],$year,$hour,$min,$sec); +} diff --git a/webtools/tinderbox/viewallnotes.cgi b/webtools/tinderbox/viewallnotes.cgi index f328459443e2..59e7e9523a93 100755 --- a/webtools/tinderbox/viewallnotes.cgi +++ b/webtools/tinderbox/viewallnotes.cgi @@ -20,9 +20,7 @@ # # Contributor(s): -use lib '../bonsai'; require "tbglobals.pl"; -require 'lloydcgi.pl'; require 'header.pl'; use Date::Parse; @@ -30,6 +28,10 @@ use Date::Format; my $TIMEFORMAT = "%D %T"; +# Process the form arguments +%form = (); +&split_cgi_args(); + $| = 1; print "Content-type: text/html\n\n\n"; diff --git a/webtools/tinderbox/warnings.pl b/webtools/tinderbox/warnings.pl index b00144d19bfb..fdc57815dcf6 100755 --- a/webtools/tinderbox/warnings.pl +++ b/webtools/tinderbox/warnings.pl @@ -475,8 +475,7 @@ sub mac_parser { sub build_blame { my ($cvs_root, $tags) = @_; - use lib '../bonsai'; - require 'utils.pl'; + use lib '/d/webdocs/projects/bonsai'; require 'cvsblame.pl'; while (($file, $lines_hash) = each %warnings) {