[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.10-188-g5feda65



The following commit has been merged in the master branch:
commit 5feda656d4a18ffe8e1f1d2e5f0bf33fa08c5117
Author: Jordà Polo <jorda@ettin.org>
Date:   Fri Oct 5 12:16:44 2012 +0200

    html_reports: Visualize history data
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/debian/changelog b/debian/changelog
index 86418e9..860c130 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -179,6 +179,12 @@ lintian (2.5.11) UNRELEASED; urgency=low
   * man/lintian.pod.in:
     + [NT] Remove documentation about removed options.
 
+  * reporting/graphs/{statistics,tags}.gpi:
+    + [JP] New file.
+  * reporting/html_reports:
+    + [JP,NT] Generate graphs of the collected history data.
+      (Closes: #672273)
+
  -- Niels Thykier <niels@thykier.net>  Tue, 10 Jul 2012 13:21:56 +0200
 
 lintian (2.5.10.2) unstable; urgency=low
diff --git a/reporting/config b/reporting/config
index 0250309..d6abf5c 100644
--- a/reporting/config
+++ b/reporting/config
@@ -12,6 +12,7 @@ $LINTIAN_LAB = "$HOME/laboratory";
 $LOG_DIR = "$HOME/logs";
 $HTML_DIR = "$HOME/www";
 $HTML_TMP_DIR = "$HTML_DIR.new";
+$GRAPH_DIR = "$HTML_TMP_DIR/graphs";
 $LINTIAN_CFG = "$LINTIAN_ROOT/reporting/lintian-dummy.cfg";  # this config file has to be empty!
 $LINTIAN_BIN_DIR = "$HOME/bin";
 $LINTIAN_GPG_CHECK = 0;
@@ -22,6 +23,13 @@ $LINTIAN_SOURCE = "http://anonscm.debian.org/gitweb/?p=lintian/lintian.git";;
 $HISTORY = 0;
 $HISTORY_DIR = "$HOME/history";
 
+# Whether or not to create graphs from $HISTORY
+#   Requires that $HISTORY is enabled.
+$GRAPHS = 1;
+# Make graphs of the data in the time interval
+#   [today() - $GRAPH_RANGE_DAYS ; now()]
+$GRAPHS_RANGE_DAYS = 240;
+
 $log_file = "$LOG_DIR/harness.log";
 $changes_file = "$LOG_DIR/setup-lab.log";
 $list_file = "$LOG_DIR/changed-packages.list";
diff --git a/reporting/graphs/statistics.gpi b/reporting/graphs/statistics.gpi
new file mode 100644
index 0000000..c2bae7a
--- /dev/null
+++ b/reporting/graphs/statistics.gpi
@@ -0,0 +1,38 @@
+# set terminal png truecolor small size 600,300
+set terminal svg size 600,300
+
+set style line 10 linetype 1 linecolor rgb "#FF6700" lw 1.5
+set style line 11 linetype 1 linecolor rgb "#FFEB44" lw 1.5
+set style line 12 linetype 1 linecolor rgb "#C7EA3C" lw 1.5
+set style line 13 linetype 1 linecolor rgb "#E7F6AC" lw 1.5
+set style line 14 linetype 1 linecolor rgb "#EE99EE" lw 1.5
+set style line 15 linetype 1 linecolor rgb "#CCCCCC" lw 1.5
+
+set key outside
+
+set xdata time
+set timefmt "%s"
+set format x "%b/%y"
+
+set size 1.0,0.85
+set origin 0.0,0.05
+
+set nomxtics
+set xtics nomirror scale 0.5,0 rotate by 55 offset -2.5,-2.4
+set ytics nomirror scale 0.5,0
+set offsets 0,0,500,0
+
+load "common.gpi"
+
+set xrange [ date_min : date_max ]
+set yrange [ 0 : ]
+
+set output sprintf("%s/statistics.svg", graph_dir)
+plot sprintf("%s/statistics.dat", history_dir) \
+    u 1:7  w l ls 10 t 'Errors', \
+ '' u 1:8  w l ls 11 t 'Warnings', \
+ '' u 1:9  w l ls 12 t 'Info', \
+ '' u 1:11 w l ls 13 t 'Pedantic', \
+ '' u 1:10 w l ls 14 t 'Experimental', \
+ '' u 1:12 w l ls 15 t 'Overridden'
+
diff --git a/reporting/graphs/tags.gpi b/reporting/graphs/tags.gpi
new file mode 100644
index 0000000..5c79707
--- /dev/null
+++ b/reporting/graphs/tags.gpi
@@ -0,0 +1,33 @@
+# set terminal png truecolor small size 600,300
+set terminal svg size 600,300
+
+set style fill solid 0.25
+
+set style line 20 linetype 1 linecolor rgb "#1A77C9"
+set style line 21 linetype 1 linecolor rgb "#83CDBE"
+set style line 22 linetype 1 linecolor rgb "#BBBBBB"
+
+set key outside
+
+set xdata time
+set timefmt "%s"
+set format x "%b/%y"
+
+set size 1.0,0.85
+set origin 0.0,0.05
+
+set nomxtics
+set xtics nomirror scale 0.5,0 rotate by 55 offset -2.5,-2.4
+set ytics nomirror scale 0.5,0
+
+load "common.gpi"
+
+set xrange [ date_min : date_max ]
+set yrange [ 0 : ]
+
+set output sprintf("%s/tags/%s.svg", graph_dir, tag)
+plot sprintf("%s/tags/%s.dat", history_dir, tag) \
+    u 1:2 w filledcurve x1 ls 20 t 'Tags', \
+ '' u 1:3 w filledcurve x1 ls 21 t 'Packages', \
+ '' u 1:4 w filledcurve x1 ls 22 t 'Overridden'
+
diff --git a/reporting/html_reports b/reporting/html_reports
index 2edf71b..0d25f4f 100755
--- a/reporting/html_reports
+++ b/reporting/html_reports
@@ -23,7 +23,9 @@
 
 use strict;
 
+use POSIX qw(strftime);
 use File::Copy qw(copy);
+use Fcntl qw(SEEK_SET);
 use URI::Escape;
 use Text::Template ();
 
@@ -34,7 +36,8 @@ use Text::Template ();
 # FIXME: $statistics_file should be in all caps as well.
 our ($LINTIAN_ROOT, $LINTIAN_LAB, $LINTIAN_ARCHIVEDIR, $LINTIAN_DIST,
      $LINTIAN_ARCH, $HTML_TMP_DIR, $statistics_file,
-     $LINTIAN_AREA, $HISTORY, $HISTORY_DIR, $LINTIAN_SOURCE);
+     $LINTIAN_AREA, $HISTORY, $HISTORY_DIR, $LINTIAN_SOURCE,
+     $GRAPH_RANGE_DAYS, $GRAPHS, $GRAPH_DIR);
 
 # Read the configuration.
 require './config';
@@ -568,6 +571,9 @@ output_template ('index.html', $templates{index}, \%data);
 exit 0 if (not $HISTORY);
 
 # Update history.
+my %versions = ();
+my $commonf = "$GRAPH_DIR/common.gpi";
+my $do_graphs = 1;
 my $unix_time = time();
 mkdir("$HISTORY_DIR")
     or die "cannot create history directory $HISTORY_DIR: $!\n"
@@ -581,11 +587,51 @@ my $stats = '';
 for my $attr (@attrs) {
     $stats .= " $statistics{$attr}";
 }
-open(HIST, '>>', $history_file)
+open(HIST, '+>>', $history_file)
     or die "cannot open history file: $!\n";
 print HIST "$unix_time $LINTIAN_VERSION$stats\n";
+
+if ($GRAPHS and seek HIST, 0, SEEK_SET) {
+    while ( <HIST> ) {
+        my @fields = split();
+        $versions{$fields[1]} = $fields[0] if not exists $versions{$fields[1]};
+    }
+} elsif ($GRAPHS) {
+    die "seek failed: $!\n";
+}
 close HIST or die "cannot write to $history_file: $!\n";
 
+if ($GRAPHS) {
+    mkdir("$GRAPH_DIR", 0777)
+        or die "cannot create output directory $GRAPH_DIR: $!\n";
+    mkdir("$GRAPH_DIR/tags", 0777)
+        or die "cannot create output directory $GRAPH_DIR/tags: $!\n";
+    my $RANGE_DAYS = 240;
+
+    my $date_min = strftime ("%s", localtime ($unix_time - 3600 * 24 * $RANGE_DAYS));
+    my $date_max = strftime ("%s", localtime ($unix_time));
+
+    # Generate loadable Gnuplot file with common variables and labels/arrows
+    # for Lintian versions.
+    open my $common, '>', $commonf
+        or die "cannot open $commonf: $!\n";
+    print { $common } "history_dir='$HISTORY_DIR'\n";
+    print { $common } "graph_dir='$GRAPH_DIR'\n";
+    print { $common } "date_min='$date_min'\n";
+    print { $common } "date_max='$date_max'\n";
+    for my $v (sort keys %versions) {
+        print { $common } "set label '$v' at '$versions{$v}',graph 1.04 ",
+            "rotate by 90 font ',10'\n";
+        print { $common } "set arrow from '$versions{$v}',graph 0 to ",
+            "'$versions{$v}',graph 1 nohead lw 0.4\n";
+    }
+    close $common or die "close $commonf: $!\n";
+
+    print "Plotting global statistics...\n";
+    chdir_system ($GRAPH_DIR, ['gnuplot', "$LINTIAN_ROOT/reporting/graphs/statistics.gpi"]) == 0
+        or die "gnuplot died with $?\n";
+}
+
 for my $tag (sort keys %tag_statistics) {
     $history_file = "$HISTORY_DIR/tags/$tag.dat";
     $stats = $tag_statistics{$tag};
@@ -594,6 +640,16 @@ for my $tag (sort keys %tag_statistics) {
     print HIST "$unix_time $stats->{'count'} $stats->{'overrides'} " .
                "$stats->{'packages'}\n";
     close HIST or die "cannot write to $history_file: $!\n";
+    if ($GRAPHS) {
+        print "Plotting $tag statistics...\n";
+        chdir_system ($GRAPH_DIR, ['gnuplot', '-e', "tag='$tag'",
+                                   "$LINTIAN_ROOT/reporting/graphs/tags.gpi"]) == 0
+            or die "gnuplot died with $?\n";
+    }
+}
+
+if ($GRAPHS) {
+    unlink $commonf or die "unlink $commonf: $!";
 }
 
 exit 0;
@@ -688,6 +744,20 @@ sub by_tag {
         || $a->{extra}   cmp $b->{extra};
 }
 
+sub chdir_system {
+    my ($dir, $cmd) = @_;
+    my $pid = fork // die "fork: $!";
+    if ($pid) {
+        waitpid ($pid, 0) == $pid or die "waitpid failed: $!\n";
+        return $?
+    }
+
+    chdir $dir
+        or "chdir failed: $!";
+    exec @$cmd
+        or die "exec failed: $!";
+}
+
 # Local Variables:
 # indent-tabs-mode: nil
 # cperl-indent-level: 4

-- 
Debian package checker


Reply to: