X-Git-Url: https://git.exim.org/buildfarm-server.git/blobdiff_plain/b0a27e8521e4d827dd1a2cb05bf5c5884822e760..f0286f91a9ec65c30a27f070a179ca9f6de53dbd:/cgi-bin/show_stage_log.pl diff --git a/cgi-bin/show_stage_log.pl b/cgi-bin/show_stage_log.pl index fe2e3ca..38ccf89 100755 --- a/cgi-bin/show_stage_log.pl +++ b/cgi-bin/show_stage_log.pl @@ -1,5 +1,13 @@ #!/usr/bin/perl +=comment + +Copyright (c) 2003-2010, Andrew Dunstan + +See accompanying License file for license details + +=cut + use strict; use DBI; use Template; @@ -8,9 +16,8 @@ use File::Temp qw(tempfile); use vars qw($dbhost $dbname $dbuser $dbpass $dbport @log_file_names); - -require "$ENV{BFConfDir}/BuildFarmWeb.pl"; -#require "BuildFarmWeb.pl"; +use FindBin qw($RealBin); +require "$RealBin/../BuildFarmWeb.pl"; die "no dbname" unless $dbname; die "no dbuser" unless $dbuser; @@ -24,6 +31,7 @@ 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 $stage = $query->param('stg');$stage =~ s/[^a-zA-Z0-9._ -]//g; +my $brnch = $query->param('branch') || 'HEAD'; $brnch =~ s/[^a-zA-Z0-9._ -]//g; use vars qw($tgz); @@ -33,6 +41,20 @@ if ($system && $logdate && $stage) die $DBI::errstr unless $db; + if ($logdate =~ /^latest$/i) + { + my $find_latest = qq{ + select max(snapshot) + from build_status_log + where sysname = ? + and snapshot > now() - interval '30 days' + and log_stage = ? || '.log' + and branch = ? + }; + my $logs = $db->selectcol_arrayref($find_latest,undef,$system,$stage,$brnch); + $logdate = shift(@$logs); + } + my $statement = q( select branch, log_text @@ -40,8 +62,6 @@ if ($system && $logdate && $stage) where sysname = ? and snapshot = ? and log_stage = ? || '.log' ); - - my $sth=$db->prepare($statement); $sth->execute($system,$logdate,$stage); @@ -55,13 +75,11 @@ if ($system && $logdate && $stage) $sth->finish; $db->disconnect; - print "Content-Type: text/plain\n\n", $logtext, + print "Content-Type: text/plain\n\nSnapshot: $logdate\n\n", $logtext, "-------------------------------------------------\n\n", - "Hosting for the PostgreSQL Buildfarm is generously ", - "provided by: CommandPrompt, The PostgreSQL Company"; - - exit; + "Hosting for the Exim BuildFarm is generously ", + "provided by: Host1"; } @@ -69,74 +87,4 @@ else { print "Status: 460 bad parameters\n", "Content-Type: text/plain\n\n"; - exit; -} - -if ($system && $logdate) -{ - - my $db = DBI->connect($dsn,$dbuser,$dbpass); - - die $DBI::errstr unless $db; - - my $statement = q( - - select log_archive - from build_status - where sysname = ? and snapshot = ? - - ); - - - - my $sth=$db->prepare($statement); - $sth->execute($system,$logdate); - my $row=$sth->fetchrow_arrayref; - $tgz=$row->[0]; - $sth->finish; - $db->disconnect; - -} - -unless ($stage) -{ - - print - "Content-Type: application/x-gzip\n", - "Content-Disposition: attachment; filename=buildfarmlog.tgz\n", - "\n", - $tgz; - exit; } - -my $template = "buildlogXXXXXX"; -my ($fh, $filename) = tempfile($template, - DIR => '/home/community/pgbuildfarm/buildlogs', - UNLINK => 1); -print $fh $tgz; -close($fh); - -my $output = `tar -z -O -xf $filename $stage.log 2>&1`; - -print "Content-Type: text/plain\n\n", $output, - - "-------------------------------------------------\n\n", - "Hosting for the PostgreSQL Buildfarm is generously ", - "provided by: CommandPrompt, The PostgreSQL Company"; - -; exit; - -# using
 like this on huge files can make browsers choke
-
-print "Content-Type: text/html\n\n";
-
-print <
-
-
-$output
-
- - - -EOHTML