<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#! /usr/bin/perl -wT
#
# Require the debian package libchart-perl.

$ENV{PATH}="/usr/bin:/bin";
$dirpng = shift @ARGV;
$dirpng =~ m/(.*)/ and $dirpng=$1;
$oneyearago = `date +"%Y-%m-%d" -d "1 year ago"`;

while (&lt;&gt;)
{
   my ($file);
   m/^(.*\/popcon-([0-9-]+)(\.stable)?\.gz)$/ or next;
   $file=$1;
   $f=$2;
   push @date,$f;
   open FILE,"zcat $file|";
   while(&lt;FILE&gt;)
   {
     my @line=split(/ +/);
     if ($line[0] eq "Submissions:")
     {
       $subt{$f}=$line[1];
     }
     elsif ($line[0] eq "Architecture:")
     {
       $sub{$f}-&gt;{$line[1]}=$line[2];
       $arch{$line[1]}++;
     }
     elsif ($line[0] eq "Release:")
     {
       if (defined($line[2]))
       {
         if ($line[1] =~ m/^([0-9]+(?:\.[0-9]+)*)/)
         {
           $rel{$f}-&gt;{"$1"}+=$line[2];
         } else {
           $rel{$f}-&gt;{"unknown"}+=$line[2];
         }
       } else {
         $rel{$f}-&gt;{"unknown"}+=$line[1];
       }
     }
     elsif ($line[0] eq "Package:")
     {
       last;
     }
   }
   close FILE;
}

sub ytick
{
  my ($x)=$_[0];
  $x &lt; 1 and return 0;
  return int 2**($x-1);
}

use Chart::LinesPoints;

sub getsub
{
  my ($day,$r)=@_;
  return defined($sub{$day}-&gt;{$r})?$sub{$day}-&gt;{$r}:0;
}

sub submission_chart
{
  my ($pngname,$startdate,$ticks,$title)=@_;
  my (@days) = sort grep { defined($sub{$_}-&gt;{'i386'}) } @date;
  @days = sort grep { $_ ge $startdate } @days;
  my (@data) = (\@days);
  my ($today)=$days[-1];
  my (@arch)= sort {getsub($today,$b) &lt;=&gt; getsub($today,$a)} (keys %arch);
  $maxv = -10;
  for $arch (@arch)
  {
	  my @res=();
	  for (@days)
	  {
		  my $data=defined($sub{$_}-&gt;{$arch})?log($sub{$_}-&gt;{$arch})/log(2)+1:0;
		  push @res,$data;
		  $maxv=$data if ($data &gt; $maxv);
	  }
	  push @data,\@res;
  }

  $obj=Chart::LinesPoints-&gt;new (600,400);
  $obj-&gt;set ('title' =&gt; "Number of submissions per architectures $title");
  $obj-&gt;set ('legend_labels' =&gt; [@arch]);
  $obj-&gt;set ('f_y_tick' =&gt; \&amp;ytick);
  $obj-&gt;set ('brush_size' =&gt; 3);
  $obj-&gt;set ('pt_size' =&gt; 3);
  $obj-&gt;set ('max_val' =&gt; $maxv+1);
  $obj-&gt;set ('max_y_ticks' =&gt; 30);
  $obj-&gt;set ('y_ticks' =&gt; int $maxv +1);
  $obj-&gt;set ('x_ticks' =&gt; 'vertical');
  $obj-&gt;set ('skip_x_ticks' =&gt; $ticks);
  $obj-&gt;png ("$dirpng/submission$pngname.png", \@data);
}

submission_chart ("","0000-00-00",63,"");
submission_chart ("-1year",$oneyearago,14,"(last 12 months)");

use Chart::Composite;
my (@days) = sort grep { defined($sub{$_}-&gt;{'i386'}) } @date;
my (@arch)= sort (keys %arch);
for $arch (@arch)
{
  my @data;
  my @res=();
  my @tot=();
  for (@days)
  {
    push @res,defined($sub{$_}-&gt;{$arch})?$sub{$_}-&gt;{$arch}:0;
    push @tot,defined($subt{$_})?$subt{$_}:0;
  }
  @data=(\@days,\@res,\@tot);
  @labels=($arch, 'all submissions');
  $obj=Chart::Composite-&gt;new (700,400);
  $obj-&gt;set ('title' =&gt; "Number of submissions for $arch");
  $obj-&gt;set ('legend_labels' =&gt; \@labels);
  $obj-&gt;set ('brush_size' =&gt; 3);
  $obj-&gt;set ('pt_size' =&gt; 7);
  $obj-&gt;set ('x_ticks' =&gt; 'vertical');
  $obj-&gt;set ('skip_x_ticks' =&gt; 63);
  $obj-&gt;set ('composite_info' =&gt; [ ['LinesPoints', [1]], ['LinesPoints', [2] ] ]); 
  $obj-&gt;png ("$dirpng/sub-$arch.png", \@data);
}

sub getrel
{
  my ($day,$r)=@_;
  return defined($rel{$day}-&gt;{$r})?$rel{$day}-&gt;{$r}:0;
}

sub release_chart
{
  my ($pngname,$startdate,$ticks,$title)=@_;
  my (@days) = sort grep { $_ ge $startdate } @date;
  my (%release) = map { map { $_ =&gt; 1 } keys %{$rel{$_}}  } @days;
  my (@data) = (\@days);
  my ($today)=$days[-1];
  my (@release)= sort {getrel($today,$b) &lt;=&gt; getrel($today,$a)} (keys %release);
  for $release (@release)
  {
    my @res=();
    for (@days)
    {
      my $data=getrel($_,$release);
      push @res,$data;
    }
    push @data,\@res;
  }
  $obj=Chart::LinesPoints-&gt;new (600,400);
  $obj-&gt;set ('title' =&gt; "popularity-contest versions in use $title");
  $obj-&gt;set ('legend_labels' =&gt; [@release]);
  $obj-&gt;set ('brush_size' =&gt; 3);
  $obj-&gt;set ('pt_size' =&gt; 3);
  $obj-&gt;set ('x_ticks' =&gt; 'vertical');
  $obj-&gt;set ('skip_x_ticks' =&gt; $ticks);
  $obj-&gt;png ("$dirpng/release$pngname.png", \@data);
}
release_chart ("","2004-05-14",63,"");
release_chart ("-1year",$oneyearago,14,"(last 12 months)");
</pre></body></html>