10 my $gitweb_url = 'http://benpfaff.org/cgi-bin/gitweb.cgi?p=pspp;a=blob;f=[FILE];hb=[BRANCH]#l[LINE]';
12 open (LOG, '<', "LOG");
13 open (LOG_HTML, '>', "log.html");
18 <link rel="stylesheet" href="build.css">
22 print LOG_HTML "<pre>";
27 if (open (VARS, "<", $file)) {
30 my ($key, $value) = /^([^=]+)=(.*)/ or next;
37 my (%vars) = read_vars ('VARS');
41 my ($result) = "failure";
49 if (/Entering directory `(.*)'$/) {
51 } elsif (/Leaving directory `(.*)'$/) {
56 if (my ($title) = /^## (.*) ##$/) {
58 if (my ($name, $product) = $title =~ /^Saving(?:\s+([^:]*):)?\s+(.*)$/) {
59 my $href = "$product/summary.html";
60 $href = $product if ! -e $href;
63 $p{NAME} = $name if defined ($name);
64 $p{PRODUCT} = $product;
67 push (@products, \%p);
68 push (@{$steps[$#steps]{CHILDREN}}, \%p);
70 if (defined ($name) && $name eq 'source distribution') {
71 open (DIST, '-|', "zcat $product | tar tf -");
72 while (my $line = <DIST>) {
74 $line =~ s%^([./])*%%; # Trim leading ./
75 $dist_files{$line} = 1;
76 if (!defined ($dist_dir)) {
77 $dist_dir = (split ('/', $line))[0];
82 } elsif ($title eq 'Success') {
84 } elsif ($title !~ /^-+$/) {
92 $diagnostic = "error" if /error:/i || /FAILED/;
93 $diagnostic = "warning" if /warning:/i;
96 $d{DIAGNOSTIC} = $diagnostic;
100 if (@dirstack && defined ($dist_dir)
101 && (my ($match, $file, $line) = /^(([^\s:]+):(\d+):)/)) {
102 $file = File::Spec->rel2abs ($file, $dirstack[$#dirstack]);
103 my (@path) = grep ($_ ne '' && $_ ne '.', split ('/', $file));
104 for (my $i = 1; $i <= $#path; ) {
105 if ($path[$i] eq '..') {
106 splice (@path, $i - 1, 2);
113 for (my $i = $#path; $i >= 0; $i--) {
114 if ($path[$i] eq $dist_dir) {
115 my $dist_file = join ('/', @path[$i..$#path]);
116 if (exists ($dist_files{$dist_file})) {
117 $d{MATCH} = length ($match);
119 $d{FILE} = $dist_file;
125 push (@{$steps[$#steps]{CHILDREN}}, \%d);
128 printf LOG_HTML "<a name=\"%d\"><tt>%4d</tt></a> ", $ln, $ln;
129 if (defined ($log_class)) {
130 print LOG_HTML "<span class=\"$log_class\">", encode_entities ($_), "</span>\n";
132 print LOG_HTML encode_entities ($_), "\n";
136 open (INDEX, '>','summary.html');
141 <link rel="stylesheet" href="build.css">
146 print INDEX "<h1>Build ", $vars{"BUILD_NUMBER"}, ": $result</h1>\n";
148 print INDEX "<h2>Build Properties</h2>\n";
149 print INDEX "<table>\n";
150 print INDEX "<tr><th>Name</th><th>Value</th></tr>\n";
151 foreach my $key (sort (keys (%vars))) {
153 print INDEX "<td>", encode_entities ($key), "</td>";
154 print INDEX "<td>", encode_entities ($vars{$key}), "</td>";
155 print INDEX "</tr>\n";
157 print INDEX "</table>\n";
159 print INDEX "<h2>Build Products</h2>\n";
160 print INDEX "<ul>\n";
161 foreach my $p (@products) {
163 print INDEX encode_entities ($p->{NAME}), ": " if defined ($p->{NAME});
164 print INDEX "<a href=\"", encode_entities ($p->{HREF}), "\">";
165 print INDEX encode_entities ($p->{PRODUCT});
166 print INDEX "</a></li>\n";
168 print INDEX "</ul>\n";
172 return "<small><a href=\"log.html#$ln\">(log)</a></small>";
175 print INDEX "<h2>Build Summary</h2>\n";
176 print INDEX "<ol>\n";
177 foreach my $s (@steps) {
178 print INDEX "<li>", encode_entities ($s->{TITLE});
179 print INDEX " ", log_link ($s->{LN});
180 foreach my $c (@{$s->{CHILDREN}}) {
181 if (defined ($c->{DIAGNOSTIC})) {
182 print INDEX "<p class=\"$c->{DIAGNOSTIC}\">";
183 if (defined ($c->{MATCH})) {
184 my $href = $gitweb_url;
185 $href =~ s/\[FILE\]/uri_escape ($c->{FILE})/ge;
186 $href =~ s/\[LINE\]/$c->{LINE}/g;
187 $href =~ s/\[BRANCH\]/uri_escape ($vars{'dist_commit'})/e;
189 print INDEX '<a href="', encode_entities ($href), '">';
190 print INDEX encode_entities (substr ($c->{MESSAGE},
193 print INDEX encode_entities (substr ($c->{MESSAGE},
196 print INDEX encode_entities ($c->{MESSAGE});
198 print INDEX " ", log_link ($c->{LN});
199 print INDEX "</p>\n";
201 print INDEX "<p>→ <a href=\"", encode_entities ($c->{HREF}), "\">";
202 print INDEX encode_entities ($c->{PRODUCT});
204 print INDEX log_link ($c->{LN});
205 print INDEX "</p>\n";
208 print INDEX "</li>\n";
210 print INDEX "</ol>\n";
217 print LOG_HTML <<EOF;
223 open (HTACCESS, '>', '.htaccess');
224 print HTACCESS <<EOF;
228 open (CSS, '>', "build.css");
233 padding: 0em 3em 0em 3em;
237 margin: 0pt 0pt 0pt 0em
259 H1, H2, H3, H4, H5, H6 {
260 font-family: sans-serif;
269 text-decoration: none;
273 text-decoration: none;
277 text-decoration: none;
280 text-decoration: underline