7 use File::Temp qw(tempfile);
9 use vars qw($dbhost $dbname $dbuser $dbpass $dbport @log_file_names);
12 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
13 #require "BuildFarmWeb.pl";
15 die "no dbname" unless $dbname;
16 die "no dbuser" unless $dbuser;
18 my $dsn="dbi:Pg:dbname=$dbname";
19 $dsn .= ";host=$dbhost" if $dbhost;
20 $dsn .= ";port=$dbport" if $dbport;
24 my $system = $query->param('nm'); $system =~ s/[^a-zA-Z0-9_ -]//g;
25 my $logdate = $query->param('dt');$logdate =~ s/[^a-zA-Z0-9_ -]//g;
26 my $stage = $query->param('stg');$stage =~ s/[^a-zA-Z0-9_ -]//g;
30 if ($system && $logdate && $stage)
32 my $db = DBI->connect($dsn,$dbuser,$dbpass);
34 die $DBI::errstr unless $db;
38 select branch, log_text
40 where sysname = ? and snapshot = ? and log_stage = ? || '.log'
46 my $sth=$db->prepare($statement);
47 $sth->execute($system,$logdate,$stage);
48 my $row=$sth->fetchrow_arrayref;
49 my ($branch, $logtext) = ("unknown","no log text found");
58 print "Content-Type: text/plain\n\n", $logtext,
60 "-------------------------------------------------\n\n",
61 "Hosting for the PostgreSQL Buildfarm is generously ",
62 "provided by: CommandPrompt, The PostgreSQL Company";
70 print "Status: 460 bad parameters\n",
71 "Content-Type: text/plain\n\n";
75 if ($system && $logdate)
78 my $db = DBI->connect($dsn,$dbuser,$dbpass);
80 die $DBI::errstr unless $db;
86 where sysname = ? and snapshot = ?
92 my $sth=$db->prepare($statement);
93 $sth->execute($system,$logdate);
94 my $row=$sth->fetchrow_arrayref;
105 "Content-Type: application/x-gzip\n",
106 "Content-Disposition: attachment; filename=buildfarmlog.tgz\n",
112 my $template = "buildlogXXXXXX";
113 my ($fh, $filename) = tempfile($template,
114 DIR => '/home/community/pgbuildfarm/buildlogs',
119 my $output = `tar -z -O -xf $filename $stage.log 2>&1`;
121 print "Content-Type: text/plain\n\n", $output,
123 "-------------------------------------------------\n\n",
124 "Hosting for the PostgreSQL Buildfarm is generously ",
125 "provided by: CommandPrompt, The PostgreSQL Company";
129 # using <pre> like this on huge files can make browsers choke
131 print "Content-Type: text/html\n\n";