44 if ($help) |
48 if ($help) |
45 { |
49 { |
46 print "Unite and HTML-ize Raptor log files.\n"; |
50 print "Unite and HTML-ize Raptor log files.\n"; |
47 print "Usage: perl uh.pl [OPTIONS] FILE1 FILE2 ...\n"; |
51 print "Usage: perl uh.pl [OPTIONS] FILE1 FILE2 ...\n"; |
48 print "where OPTIONS are:\n"; |
52 print "where OPTIONS are:\n"; |
49 print "\t--basedir=DIR Generate output under DIR (defaults to current dir)\n"; |
53 print "\t-m, --missing\tAlso add the list of missing binaries (Raptor log should include whatlog info).\n"; |
|
54 print "\t\t\tCheck is done against the epoc tree at the root of the current drive\n"; |
|
55 print "\t-b DIR, --basedir DIR\tGenerate output under DIR (defaults to current dir)\n"; |
50 exit(0); |
56 exit(0); |
51 } |
57 } |
52 |
58 |
53 if ($basedir) |
59 if ($basedir) |
54 { |
60 { |
55 $raptorbitsdir = "$basedir/raptorbits"; |
61 $raptorbitsdir = "$basedir/raptorbits"; |
56 $outputdir = "$basedir/html"; |
62 $outputdir = "$basedir/html"; |
|
63 $releaseablesdir = "$basedir/releaseables"; |
57 } |
64 } |
58 mkdir($basedir) if (!-d$basedir); |
65 mkdir($basedir) if (!-d$basedir); |
59 |
66 |
60 $raptorbitsdir =~ s,/,\\,g; # this is because rmdir doens't cope correctly with the forward slashes |
67 $raptorbitsdir =~ s,/,\\,g; # this is because rmdir doens't cope correctly with the forward slashes |
61 |
68 |
62 system("rmdir /S /Q $raptorbitsdir") if (-d $raptorbitsdir); |
69 system("rmdir /S /Q $raptorbitsdir") if (-d $raptorbitsdir); |
63 mkdir($raptorbitsdir); |
70 mkdir($raptorbitsdir); |
64 #print "Created dir $raptorbitsdir.\n"; |
71 #print "Created dir $raptorbitsdir.\n"; |
|
72 system("rmdir /S /Q $releaseablesdir") if (-d $releaseablesdir); |
|
73 mkdir("$releaseablesdir"); |
65 |
74 |
66 our $failure_item_number = 0; |
75 our $failure_item_number = 0; |
67 |
76 |
68 # create empty summary file anyway |
77 # create empty summary file anyway |
69 open(SUMMARY, ">$raptorbitsdir/summary.csv"); |
78 open(SUMMARY, ">$raptorbitsdir/summary.csv"); |
70 close(SUMMARY); |
79 close(SUMMARY); |
|
80 |
71 |
81 |
72 my $saxhandler = RaptorSAXHandler->new(); |
82 my $saxhandler = RaptorSAXHandler->new(); |
73 $saxhandler->add_observer('RaptorError', $RaptorError::reset_status); |
83 $saxhandler->add_observer('RaptorError', $RaptorError::reset_status); |
74 $saxhandler->add_observer('RaptorWarning', $RaptorWarning::reset_status); |
84 $saxhandler->add_observer('RaptorWarning', $RaptorWarning::reset_status); |
75 $saxhandler->add_observer('RaptorInfo', $RaptorInfo::reset_status); |
85 $saxhandler->add_observer('RaptorInfo', $RaptorInfo::reset_status); |
76 $saxhandler->add_observer('RaptorUnreciped', $RaptorUnreciped::reset_status); |
86 $saxhandler->add_observer('RaptorUnreciped', $RaptorUnreciped::reset_status); |
77 $saxhandler->add_observer('RaptorRecipe', $RaptorRecipe::reset_status); |
87 $saxhandler->add_observer('RaptorRecipe', $RaptorRecipe::reset_status); |
|
88 $saxhandler->add_observer('releaseables', $releaseables::reset_status); |
78 |
89 |
79 our $allbldinfs = {}; |
90 our $allbldinfs = {}; |
80 |
91 |
81 my $parser = XML::SAX::ParserFactory->parser(Handler=>$saxhandler); |
92 my $parser = XML::SAX::ParserFactory->parser(Handler=>$saxhandler); |
82 for (@logfiles) |
93 for (@logfiles) |
83 { |
94 { |
84 print "Reading file: $_\n"; |
95 print "Reading file: $_\n"; |
85 $current_log_file = $_; |
96 $current_log_file = $_; |
86 $parser->parse_uri($_); |
97 $parser->parse_uri($_); |
87 } |
98 } |
|
99 |
|
100 releaseables::remove_missing_duplicates(); |
88 |
101 |
89 my @allpackages = distinct_packages($allbldinfs); |
102 my @allpackages = distinct_packages($allbldinfs); |
90 |
103 |
91 print "Generating HTML...\n"; |
104 print "Generating HTML...\n"; |
92 |
105 |
98 my $raptor_unreciped = {}; |
111 my $raptor_unreciped = {}; |
99 my $general_failures_num_by_severity = {}; |
112 my $general_failures_num_by_severity = {}; |
100 my $general_failures_by_category_severity = {}; |
113 my $general_failures_by_category_severity = {}; |
101 my $recipe_failures_num_by_severity = {}; |
114 my $recipe_failures_num_by_severity = {}; |
102 my $recipe_failures_by_package_severity = {}; |
115 my $recipe_failures_by_package_severity = {}; |
|
116 my $missing_by_package = {}; |
103 #my $severities = {}; |
117 #my $severities = {}; |
104 my @severities = ('critical', 'major', 'minor', 'unknown'); |
118 my @severities = ('critical', 'major', 'minor', 'unknown'); |
105 |
119 |
106 # READ SUMMARY.CSV FILE |
120 # READ SUMMARY.CSV FILE |
107 my $csv_file = "$raptorbitsdir/summary.csv"; |
121 my $csv_file = "$raptorbitsdir/summary.csv"; |
233 |
247 |
234 print AGGREGATED "<br/>PACKAGE-SPECIFIC FAILURES<br/>\n"; |
248 print AGGREGATED "<br/>PACKAGE-SPECIFIC FAILURES<br/>\n"; |
235 print AGGREGATED "<table border='1'>\n"; |
249 print AGGREGATED "<table border='1'>\n"; |
236 $tableheader = "<tr><th>package</th>"; |
250 $tableheader = "<tr><th>package</th>"; |
237 for (@severities) { $tableheader .= "<th>$_</th>"; } |
251 for (@severities) { $tableheader .= "<th>$_</th>"; } |
|
252 $tableheader .= "<th>missing</th>" if ($missing); |
238 $tableheader .= "</tr>"; |
253 $tableheader .= "</tr>"; |
239 print AGGREGATED "$tableheader\n"; |
254 print AGGREGATED "$tableheader\n"; |
240 for my $package (@allpackages) |
255 for my $package (@allpackages) |
241 { |
256 { |
242 if (defined $recipe_failures_num_by_severity->{$package}) |
257 my $mustlink = print_package_specific_summary($package); |
243 { |
258 if ($mustlink) |
244 print_package_specific_summary($package, $recipe_failures_by_package_severity->{$package}); |
259 { |
245 my $packagesummaryhtml = $package; |
260 my $packagesummaryhtml = $package; |
246 $packagesummaryhtml =~ s,/,_,; |
261 $packagesummaryhtml =~ s,/,_,; |
247 $packagesummaryhtml .= ".html"; |
262 $packagesummaryhtml .= ".html"; |
248 my $packageline = "<tr><td><a href='$packagesummaryhtml'>$package</a></td>"; |
263 my $packageline = "<tr><td><a href='$packagesummaryhtml'>$package</a></td>"; |
249 for (@severities) |
264 for (@severities) |
250 { |
265 { |
251 my $failuresbyseverity = 0; |
266 my $failuresbyseverity = 0; |
252 $failuresbyseverity = $recipe_failures_num_by_severity->{$package}->{$_} if (defined $recipe_failures_num_by_severity->{$package}->{$_}); |
267 $failuresbyseverity = $recipe_failures_num_by_severity->{$package}->{$_} if (defined $recipe_failures_num_by_severity->{$package}->{$_}); |
253 $packageline .= "<td>$failuresbyseverity</td>"; |
268 $packageline .= "<td>$failuresbyseverity</td>"; |
254 } |
269 } |
|
270 $packageline .= "<td>".$missing_by_package->{$package}."</td>" if ($missing); |
255 $packageline .= "</tr>"; |
271 $packageline .= "</tr>"; |
256 print AGGREGATED "$packageline\n"; |
272 print AGGREGATED "$packageline\n"; |
257 } |
273 } |
258 else |
274 else |
259 { |
275 { |
308 close(SPECIFIC); |
324 close(SPECIFIC); |
309 } |
325 } |
310 |
326 |
311 sub print_package_specific_summary |
327 sub print_package_specific_summary |
312 { |
328 { |
313 my ($package, $failures_by_severity) = @_; |
329 my ($package) = @_; |
|
330 |
|
331 my $anyfailures = 0; |
314 |
332 |
315 my $filenamebase = $package; |
333 my $filenamebase = $package; |
316 $filenamebase =~ s,/,_,; |
334 $filenamebase =~ s,/,_,; |
317 |
335 |
318 open(SPECIFIC, ">$outputdir/$filenamebase.html"); |
336 if (defined $recipe_failures_by_package_severity->{$package}) |
319 print SPECIFIC "FAILURES FOR PACKAGE $package<br/>\n"; |
337 { |
320 |
338 $anyfailures = 1; |
321 for my $severity (@severities) |
339 |
322 { |
340 my $failures_by_severity = $recipe_failures_by_package_severity->{$package}; |
323 if (defined $failures_by_severity->{$severity}) |
341 |
324 { |
342 open(SPECIFIC, ">$outputdir/$filenamebase.html"); |
325 print SPECIFIC "<br/>".uc($severity)."<br/>\n"; |
343 print SPECIFIC "FAILURES FOR PACKAGE $package<br/>\n"; |
326 print SPECIFIC "<table border='1'>\n"; |
344 |
327 # $subcategory, $severity, $mmp, $phase, $recipe, $file, $line |
345 for my $severity (@severities) |
328 my $tableheader = "<tr><th>category</th><th>configuration</th><th>mmp</th><th>phase</th><th>recipe</th><th>log snippet</th></tr>"; |
346 { |
329 print SPECIFIC "$tableheader\n"; |
347 if (defined $failures_by_severity->{$severity}) |
330 |
348 { |
331 for my $failure (@{$failures_by_severity->{$severity}}) |
349 print SPECIFIC "<br/>".uc($severity)."<br/>\n"; |
332 { |
350 print SPECIFIC "<table border='1'>\n"; |
333 my $failureline = "<tr><td>$failure->{subcategory}</td>"; |
351 # $subcategory, $severity, $mmp, $phase, $recipe, $file, $line |
334 $failureline .= "<td>$failure->{config}</td>"; |
352 my $tableheader = "<tr><th>category</th><th>configuration</th><th>mmp</th><th>phase</th><th>recipe</th><th>log snippet</th></tr>"; |
335 $failureline .= "<td>$failure->{mmp}</td>"; |
353 print SPECIFIC "$tableheader\n"; |
336 $failureline .= "<td>$failure->{phase}</td>"; |
354 |
337 $failureline .= "<td>$failure->{recipe}</td>"; |
355 for my $failure (@{$failures_by_severity->{$severity}}) |
338 $failureline .= "<td><a href='$filenamebase\_failures.html#failure_item_$failure->{linenum}'>item $failure->{linenum}</a></td>"; |
356 { |
339 $failureline .= "</tr>"; |
357 my $failureline = "<tr><td>$failure->{subcategory}</td>"; |
340 print SPECIFIC "$failureline\n"; |
358 $failureline .= "<td>$failure->{config}</td>"; |
341 } |
359 $failureline .= "<td>$failure->{mmp}</td>"; |
342 |
360 $failureline .= "<td>$failure->{phase}</td>"; |
343 print SPECIFIC "</table>\n"; |
361 $failureline .= "<td>$failure->{recipe}</td>"; |
344 print SPECIFIC "<br/>\n"; |
362 $failureline .= "<td><a href='$filenamebase\_failures.html#failure_item_$failure->{linenum}'>item $failure->{linenum}</a></td>"; |
345 } |
363 $failureline .= "</tr>"; |
346 } |
364 print SPECIFIC "$failureline\n"; |
347 |
365 } |
348 close(SPECIFIC); |
366 |
|
367 print SPECIFIC "</table>\n"; |
|
368 print SPECIFIC "<br/>\n"; |
|
369 } |
|
370 } |
|
371 close(SPECIFIC); |
|
372 } |
|
373 |
|
374 if ($missing) |
|
375 { |
|
376 my $missinglistfile = $package; |
|
377 $missinglistfile =~ s,/,_,; |
|
378 $missinglistfile .= "_missing.txt"; |
|
379 if (open(MISSINGLIST, "$::raptorbitsdir/$missinglistfile")) |
|
380 { |
|
381 my @list = (); |
|
382 while(<MISSINGLIST>) |
|
383 { |
|
384 my $missingfile = $_; |
|
385 chomp $missingfile; |
|
386 $missingfile =~ s,^\s+,,g; |
|
387 $missingfile =~ s,\s+$,,g; |
|
388 push(@list, $missingfile); |
|
389 } |
|
390 close(MISSINGLIST); |
|
391 |
|
392 $missing_by_package->{$package} = scalar(@list); |
|
393 |
|
394 if ($missing_by_package->{$package} > 0) |
|
395 { |
|
396 open(SPECIFIC, ">>$outputdir/$filenamebase.html"); |
|
397 print SPECIFIC "FAILURES FOR PACKAGE $package<br/>\n" if(!$anyfailures); |
|
398 |
|
399 $anyfailures = 1; |
|
400 |
|
401 print SPECIFIC "<br/>MISSING<br/>\n"; |
|
402 print SPECIFIC "<table border='1'>\n"; |
|
403 # $subcategory, $severity, $mmp, $phase, $recipe, $file, $line |
|
404 my $tableheader = "<tr><th>file</th></tr>\n"; |
|
405 print SPECIFIC "$tableheader\n"; |
|
406 |
|
407 for my $missingfile (sort {$a cmp $b} @list) |
|
408 { |
|
409 $missingfile = CGI::escapeHTML($missingfile); |
|
410 print SPECIFIC "<tr><td>$missingfile</td></tr>\n"; |
|
411 } |
|
412 |
|
413 print SPECIFIC "</table>\n"; |
|
414 print SPECIFIC "<br/>\n"; |
|
415 |
|
416 close(SPECIFIC); |
|
417 } |
|
418 } |
|
419 } |
|
420 |
|
421 return $anyfailures; |
349 } |
422 } |
350 |
423 |
351 sub translate_detail_files_to_html |
424 sub translate_detail_files_to_html |
352 { |
425 { |
353 opendir(DIR, $raptorbitsdir); |
426 opendir(DIR, $raptorbitsdir); |