diff --git a/mozilla/webtools/buildbot-try/downloadpatches.sh b/mozilla/webtools/buildbot-try/downloadpatches.sh deleted file mode 100644 index 6b598b6ed91..00000000000 --- a/mozilla/webtools/buildbot-try/downloadpatches.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -# File: downloadpatches.sh -# Author: Ben Hearsum -# Description: -# This file downloads patches from a webserver and generates sendchange -# commands for each one. It keeps track of the most recent patch by -# maintaining a hardlink to it. It is intended to be used by the -# MozillaDownloadPatch and MozillaCustomPatch steps on the buildbot side. -# It's output is logged in $LOGFILE - -# where to retrieve the patches -- make sure this has a trailing slash -PATCHURL="http://localhost//patches/" -# where the patches go -PATCHDIR="." -# this hardlink points to the latest patche -# it is relative to PATCHDIR -LASTFILE="lastpatch" -# where to log any error messages -LOGFILE="downloader.log" - -PYTHON_PATH="/usr/bin/python" -BUILDBOT_PATH="/usr/bin/buildbot" -MASTER_HOST="localhost:9989" -BRANCH="HEAD_TRY" -# if multiple patches are being this controls the delay between each one -# this value should be more than the treeStableTimer on the Scheduler -DELAY=5 - - -# retrieve the files, but only the new ones -# making sure to have wget ignore the funny index files it downloads -wget --no-check-certificate -r -l1 -np -nc -nd -R"index.html*" -P $PATCHDIR $PATCHURL &>/dev/null - -# only look at the info files; it's not necessary to look at both -files=$(ls -1 $PATCHDIR | grep "\.info$") - -# check for a $LASTFILE hardlink -if [ -e "$PATCHDIR/$LASTFILE" ] -then - # since $LASTFILE exists, find any changes that are newer than it - # and forget about them - for file in $files - do - files=$(echo $files | sed -e "s/$file *//") - if [ "$PATCHDIR/$file" -ef "$PATCHDIR/$LASTFILE" ] - then - break - fi - done -fi - -if [[ $files == "" ]] -then - echo "`date` - No patches, exiting..." >>$LOGFILE - exit 1 -fi - -# any changes that are left need a sendchange generated, so do it! -for file in $files -do - # extract info from the .info file - user=$(cat "$PATCHDIR/$file" | sed -n '1p' | sed -e 's/.*: *//') - patchfile=$(cat "$PATCHDIR/$file" | sed -n '3p' | sed -e 's/.*: *//') - description=$(cat "$PATCHDIR/$file" | sed -n '4p' | sed -e 's/.*: *//') - cat "$PATCHDIR/$file" | sed -n '5,$p' > /tmp/patcher-$$ - while read line - do - description="$description\n$line" - done < /tmp/patcher-$$ - - # send the change to buildbot - $PYTHON_PATH $BUILDBOT_PATH sendchange --username $user \ - --master $MASTER_HOST --branch $BRANCH --comments "$description" \ - $patchfile &>/dev/null - - # TODO: this should only happen if this isn't the last time through the loop - sleep $DELAY -done - -rm /tmp/patcher-$$ - -# now create a hard link to the last file -mostrecent=$(echo $files | sed -e 's/.* //g') -rm "$PATCHDIR/$LASTFILE" 2>/dev/null -ln "$PATCHDIR/$mostrecent" "$PATCHDIR/$LASTFILE" 2>/dev/null - -exit 0 diff --git a/mozilla/webtools/buildbot-try/processchanges.sh b/mozilla/webtools/buildbot-try/processchanges.sh new file mode 100644 index 00000000000..aed40937c20 --- /dev/null +++ b/mozilla/webtools/buildbot-try/processchanges.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# File: processchanges.sh +# Author: Ben Hearsum +# Description: +# This script downloads .info files from a webserver running "sendchange.cgi" +# It then informs Buildbot that either a patch or Mercurial repository is +# ready to be tested. +# It requires the MozillaDownloadPatch and MozillaCustomPatch steps on the +# buildbot side. +# It's output is logged in $LOGFILE + +# where to retrieve the patches -- make sure this has a trailing slash +PATCHURL="http://localhost/patches/" +# where the patches go +PATCHDIR="." +# this hardlink points to the latest patche +# it is relative to PATCHDIR +LASTFILE="lastpatch" +# where to log any error messages +LOGFILE="downloader.log" + +PYTHON_PATH="/usr/bin/python" +BUILDBOT_PATH="/usr/bin/buildbot" +MASTER_HOST="localhost:9989" +PATCH_BRANCH="PATCH_TRY" +HG_BRANCH="HG_TRY" +# if multiple patches are being this controls the delay between each one +# this value should be more than the treeStableTimer on the Scheduler +DELAY=5 + + +# retrieve the files, but only the new ones +# making sure to have wget ignore the funny index files it downloads +wget --no-check-certificate -r -l1 -np -nc -nd -R"index.html*" -P $PATCHDIR $PATCHURL &>/dev/null + +# only look at the info files; it's not necessary to look at both +files=$(ls -1 $PATCHDIR | grep "\.info$") + +# check for a $LASTFILE hardlink +if [ -e "$PATCHDIR/$LASTFILE" ] +then + # since $LASTFILE exists, find any changes that are newer than it + # and forget about them + for file in $files + do + files=$(echo $files | sed -e "s/$file *//") + if [ "$PATCHDIR/$file" -ef "$PATCHDIR/$LASTFILE" ] + then + break + fi + done +fi + +if [[ $files == "" ]] +then + echo "`date` - No patches, exiting..." >>$LOGFILE + exit 1 +fi + +# any changes that are left need a sendchange generated, so do it! +for file in $files +do + # extract info from the .info file + patchfile="" + codeBranch="" # this will be used once multiple branches are supported + mozillaRepo="" + tamarinRepo="" + user=$(cat "$PATCHDIR/$file" | sed -n '1p' | sed -e 's/[^:]*: *//') + changeType=$(cat "$PATCHDIR/$file" | sed -n '3p' | sed -e 's/[^:]*: *//') + if [[ $changeType == "patch" ]] + then + patchfile=$(cat "$PATCHDIR/$file" | sed -n '4p' | sed -e 's/[^:]*: *//') + codeBranch=$(cat "$PATCHDIR/$file" | sed -n '5p' | sed -e 's/[^:]*: *//') + description=$(cat "$PATCHDIR/$file" | sed -n '6,$p') + # get rid of the leading newline on the description + description=$(echo "$description" | sed -e 's/^\n//') + + # TODO: support building different branches + # send the change + $PYTHON_PATH $BUILDBOT_PATH sendchange --username $user \ + --master $MASTER_HOST --branch $PATCH_BRANCH --comments "$description" \ + $patchfile &>/dev/null + elif [[ $changeType == "hg" ]] + then + mozillaRepo=$(cat "$PATCHDIR/$file" | sed -n '4p' | sed -e 's/[^:]*: *//') + tamarinRepo=$(cat "$PATCHDIR/$file" | sed -n '5p' | sed -e 's/[^:]*: *//') + description=$(cat "$PATCHDIR/$file" | sed -n '6,$p') + # get rid of the leading newline on the description + description=$(echo "$description" | sed -e 's/^\n//') + + # send the change to buildbot + $PYTHON_PATH $BUILDBOT_PATH sendchange --username $user \ + --master $MASTER_HOST --branch $HG_BRANCH --comments "$description" \ + $mozillaRepo $tamarinRepo &>/dev/null + fi + + # TODO: this should only happen if this isn't the last time through the loop + sleep $DELAY +done + +# now create a hard link to the last file +mostrecent=$(echo $files | sed -e 's/.* //g') +rm "$PATCHDIR/$LASTFILE" 2>/dev/null +ln "$PATCHDIR/$mostrecent" "$PATCHDIR/$LASTFILE" 2>/dev/null + +exit 0 diff --git a/mozilla/webtools/buildbot-try/sendchange.cgi b/mozilla/webtools/buildbot-try/sendchange.cgi new file mode 100644 index 00000000000..4c067c3bf6e --- /dev/null +++ b/mozilla/webtools/buildbot-try/sendchange.cgi @@ -0,0 +1,407 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use CGI qw/:standard/; +use LWP::Simple qw/!head/; + +# File: sendchange.cgi +# Author: Ben Hearsum +# Description: +# This cgi script displays a simple form that allows a user to submit a diff +# that will eventually be uploaded to a Buildbot master. +# It can also be used to point a Buildbot master at a set of Mercurial +# repositories to build from. +# This script generates a .info file that contains the +# name of the submitter, as read from $ENV['REMOTE_USER'], the date in unix +# time, the description read from the form, and the relevant change +# information (patch file/repository locations). +# This information is used by the download script to generate the +# 'buildbot sendchange' command. + + +# where patches and info files will go after being submitted +my $PATCH_DIR = '/buildbot/patches'; +# the size limit for the file, in bytes +# 10*1024*1024 is 10MB +my $SIZE_LIMIT = 10*1024*1024; +# the URL to the buildbot installation the patches will eventually go to +my $BUILDBOT_URL = 'http://localhost:8010'; +# the URL to the uploadpatch.cgi script +my $UPLOADPATCH_URL = 'http://localhost/cgi-bin/sendchange.cgi'; + +$CGI::POST_MAX = $SIZE_LIMIT; + +sub WriteSuccessPage +{ + print "Content-type: text/html\n\n"; + print <<__END_OF_HTML__; + + + +
Note: Uploaded files must be less than ${limit}kB
+__END_OF_HTML__ + + if ($err) { + print "$err
"; + } + print "\n"; +} + +sub Process +{ + my $time = time(); + # get the parameters + my $name = $ENV{'REMOTE_USER'}; + my $description = param('description'); + my $type = param('type'); + my $patchFile = param('patchfile'); + my $branch = param('branch'); + my $mozillaRepoPath = param('mozilla-repo'); + my $tamarinRepoPath = param('tamarin-repo'); + my ($filename, $infoFile); + + my %args = ( + description => $description, + type => $type, + branch => $branch, + mozillaRepoPath => $mozillaRepoPath, + tamarinRepoPath => $tamarinRepoPath + ); + + if (! $name) { + $args{'err'} = 'You must be logged in to use this service'; + WritePage(%args); + return; + } + + if ($description eq '') { + $description = 'No description given.'; + } + + # only allow alphanumeric, '_', and whitespace + if ($description =~ m/[^\w\s]/) { + $args{'err'} = 'Description must only contain alphanumeric characters,' + . " '_' and whitespace"; + WritePage(%args); + return; + } + $description =~ s/\n//g; + + # Using a patchfile + if ($type eq "patch") { + if ($branch eq '') { + $branch = 'HEAD'; + } elsif ($branch eq 'trunk' || $branch eq '') { + $branch = 'HEAD'; + } else { + # only allow alphanumeric plus '_' + if ($branch =~ /[^\w]/) { + $args{'err'} = 'Branch must only contain alphanumeric ' + . "characters or '_'"; + WritePage(%args); + return; + } + $branch =~ s/\n//g; + } + + # only allow alphanumeric, hyphens, and single dots + if ($patchFile !~ /^([\w-]|\.[\w-])+$/) { + $args{'err'} = 'Invalid filename. Please use only alphanumeric, ' + . '-, _, and single dots'; + WritePage(%args); + return; + } + + # if we get here the file is small enough and passes the filename test + + # pull all of the contents of the file + my $patchHandle = upload('patchfile'); + + # strip off everything except the filename itself + $patchFile =~ s/.*[\/\\](.*)/$1/; + + # generate the filenames + $patchFile = "$time-$patchFile"; + $infoFile = "$patchFile.info"; + + # make sure the file has a non-zero length + # this also handles a case where the file specified doesn't exist + if (-z $patchHandle) { + $args{'err'} = 'Specified file has a length of zero'; + WritePage(%args); + return; + } + + # write the patch + $filename = "$PATCH_DIR/$patchFile"; + if (! open(PATCH, ">$filename")) { + $args{'err'} = 'Server error - Could not open file for writing'; + WritePage(%args); + return; + } + binmode PATCH; + + while (<$patchHandle>) { + print PATCH; + } + close PATCH; + } elsif ($type eq "hg") { + # TODO: is this a valid way to test if there's a repo there? + if (get($mozillaRepoPath) eq '') { + $args{'err'} = 'Mozilla repository path is not valid'; + WritePage(%args); + return; + } + + if (get($tamarinRepoPath) eq '') { + $args{'err'} = 'Tamarin repository path is not valid'; + WritePage(%args); + return; + } + + # generate the infofile name + $infoFile = "$time-hg.info"; + } + + # now write the infofile + $filename = "$PATCH_DIR/$infoFile"; + + if (! open(INFO, ">$filename")) { + $args{'err'} = 'Server error - Could not open file for writing'; + WritePage(%args); + return; + } + + print INFO "submitter: $name\n"; + print INFO "date: $time\n"; + print INFO "type: $type\n"; + if ($type eq "patch") { + print INFO "patchfile: $patchFile\n"; + print INFO "branch: $branch\n"; + } elsif ($type eq "hg") { + print INFO "mozilla-repo: $mozillaRepoPath\n"; + print INFO "tamarin-repo: $tamarinRepoPath\n"; + } + print INFO "description: $description\n"; + + close(INFO); + + WriteSuccessPage(); +} + +if (param()) { + Process(); +} else { + WritePage(); +} diff --git a/mozilla/webtools/buildbot-try/uploadpatch.cgi b/mozilla/webtools/buildbot-try/uploadpatch.cgi deleted file mode 100644 index f3cf2c3a069..00000000000 --- a/mozilla/webtools/buildbot-try/uploadpatch.cgi +++ /dev/null @@ -1,243 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use CGI qw/:standard/; - -# File: uploadpatch.cgi -# Author: Ben Hearsum -# Description: -# This cgi script displays a simple form that allows a user to submit a diff -# that will eventually be uploaded to a Buildbot installation. -# Along with the patch this script generates a .info file that contains the -# name of the submitter, as read from $ENV['REMOTE_USER'], the date, in unix -# time, the name of the patchfile, and the description read from the form. -# This information is used by the download script to generate the -# 'buildbot sendchange' command. - - -# where the patches will go after being submitted -my $PATCH_DIR = '/buildbot/patches'; -# the size limit for the file, in bytes -# 10*1024*1024 is 10MB -my $SIZE_LIMIT = 10*1024*1024; -# the URL to the buildbot installation the patches will eventually go to -my $BUILDBOT_URL = 'http://localhost:8010'; -# the URL to the uploadpatch.cgi script -my $UPLOADPATCH_URL = 'http://localhost/cgi-bin/uploadpatch.cgi'; - -$CGI::POST_MAX = $SIZE_LIMIT; - -sub WriteSuccessPage -{ - print "Content-type: text/html\n\n"; - print <<__END_OF_HTML__; - - - -Note: Uploaded files must be less than ${limit}kB
- - -__END_OF_HTML__ - - if ($err) { - print "$err
"; - } - print "