#!/usr/bin/perl use strict; use DBI; use Template; use CGI; use URI::Escape; use vars qw($dbhost $dbname $dbuser $dbpass $dbport @log_file_names); require "$ENV{BFConfDir}/BuildFarmWeb.pl"; #require "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; my $query = new CGI; my $system = $query->param('nm'); $system =~ s/[^a-zA-Z0-9_ -]//g; my $logdate = $query->param('dt'); $logdate =~ s/[^a-zA-Z0-9_ -]//g; my $log = ""; my $conf = ""; my ($stage,$changed_this_run,$changed_since_success,$sysinfo,$branch,$scmurl); my $scm; use vars qw($info_row); if ($system && $logdate) { my $db = DBI->connect($dsn,$dbuser,$dbpass); die $DBI::errstr unless $db; my $statement = <prepare($statement); $sth->execute($system,$logdate); my $row=$sth->fetchrow_arrayref; $log=$row->[0]; $conf=$row->[1] || "not recorded" ; $stage=$row->[2] || "unknown"; $changed_this_run = $row->[3]; $changed_since_success = $row->[4]; $branch = $row->[5]; my $log_file_names = $row->[6]; $scm = $row->[7]; $scm ||= 'cvs'; # legacy scripts $scmurl = $row->[8]; $log_file_names =~ s/^\{(.*)\}$/$1/; @log_file_names=split(',',$log_file_names) if $log_file_names; $sth->finish; $statement = <prepare($statement); $sth->execute($system); $info_row=$sth->fetchrow_hashref; # $sysinfo = join(" ",@$row); $sth->finish; $db->disconnect; } foreach my $chgd ($changed_this_run,$changed_since_success) { my $cvsurl = 'http://anoncvs.postgresql.org/cvsweb.cgi'; my $giturl = $scmurl || 'http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h='; my @lines = split(/!/,$chgd); foreach (@lines) { if ($scm eq 'git') { s!(^\S+)(\s+)(\S+)!$1!; } elsif ($scm eq 'cvs') { next unless m!^pgsql/!; s!(^\S+)(\s+)(\S+)!$1$2$3!; } } $chgd = join("\n",@lines); $chgd ||= 'not recorded'; } $conf =~ s/\@/ [ a t ] /g; map {s/&/&/g; s//>/g; s/\"/"/g;} ($log,$conf); # map {s/!/\n/g} ($changed_this_run,$changed_since_success); use POSIX qw(ceil); my $lrfactor = 6; my $logrows = ceil(scalar(@log_file_names)/$lrfactor); my $logcells = $lrfactor * $logrows; my $heading_done; my $urldt = uri_escape($logdate); my $cell = 0; print "Content-Type: text/html\n\n"; if ($stage eq 'OK') { print < PostgreSQL BuildFarm | Configuration summary for system "$system"

PostgreSQL Build Farm Log

System Information Farm member Branch OS Compiler Architecture Owner
$system $branch $info_row->{operating_system} $info_row->{os_version} $info_row->{compiler} $info_row->{compiler_version} $info_row->{architecture} $info_row->{owner_email}
EOHTML if ($info_row->{sys_notes}) { print <
System Notes Date Notes
$info_row->{sys_notes_date} $info_row->{sys_notes}
EOHTML } for my $logstage (@log_file_names) { print "
\n" unless $heading_done; $heading_done = 1; $cell++; $logstage =~ s/\.log$//; print "\n" if ($cell > 1 && $cell % $lrfactor == 1); print "\n"; print "\n" if ($cell % $lrfactor == 0); } if ($cell) { foreach my $rcell ($cell+1 .. $logcells) { print "\n" if ($rcell > 1 && $rcell % $lrfactor == 1); print "\n"; print "\n" if ($rcell % $lrfactor == 0); } print "
Stage Logs
$logstage
 
\n"; } print <

Configuration summary for system "$system"

Status 'OK' on snapshot taken $logdate

$conf

Files changed this run

$changed_this_run
EOHTML print <Log
$log
EOHTML print <

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

EOHTML ; exit; } print < PostgreSQL BuildFarm | Log for system "$system" failure on snapshot taken $logdate

PostgreSQL Build Farm Log

Details for system "$system" failure at stage $stage on snapshot taken $logdate

System Information Farm member Branch OS Compiler Architecture Owner
$system $branch $info_row->{operating_system} $info_row->{os_version} $info_row->{compiler} $info_row->{compiler_version} $info_row->{architecture} $info_row->{owner_email}
EOHTML if ($info_row->{sys_notes}) { print <
System Notes Date Notes
$info_row->{sys_notes_date} $info_row->{sys_notes}
EOHTML } for my $logstage (@log_file_names) { print "
\n" unless $heading_done; $heading_done = 1; $cell++; $logstage =~ s/\.log$//; print "\n" if ($cell > 1 && $cell % $lrfactor == 1); print "\n"; print "\n" if ($cell % $lrfactor == 0); } if ($cell) { foreach my $rcell ($cell+1 .. $logcells) { print "\n" if ($rcell > 1 && $rcell % $lrfactor == 1); print "\n"; print "\n" if ($rcell % $lrfactor == 0); } print "
Stage Logs
$logstage
 
\n"; } print <Configuration summary
$conf

Files changed this run

$changed_this_run

Files changed since last success

$changed_since_success

Log

$log

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

EOHTML ;