From d8818469c070065e44415ede75007d5f3b276ea3 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Wed, 13 Oct 2010 15:10:26 +0000 Subject: [PATCH] add some missing files, complete separation of templates, factor common page wrapper from templates --- cgi-bin/addnotes.pl | 116 +++++++++++++++++++++++++++++++ cgi-bin/register.pl | 67 +++--------------- cgi-bin/show_members.pl | 27 +++++-- htdocs/img/git.png | Bin 0 -> 164 bytes htdocs/img/info.gif | Bin 0 -> 83 bytes htdocs/img/vpath.png | Bin 0 -> 578 bytes htdocs/index.html | 77 ++++++++++---------- templates/bfwrapper.tt | 49 ------------- templates/dashboard.tt | 77 -------------------- templates/history.tt | 78 ++++++--------------- templates/index.tt | 38 ++++++++++ templates/log.tt | 44 +++--------- templates/members.tt | 54 ++------------ templates/page.tt | 39 +++++++++++ templates/register-form.tt | 51 ++------------ templates/register-incomplete.tt | 9 +++ templates/register-ok.tt | 8 +++ templates/status.tt | 54 ++------------ 18 files changed, 328 insertions(+), 460 deletions(-) create mode 100755 cgi-bin/addnotes.pl create mode 100644 htdocs/img/git.png create mode 100644 htdocs/img/info.gif create mode 100644 htdocs/img/vpath.png delete mode 100644 templates/bfwrapper.tt delete mode 100644 templates/dashboard.tt create mode 100644 templates/index.tt create mode 100644 templates/page.tt create mode 100644 templates/register-incomplete.tt create mode 100644 templates/register-ok.tt diff --git a/cgi-bin/addnotes.pl b/cgi-bin/addnotes.pl new file mode 100755 index 0000000..acab114 --- /dev/null +++ b/cgi-bin/addnotes.pl @@ -0,0 +1,116 @@ +#!/usr/bin/perl + +use strict; + +use CGI; +use Digest::SHA1 qw(sha1_hex); +use MIME::Base64; +use DBI; +use DBD::Pg; +use Data::Dumper; + +use vars qw($dbhost $dbname $dbuser $dbpass $dbport); + +my $query = new CGI; + +my $sig = $query->path_info; +$sig =~ s!^/!!; + +my $animal = $query->param('animal'); +my $sysnotes = $query->param('sysnotes'); + +my $content = "animal=$animal\&sysnotes=$sysnotes"; + +require "$ENV{BFConfDir}/BuildFarmWeb.pl"; + +die "no dbname" unless $dbname; +die "no dbuser" unless $dbuser; + +my $dsn="dbi:Pg:dbname=$dbname"; +$dsn .= ";host=$dbhost" if $dbhost; +$dsn .= ";port=$dbport" if $dbport; + +unless ($animal && defined($sysnotes) && $sig) +{ + print + "Status: 490 bad parameters\nContent-Type: text/plain\n\n", + "bad parameters for request\n"; + exit; + +} + + +my $db = DBI->connect($dsn,$dbuser,$dbpass); + +die $DBI::errstr unless $db; + +my $gethost= + "select secret from buildsystems where name = ? and status = 'approved'"; +my $sth = $db->prepare($gethost); +$sth->execute($animal); +my ($secret)=$sth->fetchrow_array(); +$sth->finish; + + +unless ($secret) +{ + print + "Status: 495 Unknown System\nContent-Type: text/plain\n\n", + "System $animal is unknown\n"; + $db->disconnect; + exit; + +} + + + + +my $calc_sig = sha1_hex($content,$secret); + +if ($calc_sig ne $sig) +{ + + print "Status: 450 sig mismatch\nContent-Type: text/plain\n\n"; + print "$sig mismatches $calc_sig on content:\n$content"; + $db->disconnect; + exit; +} + +# undo escape-proofing of base64 data and decode it +map {tr/$@/+=/; $_ = decode_base64($_); } + ($sysnotes); + +my $set_notes = q{ + + update buildsystems + set sys_notes = nullif($2,''), + sys_notes_ts = case + when coalesce($2,'') <> '' then now() + else null + end + where name = $1 + and status = 'approved' + +}; + +$sth = $db->prepare($set_notes); +my $rv = $sth->execute($animal,$sysnotes); +unless($rv) +{ + print "Status: 460 old data fetch\nContent-Type: text/plain\n\n"; + print "error: ",$db->errstr,"\n"; + $db->disconnect; + exit; +} + +$sth->finish; + + + +$db->disconnect; + +print "Content-Type: text/plain\n\n"; +print "request was on:\n$content\n"; + + + diff --git a/cgi-bin/register.pl b/cgi-bin/register.pl index 7f8d6fc..b15a0e2 100755 --- a/cgi-bin/register.pl +++ b/cgi-bin/register.pl @@ -7,61 +7,16 @@ use CGI; use Template; use Captcha::reCAPTCHA; -use vars qw($dbhost $dbname $dbuser $dbpass $dbport $notifyapp $captcha_pubkey $captcha_privkey); +use vars qw($dbhost $dbname $dbuser $dbpass $dbport $notifyapp $captcha_pubkey $captcha_privkey $template_dir); require "$ENV{BFConfDir}/BuildFarmWeb.pl"; -#require "BuildFarmWeb.pl"; my $dsn="dbi:Pg:dbname=$dbname"; $dsn .= ";host=$dbhost" if $dbhost; $dsn .= ";port=$dbport" if $dbport; -my $header = < - - - - PostgreSQL BuildFarm Application - - - - - -
- -
-EOS - -my $footer = < -
-

-Hosting for the PostgreSQL Buildfarm is generously -provided by: -CommandPrompt, -The PostgreSQL Company -

-
- - -EOS - +my $template_opts = { INCLUDE_PATH => $template_dir}; +my $template = new Template($template_opts); my $query = new CGI; my $params = $query->Vars; @@ -80,11 +35,9 @@ my $captcha_ok = $captcha->check_answer unless ($os && $osv && $comp && $compv && $arch && $email && $owner && $captcha_ok->{is_valid}) { - print "Content-Type: text/html\n\n", - $header, - "

You need to complete all the form items. Please try again.

\n", - $footer; - exit; + print "Content-Type: text/html\n\n"; + $template->process('register-incomplete.tt'); + exit; } # some idiot has a script that tries to talk to me @@ -157,12 +110,10 @@ my $sth=$db->prepare($statement); my $rv=$sth->execute($dummyname,$secret,$os,$osv,$comp,$compv, $arch,$owner,$email); my $err=$db->errstr; -print "Content-type: text/html\n\n"; -print $header - , "

PostgreSQL BuildFarm Application received

\n" - , "

Thank you. You should hear from us shortly.

" - , $footer; +# everything looks OK, so tell them so +print "Content-type: text/html\n\n"; +$template->process('register-ok.tt'); $sth->finish; $db->disconnect; diff --git a/cgi-bin/show_members.pl b/cgi-bin/show_members.pl index 2b6e0be..61c621a 100755 --- a/cgi-bin/show_members.pl +++ b/cgi-bin/show_members.pl @@ -31,7 +31,7 @@ my $db = DBI->connect($dsn,$dbuser,$dbpass); # there is possibly some redundancy in this query, but it makes # a lot of the processing simpler. -my $statement = < 'HEAD', branch desc - ) as branches + ) as branches, + ARRAY(select compiler_version || '\t' || os_version || '\t' || effective_date + from personality p + where p.name = s.name + order by effective_date + ) as personalities from buildsystems s where status = 'approved' - order by $sort_by +}; -EOS -; +$statement .= "order by $sort_by"; my $statrows=[]; my $sth=$db->prepare($statement); @@ -54,6 +58,19 @@ $sth->execute; while (my $row = $sth->fetchrow_hashref) { $row->{branches} =~ s/^\{(.*)\}$/$1/; + my $personalities = $row->{personalities}; + $personalities =~ s/^\{(.*)\}$/$1/; + my @personalities = split($personalities,','); + $row->{personalities} = []; + foreach my $personality (@personalities) + { + $personality =~ s/^"(.*)"$/$1/; + $personality =~ s/\\(.)/$1/g; + my ($compiler_version, $os_version, $effective_date) = split(/\t/,$personality); + push(@{$row->{personalities}}, {compiler_version => $compiler_version, + os_version => $os_version, + effective_date => $effective_date }); + } $row->{owner_email} =~ s/\@/ [ a t ] /; push(@$statrows,$row); } diff --git a/htdocs/img/git.png b/htdocs/img/git.png new file mode 100644 index 0000000000000000000000000000000000000000..de637c0608090162a6ce6b51d5f9bfe512cf8bcf GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9JOMr-t_OgO28RD&a4c8tKak5= z;1OBOz`!jG!i)^F=12eq?L1u^Ln;_q4{j86a1dcV@b%g0mmUiOK9(+Io+#BK-XURJ z*52lzAh4o%_q+oa1XgVS7Wa3@eurhH>!fs<8s*Qab3eLq`JX({BnD4cKbLh*2~7aN C3N}^% literal 0 HcmV?d00001 diff --git a/htdocs/img/info.gif b/htdocs/img/info.gif new file mode 100644 index 0000000000000000000000000000000000000000..ef510fa1fe5bbb13837b14ac4b0a4be77cf08dd6 GIT binary patch literal 83 zcmZ?wbh9u|6krfwSjfnbHuKE?|Nrmay$d9D7=QpI&cLM8)1P_Z?Y?;_6XhZq4>8`G k?(3_Ob+>}!!A*{~SGIW!i$CqYSMu(Rq-GF@AS;740EE*b9{>OV literal 0 HcmV?d00001 diff --git a/htdocs/img/vpath.png b/htdocs/img/vpath.png new file mode 100644 index 0000000000000000000000000000000000000000..9859b01d3197f46de98c820faf6b0af9a182699f GIT binary patch literal 578 zcmV-I0=@l-P)32H3Ind1!5nc&VRKSaFE;#)M&&w)pjYF1&i^*hEhpudG zVXaoXPr&W~;Ir@N%B@zt`?gIJC&tHvVj@DmT>hef=Q=b1D8MaA`9{A(Nc$UW^*UBI zHy;qt8VUe_PrjceZH=DpLi|v`vwp1yuW5gdH@Qjd~Y-s zb~_#DljO_giXxgH7!3gHPZ&VjG>mHw=aaF~(ZdesiK6E{*-`50Fu;GuUnl3@)`#My QlmGw#07*qoM6N<$g05Q%g#Z8m literal 0 HcmV?d00001 diff --git a/htdocs/index.html b/htdocs/index.html index 0968db1..b17ceb2 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -1,31 +1,33 @@ - - - PostgreSQL BuildFarm - - - - - -
- -
+ --> + + +
+ +
+ +

The PostgreSQL build farm is a distributed system for automatically testing changes in the source code for PostgreSQL as they occur, on a wide variety @@ -42,22 +44,23 @@ the Registration Page. We are particularly interested in unusual platforms or combinations of architecture, operating system and compiler.

-

To see what is involved in running a buildfarm member, please visit the +

To see what is involved in running a buildfarm member, please +read http://wiki.postgresql.org/wiki/PostgreSQL_Buildfarm_Howto. +The client code can be found at the project page at -PGFoundry and -especially read the -HowTo documentation. +PGFoundry.

The build farm software should run on all platforms that can support PostgreSQL.

-
-
-

-Hosting for the PostgreSQL Buildfarm is generously -provided by: -CommandPrompt, -The PostgreSQL Company -

-
- + +
+
+

+ Hosting for the PostgreSQL Buildfarm is generously + provided by: + CommandPrompt, The PostgreSQL Company +

+
+ + diff --git a/templates/bfwrapper.tt b/templates/bfwrapper.tt deleted file mode 100644 index 75cd7a6..0000000 --- a/templates/bfwrapper.tt +++ /dev/null @@ -1,49 +0,0 @@ - - - - - PostgreSQL BuildFarm Status - - - - - - - diff --git a/templates/dashboard.tt b/templates/dashboard.tt deleted file mode 100644 index e7e7ee0..0000000 --- a/templates/dashboard.tt +++ /dev/null @@ -1,77 +0,0 @@ -[% - flag_imgs = { - perl = '/img/camel.png', - python = '/img/python.png', - debug = '/img/bug.png', - pam => '/img/pam.png', - cassert => '/img/cassert.png', - openssl => '/img/ssl_icon.gif', - nls => '/img/translateicon.gif', - krb5 => '/img/krb.gif', - tcl => '/img/tcl.png', - 'thread-safety' => '/img/threads.gif', - 'integer-datetimes' = '/img/days.png', - } --%] -[%- BLOCK img ; - IF flag == 'depend' or flag == 'gnu-ld' ; ; - ELSIF flag_imgs.$flag ; - FILTER collapse %][% flag %] - [% END ; - END; - END --%] -[%- BLOCK cl %] class="[% SWITCH bgfor -%] - [%- CASE 'OK' %]pass[% CASE 'ContribCheck' %]warn[% CASE [ 'Check' 'InstallCheck' ] %]warnx[% CASE %]fail[% END %]" -[%- END -%] - -
-

PostgreSQL BuildFarm Status

-

- Shown here is the latest status of each farm member - for each branch it has reported on in the last 30 days. -

-

- Use the farm member link for history of that member - on the relevant branch. -

- -[% FOREACH flagset IN flag_imgs %] - -[% IF loop.count == 5 %][% END %] -[% END %] -
Legend[% flagset.key %] = [% flagset.key %]
-
- -[% brch = "" %] -[% FOREACH row IN statrows %] -[% IF row.branch != brch ; brch = row.branch %] - - -[% END %] - - - - - - - -[% END %] -
Branch: [% brch %]
AliasSystemStatusFlags
[% row.sysname %][% row.operating_system %] - [% row.os_version %] - [%- row.compiler %] - [% row.compiler_version %] - [%- row.architecture %] - [%- row.when_ago | replace('\s',' ') %] ago  - [% row.stage -%] - - [%- IF row.stage != 'OK' %]Details[% ELSE %]Config[% END -%][% FOREACH flag IN row.build_flags.split().sort() ; PROCESS img ; END %]
-
- diff --git a/templates/history.tt b/templates/history.tt index 27a5be1..d0510e6 100644 --- a/templates/history.tt +++ b/templates/history.tt @@ -1,78 +1,42 @@ [%- BLOCK cl %] class="[% SWITCH bgfor -%] [%- CASE 'OK' %]pass[% CASE 'ContribCheck' %]warn[% CASE [ 'Check' 'InstallCheck' ] %]warnx[% CASE %]fail[% END %]" [%- END -%] - - - - - PostgreSQL BuildFarm History - - - - - -
- -
+[% WRAPPER 'page.tt' + title = 'PostgreSQL BuildFarm History' + bodyclass = 'history' + pagebutton = 'none' +%]

PostgreSQL BuildFarm Status History

- +
- - -
System Detail
Farm member[% member %]
OS[% statrows.0.operating_system %] [% statrows.0.os_version %]
Compiler[% statrows.0.compiler %] [% statrows.0.compiler_version %]
Architecture[% statrows.0.architecture %]
Owner[% statrows.0.owner_email %]
-

Branch: [% branch %][% IF statrows.size >= hm %] (last [% hm %] entries shown)[% END %]

+ +

Branch: [% branch %][% IF statrows.size >= hm %] (last [% hm %] entries shown)[% END %]

[% BLOCK stdet %] - - [%- row.when_ago | replace('\s',' ') %] ago  - [% row.stage -%] - [% row.stage -%] + [%- IF row.stage != 'OK' %]Details[% ELSE %]Config[% END -%] - + [% END %] -[% FOREACH offset IN [0,1,2] %][% low = offset * statrows.size / 3 ; high = -1 + (offset + 1) * statrows.size / 3 %] -[% TRY %][% PERL %] - use POSIX qw(floor); - $stash->set(low => floor($stash->get('low'))); - $stash->set(high => floor($stash->get('high'))); -[% END %][% CATCH %] [% END %] + [% FOREACH offset IN [0,1,2] %][% low = offset * statrows.size / 3 ; high = -1 + (offset + 1) * statrows.size / 3 %] + [% TRY %][% PERL %] + use POSIX qw(floor); + $stash->set(low => floor($stash->get('low'))); + $stash->set(high => floor($stash->get('high'))); + [% END %][% CATCH %] [% END %] -[% END %] + [% END %]
- [% FOREACH xrow IN statrows.slice(low,high) %][% PROCESS stdet row=xrow %][% END %]
-
-
-

-Hosting for the PostgreSQL Buildfarm is generously -provided by: -CommandPrompt, -The PostgreSQL Company -

-
- - +[% END %] diff --git a/templates/index.tt b/templates/index.tt new file mode 100644 index 0000000..ad99339 --- /dev/null +++ b/templates/index.tt @@ -0,0 +1,38 @@ +[%# + + Use this template to generate the index page, with something like: + + tpage index.tt > ../htdocs/index.html + +-%] +[% WRAPPER 'page.tt' + title = 'PostgreSQL BuildFarm' + bodyclass = 'none' + pagebutton = 'home' +%] + +

+The PostgreSQL build farm is a distributed system for automatically testing +changes in the source code for PostgreSQL as they occur, on a wide variety +of platforms. This server is the central repository for the results of those +tests. +

+

+To see the current status of tests on various branches, check the +Status Page. +

+

+If you are interested in running a member of the build farm, then please visit +the Registration Page. +We are particularly interested in unusual platforms or combinations of +architecture, operating system and compiler. +

+

To see what is involved in running a buildfarm member, please +read http://wiki.postgresql.org/wiki/PostgreSQL_Buildfarm_Howto. +The client code can be found at the +project page at +PGFoundry. +

+

The build farm software should run on all platforms that can support PostgreSQL. +

+[% END %] diff --git a/templates/log.tt b/templates/log.tt index 291cbdb..da255f2 100644 --- a/templates/log.tt +++ b/templates/log.tt @@ -8,35 +8,17 @@ $stash->set( logcells => $logcells); $stash->set( logrows => $logrows ); [% END -%] +[% mytitle = BLOCK %]PostgreSQL BuildFarm | [% IF stage != 'OK' %]Log for system "[% system %]" failure on snapshot taken [% urldt ; ELSE %]Configuration summary for system "[% system %]" snapshot taken [% urldt ; END ; END -%] [% cvsurl = 'http://anoncvs.postgresql.org/cvsweb.cgi'; giturl = scmurl || 'http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h='; -%] - - - - - PostgreSQL BuildFarm | [% IF stage != 'OK' %]Log for system "[% system %]" failure on snapshot taken [% urldt ; ELSE %]Configuration summary for system "[% system %]" snapshot taken [% urldt ; END %] - - - - -
- -
-

PostgreSQL Build Farm Log

+[% WRAPPER 'page.tt' + title = mytitle + bodyclass = 'none' + pagebutton = 'none' +%] +

PostgreSQL Build Farm Log

Details for system "[% system %]"[% IF stage != 'OK' %] failure at stage [% stage ; ELSE %], status 'OK'[% END %], snapshot taken [% urldt %]

@@ -118,14 +100,4 @@ not recorded
 [% log | html %]
 
- -
-

-Hosting for the PostgreSQL Buildfarm is generously -provided by: -CommandPrompt, -The PostgreSQL Company -

- - - +[% END %] diff --git a/templates/members.tt b/templates/members.tt index 7e737b4..18bb907 100644 --- a/templates/members.tt +++ b/templates/members.tt @@ -1,32 +1,8 @@ - - - - - PostgreSQL BuildFarm Members - - - - - - -
- -
+[% WRAPPER 'page.tt' + title = 'PostgreSQL BuildFarm Members' + bodyclass = 'members' + pagebutton = 'members' +%]

PostgreSQL BuildFarm Members

Click branch links to see build history. Click the heading links to resort the list. Select members by checkbox and hit the button at the bottom to create a status custom filter.

@@ -72,22 +48,4 @@
-
-
-

-Hosting for the PostgreSQL Buildfarm is generously -provided by: -CommandPrompt, -The PostgreSQL Company -

-
- - - - - - - - - - +[% END %] diff --git a/templates/page.tt b/templates/page.tt new file mode 100644 index 0000000..f00da9b --- /dev/null +++ b/templates/page.tt @@ -0,0 +1,39 @@ + + + + + [% title %] + + + + + +
+ +
+ [% content %] +
+
+

+ Hosting for the PostgreSQL Buildfarm is generously + provided by: + CommandPrompt, The PostgreSQL Company +

+
+ + diff --git a/templates/register-form.tt b/templates/register-form.tt index 13c8a4d..0f4f82b 100644 --- a/templates/register-form.tt +++ b/templates/register-form.tt @@ -1,31 +1,8 @@ - - - - - PostgreSQL BuildFarm Application - - - - - -
- -
+[% WRAPPER 'page.tt' + title = 'PostgreSQL BuildFarm Application' + bodyclass = 'application' + pagebutton = 'register' +%]

Application to join PostgreSQL BuildFarm

Here is a short description of what is required to join the buildfarm successfully. Please read it carefully @@ -48,10 +25,6 @@ before submitting this form.

  • when you receive credentials, put them in the config file, and schedule regular builds (without those flags) for the branches you want to support - which should be at least HEAD and the most recent stable branch.
  • - -

    There is also some extra information in this -article about buildfarm on the O'Reilly network.

    -

    Please complete all items.

    @@ -96,16 +69,4 @@ Systems is "Fedora Core" and the version is "4".

    -
    -
    -

    -Hosting for the PostgreSQL Buildfarm is generously -provided by: -CommandPrompt, -The PostgreSQL Company -

    -
    - - - - +[% END %] diff --git a/templates/register-incomplete.tt b/templates/register-incomplete.tt new file mode 100644 index 0000000..bc73f41 --- /dev/null +++ b/templates/register-incomplete.tt @@ -0,0 +1,9 @@ +[% WRAPPER 'page.tt' + title = 'PostgreSQL BuildFarm Application' + bodyclass = 'application' + pagebutton = 'none' +%] +

    You need to complete all the form items. +Please click here to try again. +

    +[% END %] diff --git a/templates/register-ok.tt b/templates/register-ok.tt new file mode 100644 index 0000000..fdfea96 --- /dev/null +++ b/templates/register-ok.tt @@ -0,0 +1,8 @@ +[% WRAPPER 'page.tt' + title = 'PostgreSQL BuildFarm Application' + bodyclass = 'application' + pagebutton = 'none' +%] +

    PostgreSQL BuildFarm Application received

    \ +

    Thank you. You should hear from us shortly.

    +[% END %] diff --git a/templates/status.tt b/templates/status.tt index 23fcff2..32a17d6 100644 --- a/templates/status.tt +++ b/templates/status.tt @@ -22,35 +22,11 @@ [%- BLOCK cl %] class="[% SWITCH bgfor.replace('-.*','') -%] [%- CASE 'OK' %]pass[% CASE 'ContribCheck' %]warn[% CASE [ 'Check' 'InstallCheck' ] %]warnx[% CASE %]fail[% END %]" [%- END -%] - - - - - PostgreSQL BuildFarm Status - - - - - -
    - -
    +[% WRAPPER 'page.tt' + title = 'PostgreSQL BuildFarm Status' + bodyclass = 'none' + pagebutton = 'status' +%]

    PostgreSQL BuildFarm Status

    Shown here is the latest status of each farm member @@ -96,22 +72,4 @@ [% END %] -

    -
    -

    -The PostgreSQL Buildfarm website is provided by: -CommandPrompt, -The PostgreSQL Company
    -The PostgreSQL community makes it work! -

    -
    - - - - - - - - - - +[% END %] -- 2.30.2