8 use HTML::Entities qw();
12 return HTML::Entities::encode_entities($_[0], "<&>'\"");
15 my $gitweb_url = 'http://benpfaff.org/cgi-bin/gitweb.cgi?p=pspp;a=blob;f=[FILE];hb=[BRANCH]#l[LINE]';
17 open (LOG, '<', "LOG");
18 open (LOG_HTML, '>', "log.html");
23 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
24 <link rel="stylesheet" href="build.css">
28 print LOG_HTML "<pre>";
33 if (open (VARS, "<", $file)) {
36 my ($key, $value) = /^([^=]+)=(.*)/ or next;
43 my (%vars) = read_vars ('VARS');
48 my ($result) = "failure";
59 print LOG_HTML "</pre><hr><pre>\n";
63 if (/Entering directory `(.*)'$/) {
65 } elsif (/Leaving directory `(.*)'$/) {
73 if (my ($name, $product) = /^Saving(?:\s+([^:]*):)?\s+(.*)$/) {
74 my $href = "$product/index.html";
75 $href = $product if ! -e $href;
78 $p{NAME} = $name if defined ($name);
79 $p{PRODUCT} = $product;
82 push (@products, \%p);
83 push (@{$steps[$#steps]{CHILDREN}}, \%p) if @steps;
85 if (defined ($name) && $name eq 'source distribution') {
86 open (DIST, '-|', "zcat $product | tar tf -");
87 while (my $line = <DIST>) {
89 $line =~ s%^([./])*%%; # Trim leading ./
90 $dist_files{$line} = 1;
91 if (!defined ($dist_dir)) {
92 $dist_dir = (split ('/', $line))[0];
103 $result = 'success' if $_ eq 'Success';
105 if (my ($diagnostic) = /(error|warning):/i) {
107 $d{DIAGNOSTIC} = lc ($diagnostic);
111 if (@dirstack && defined ($dist_dir)
112 && (my ($match, $file, $line) = /^(([^\s:]+):(\d+):)/)) {
113 $file = File::Spec->rel2abs ($file, $dirstack[$#dirstack]);
114 my (@path) = grep ($_ ne '' && $_ ne '.', split ('/', $file));
115 for (my $i = 1; $i <= $#path; ) {
116 if ($path[$i] eq '..') {
117 splice (@path, $i - 1, 2);
124 for (my $i = $#path; $i >= 0; $i--) {
125 if ($path[$i] eq $dist_dir) {
126 my $dist_file = join ('/', @path[$i..$#path]);
127 if (exists ($dist_files{$dist_file})) {
128 $d{MATCH} = length ($match);
130 $d{FILE} = $dist_file;
136 push (@{$steps[$#steps]{CHILDREN}}, \%d);
138 $log_class = "$diagnostic";
141 printf LOG_HTML "<a name=\"%d\"><tt>%4d</tt></a> ", $ln, $ln;
142 if (defined ($log_class)) {
143 print LOG_HTML "<span class=\"$log_class\">", encode_entities ($_), "</span>\n";
145 print LOG_HTML encode_entities ($_), "\n";
149 open (INDEX, '>','index.html');
154 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
155 <link rel="stylesheet" href="build.css">
160 print INDEX "<h1>Build ", $vars{"build_number"}, ": $result</h1>\n";
162 print INDEX "<h2>Build Properties</h2>\n";
163 print INDEX "<table>\n";
164 print INDEX "<tr><th>Name</th><th>Value</th></tr>\n";
165 foreach my $key (sort (keys (%vars))) {
167 print INDEX "<td>", encode_entities ($key), "</td>";
168 print INDEX "<td>", encode_entities ($vars{$key}), "</td>";
169 print INDEX "</tr>\n";
171 print INDEX "</table>\n";
173 print INDEX "<h2>Build Products</h2>\n";
174 print INDEX "<ul>\n";
175 foreach my $p (@products) {
177 print INDEX encode_entities ($p->{NAME}), ": " if defined ($p->{NAME});
178 print INDEX "<a href=\"", encode_entities ($p->{HREF}), "\">";
179 print INDEX encode_entities ($p->{PRODUCT});
180 print INDEX "</a>\n";
181 if ($p->{PRODUCT} =~ /\.tar\.gz$/) {
182 my $sha = Digest::SHA->new(1);
183 $sha->addfile($p->{PRODUCT});
184 print INDEX "<br>sha1: ", $sha->hexdigest, "\n";
186 $sha = Digest::SHA->new(256);
187 $sha->addfile($p->{PRODUCT});
188 print INDEX "<br>sha256: ", $sha->hexdigest, "\n";
190 print INDEX "</li>\n";
192 print INDEX "</ul>\n";
196 return "<small><a href=\"log.html#$ln\">(log)</a></small>";
199 print INDEX "<h2>Build Summary</h2>\n";
200 print INDEX "<ol>\n";
201 foreach my $s (@steps) {
202 print INDEX "<li>", encode_entities ($s->{TITLE});
203 print INDEX " ", log_link ($s->{LN});
204 foreach my $c (@{$s->{CHILDREN}}) {
205 if (defined ($c->{DIAGNOSTIC})) {
206 print INDEX "<p class=\"$c->{DIAGNOSTIC}\">";
207 if (defined ($c->{MATCH})) {
208 my $href = $gitweb_url;
209 $href =~ s/\[FILE\]/uri_escape ($c->{FILE})/ge;
210 $href =~ s/\[LINE\]/$c->{LINE}/g;
211 $href =~ s/\[BRANCH\]/uri_escape ($vars{'dist_commit'})/e;
213 print INDEX '<a href="', encode_entities ($href), '">';
214 print INDEX encode_entities (substr ($c->{MESSAGE},
217 print INDEX encode_entities (substr ($c->{MESSAGE},
220 print INDEX encode_entities ($c->{MESSAGE});
222 print INDEX " ", log_link ($c->{LN});
223 print INDEX "</p>\n";
225 print INDEX "<p>→ <a href=\"", encode_entities ($c->{HREF}), "\">";
226 print INDEX encode_entities ($c->{PRODUCT});
228 print INDEX log_link ($c->{LN});
229 print INDEX "</p>\n";
232 print INDEX "</li>\n";
234 print INDEX "</ol>\n";
241 print LOG_HTML <<EOF;
247 open (CSS, '>', "build.css");
252 padding: 0em 3em 0em 3em;
256 margin: 0pt 0pt 0pt 0em
278 H1, H2, H3, H4, H5, H6 {
279 font-family: sans-serif;
288 text-decoration: none;
292 text-decoration: none;
296 text-decoration: none;
299 text-decoration: underline