ab539f919e0e0437e99ceb8085ee566802f71c1c
[grml-infrastructure.git] / source-report / gen_index
1 #!/usr/bin/perl
2
3 use strict; 
4 use warnings;
5 use English; 
6 use CGI qw/:standard/;
7 use HTML::Table;
8 use File::Basename; 
9
10
11 my $reports = '/home/sources/reports';
12 my @status_files = split("\n", `find $reports -maxdepth 2 -name status.txt`); 
13
14
15 open(my $fh, '>', "$reports/index.html")
16         or die "Could not open '$reports/index.html' for writing: $!"; 
17
18 print $fh start_html("Source Repository for GRML"); 
19 print $fh "<center><h1><a href='http://grml.org/'>GRML</a> Source Repository</h1><br><br>";
20 my $t = new HTML::Table(
21                                 -cols => 5,
22                                 -border=>1,
23                                 -head=> ['Release','Packages','Sources', 'Errors', 'Last updated', 'source.list entry'],
24                         );
25
26 foreach my $releasefile (@status_files) {
27         open (my $pfh, '<', "$releasefile") 
28                 or die "Could not open statusfile '$releasefile': $!"; 
29         my ($release, $packages, $sources, $errors, $lastupdated, $baseurl);
30         while (<$pfh>) {        
31                 chomp;
32                 if (/^Updated: (.*)$/) { $lastupdated = $1; next;}
33                 if (/^Sources: (.*)$/) { $sources = $1; next; }
34                 if (/^Title: (.*)$/) { $release = $1; next; }
35                 if (/^Errors: (.*)$/) { $errors = $1; next; }
36                 if (/^Packages: (.*)$/) { $packages = $1; next; }
37                 if (/^Baseurl: (.*)$/) { $baseurl = $1; next; }
38         }
39         $t->addRow(     "<a href='$baseurl'>$release</a>", 
40                         "$packages", 
41                         "$sources",
42                         "$errors", 
43                         "$lastupdated",
44                         "deb-src $baseurl ./", 
45                 );
46 }
47 print $fh $t; 
48 print $fh end_html; 
49 close($fh);