generate html format report
authorZhang Qiang <qiang.z.zhang@intel.com>
Tue, 5 Nov 2013 02:29:54 +0000 (10:29 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Wed, 6 Nov 2013 06:44:15 +0000 (14:44 +0800)
Change-Id: I14d2aae84e8179cb1715fd657ad942766370c156

Makefile
data/build-report.tmpl [new file with mode: 0644]
depanneur
packaging/depanneur.spec

index 0de897c..c930a48 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ VERSION=0.1
 
 prefix=/usr
 bindir=$(prefix)/bin
-datadir=$(prefix)/share
+datadir=$(prefix)/share/depanneur
 libdir=$(prefix)/lib
 sudodir=/etc/sudoers.d
 DESTDIR=
@@ -12,6 +12,8 @@ all:
 install:
        install -m755 -d \
            $(DESTDIR)$(bindir)
+       install -m755 -d \
+           $(DESTDIR)$(datadir)
        install -m755 \
            depanneur  \
            $(DESTDIR)$(bindir)
@@ -20,4 +22,6 @@ install:
        install -m440 \
         data/gbs \
         $(DESTDIR)$(sudodir)
-
+       install -m644 \
+        data/build-report.tmpl \
+        $(DESTDIR)$(datadir)/
diff --git a/data/build-report.tmpl b/data/build-report.tmpl
new file mode 100644 (file)
index 0000000..d627a3c
--- /dev/null
@@ -0,0 +1,125 @@
+<html>
+
+<head>
+<title>GBS Build Report</title>
+<style>
+.failed { color: red }
+.succeeded { color: green }
+table {
+    border-collapse:collapse;
+    margin-bottom: 1em;
+}
+
+th { background-color: #F3F3F3 }
+td, th {
+    border: 1px solid grey;
+    padding: 3px
+}
+
+table.middle th { text-align: left }
+
+</style>
+
+</head>
+
+<body>
+
+
+<h1 align="center" >GBS Local Full Build Report</h1>
+
+<p><B>Profile:</B> <TMPL_VAR build_profile></p>
+<p><B>Arch:</B> <TMPL_VAR build_arch></p>
+
+<h3>Build Status Summary</h3>
+
+<table class = middle>
+    <tr>
+        <th>Total Packages</th>
+        <th>succeeded Packages</th>
+        <th>Export Error Packages</th>
+        <th>Expansion Error Packages</th>
+        <th>Build Error Packages</th>
+    </tr>
+    <tr>
+        <td><TMPL_VAR packages_total></td>
+        <td><TMPL_VAR packages_succeeded></td>
+        <td><TMPL_VAR packages_export_error></td>
+        <td><TMPL_VAR packages_expansion_error></td>
+        <td><TMPL_VAR packages_build_error></td>
+    </tr>
+</table>
+
+
+<tmpl_if name=have_export_errors>
+<h3>Export error details</h3>
+The following packages can't be exported correctly:
+    <table class = middle>
+        <thead>
+            <tr>
+                <th>Package name</th>
+                <th>Package path</th>
+                <th>Export error</th>
+            </tr>
+        </thead>
+        <tbody>
+            <tmpl_loop export_details>
+              <tr>
+                <td><tmpl_var package_name></td>
+                <td><tmpl_var package_path></td>
+                <td><tmpl_var error_info></td>
+              </tr>
+            </tmpl_loop>
+        </tbody>
+    </table>
+</tmpl_if>
+
+
+<tmpl_if name=have_expansion_errors>
+<h3>Expansion error details</h3>
+The following packages have build dependencies issue:
+    <table class = middle>
+        <thead>
+            <tr>
+                <th>Package name</th>
+                <th>Package path</th>
+                <th>Expansion error</th>
+            </tr>
+        </thead>
+        <tbody>
+            <tmpl_loop expansion_details>
+              <tr>
+                <td><tmpl_var package_name></td>
+                <td><tmpl_var package_path></td>
+                <td><tmpl_var error_info></td>
+              </tr>
+            </tmpl_loop>
+        </tbody>
+    </table>
+</tmpl_if>
+
+<h3>Build Statis Details</h3>
+<table class = middle>
+    <thead>
+        <tr>
+            <th>Package Name</th>
+            <th>Package Path</th>
+            <th>Build Status</th>
+        </tr>
+    </thead>
+    <tbody>
+        <TMPL_LOOP build_details>
+          <tr>
+            <td><TMPL_VAR package_name></td>
+            <td><TMPL_VAR package_path></td>
+            <TMPL_IF NAME="succeeded">
+                <td><a href=<TMPL_VAR log_path> class = succeeded> Succeeded </a> </td>
+            <TMPL_ELSE>
+                <td><a href=<TMPL_VAR log_path> class = failed> Failed </a> </td>
+            </TMPL_IF>
+          </tr>
+        </TMPL_LOOP>
+    </tbody>
+</table>
+</body>
+
+</html>
index ede5513..ae9b808 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use File::Spec::Functions;
 use JSON;
+use HTML::Template;
 
 BEGIN {
   my ($wd) = $0 =~ m-(.*)/- ;
@@ -1470,6 +1471,46 @@ sub update_repo
 
 }
 
+sub build_html_report
+{
+    my $template_file = "/usr/share/depanneur/build-report.tmpl";
+
+    if (! -e $template_file) {
+        warning("html template $template_file does not exist.");
+        return;
+    }
+
+    # generate html format report
+    my $tmpl = HTML::Template->new(filename => $template_file);
+    $tmpl->param(
+        build_profile => $build_status_json{"build_profile"},
+        build_arch => $build_status_json{"build_arch"},
+        );
+
+    $tmpl->param($build_status_json{"summary"});
+
+    if (@export_errors) {
+        $tmpl->param( have_export_errors => 1,
+                export_details => $build_status_json{"export_details"}
+                );
+    }
+
+    if (%expansion_errors) {
+    $tmpl->param( have_expansion_errors => 1,
+                  expansion_details => $build_status_json{"expansion_details"}
+                );
+    }
+
+    $tmpl->param(
+        build_details => $build_status_json{"build_details"}
+    );
+
+    open(my $report_html, '>', "$localrepo/$dist/$arch/index.html");
+    $tmpl->output(print_to => $report_html);
+    close($report_html);
+}
+
+
 sub build_json_report
 {
         info("generate html format report" );
@@ -1553,6 +1594,7 @@ sub build_report
         $build_status_json{"expansion_details"} = \@expansion_details;
         $build_status_json{"build_details"} = \@build_details;
 
+        build_html_report();
         build_json_report();
         error($msg);
     }
index 06fb0fc..4286725 100644 (file)
@@ -34,5 +34,7 @@ build mode and incremental build mode.
 
 %files
 %defattr(-,root,root,-)
+%dir %{_datadir}/depanneur
 %{_bindir}/depanneur
 %{_sysconfdir}/sudoers.d/gbs
+%{_datadir}/depanneur/build-report.tmpl