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/index.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 !~ /^-+$/) {
91 if (my ($diagnostic) = /(error|warning):/i) {
93 $d{DIAGNOSTIC} = lc ($diagnostic);
97 if (@dirstack && defined ($dist_dir)
98 && (my ($match, $file, $line) = /^(([^\s:]+):(\d+):)/)) {
99 $file = File::Spec->rel2abs ($file, $dirstack[$#dirstack]);
100 my (@path) = grep ($_ ne '' && $_ ne '.', split ('/', $file));
101 for (my $i = 1; $i <= $#path; ) {
102 if ($path[$i] eq '..') {
103 splice (@path, $i - 1, 2);
110 for (my $i = $#path; $i >= 0; $i--) {
111 if ($path[$i] eq $dist_dir) {
112 my $dist_file = join ('/', @path[$i..$#path]);
113 if (exists ($dist_files{$dist_file})) {
114 $d{MATCH} = length ($match);
116 $d{FILE} = $dist_file;
122 push (@{$steps[$#steps]{CHILDREN}}, \%d);
124 $log_class = "$diagnostic";
127 printf LOG_HTML "<a name=\"%d\"><tt>%4d</tt></a> ", $ln, $ln;
128 if (defined ($log_class)) {
129 print LOG_HTML "<span class=\"$log_class\">", encode_entities ($_), "</span>\n";
131 print LOG_HTML encode_entities ($_), "\n";
135 open (INDEX, '>','index.html');
140 <link rel="stylesheet" href="build.css">
145 print INDEX "<h1>Build ", $vars{"build_number"}, ": $result</h1>\n";
147 print INDEX "<h2>Build Properties</h2>\n";
148 print INDEX "<table>\n";
149 print INDEX "<tr><th>Name</th><th>Value</th></tr>\n";
150 foreach my $key (sort (keys (%vars))) {
152 print INDEX "<td>", encode_entities ($key), "</td>";
153 print INDEX "<td>", encode_entities ($vars{$key}), "</td>";
154 print INDEX "</tr>\n";
156 print INDEX "</table>\n";
158 print INDEX "<h2>Build Products</h2>\n";
159 print INDEX "<ul>\n";
160 foreach my $p (@products) {
162 print INDEX encode_entities ($p->{NAME}), ": " if defined ($p->{NAME});
163 print INDEX "<a href=\"", encode_entities ($p->{HREF}), "\">";
164 print INDEX encode_entities ($p->{PRODUCT});
165 print INDEX "</a></li>\n";
167 print INDEX "</ul>\n";
171 return "<small><a href=\"log.html#$ln\">(log)</a></small>";
174 print INDEX "<h2>Build Summary</h2>\n";
175 print INDEX "<ol>\n";
176 foreach my $s (@steps) {
177 print INDEX "<li>", encode_entities ($s->{TITLE});
178 print INDEX " ", log_link ($s->{LN});
179 foreach my $c (@{$s->{CHILDREN}}) {
180 if (defined ($c->{DIAGNOSTIC})) {
181 print INDEX "<p class=\"$c->{DIAGNOSTIC}\">";
182 if (defined ($c->{MATCH})) {
183 my $href = $gitweb_url;
184 $href =~ s/\[FILE\]/uri_escape ($c->{FILE})/ge;
185 $href =~ s/\[LINE\]/$c->{LINE}/g;
186 $href =~ s/\[BRANCH\]/uri_escape ($vars{'dist_commit'})/e;
188 print INDEX '<a href="', encode_entities ($href), '">';
189 print INDEX encode_entities (substr ($c->{MESSAGE},
192 print INDEX encode_entities (substr ($c->{MESSAGE},
195 print INDEX encode_entities ($c->{MESSAGE});
197 print INDEX " ", log_link ($c->{LN});
198 print INDEX "</p>\n";
200 print INDEX "<p>→ <a href=\"", encode_entities ($c->{HREF}), "\">";
201 print INDEX encode_entities ($c->{PRODUCT});
203 print INDEX log_link ($c->{LN});
204 print INDEX "</p>\n";
207 print INDEX "</li>\n";
209 print INDEX "</ol>\n";
216 print LOG_HTML <<EOF;
222 open (HTACCESS, '>', '.htaccess');
223 print HTACCESS <<EOF;
227 open (CSS, '>', "build.css");
232 padding: 0em 3em 0em 3em;
236 margin: 0pt 0pt 0pt 0em
258 H1, H2, H3, H4, H5, H6 {
259 font-family: sans-serif;
268 text-decoration: none;
272 text-decoration: none;
276 text-decoration: none;
279 text-decoration: underline