]> git.sur5r.net Git - bacula/docs/blobdiff - docs/tools/sf2bacula_downloads.pl
update version
[bacula/docs] / docs / tools / sf2bacula_downloads.pl
index 57a78a0ad5c5b9783b45be0f52907ef23afd165d..668ea84b3f5d39e1ce546b88050a0f68cc24e151 100755 (executable)
@@ -24,13 +24,13 @@ You can also use a previous output
 =cut
 
 #             bacula|depkgs | depkgs-qt
-my $version = '3.0.3';
-if ($ARGV[0] =~ /^[\d\.]+$/) {
+my $version = '5.0.1';
+if ($ARGV[0] and $ARGV[0] =~ /^[\d\.]+$/) {
     $version = shift(@ARGV);
 }
-my $depkgs_version  = '18Feb09|28Jul09';
+my $depkgs_version  = '18Dec09|28Jul09';
 
-my $base = "http://bacula.svn.sourceforge.net/viewvc/bacula/tags/Release-$version/bacula";
+my $base = "http://bacula.git.sourceforge.net/git/gitweb.cgi?p=bacula/bacula;a=blob_plain;hb=Release-$version;f=bacula";
 my $notes = "$base/ReleaseNotes";
 my $chglog = "$base/ChangeLog";
 my %cats;
@@ -50,24 +50,34 @@ open(FP, $file);
 while (my $l = <FP>)
 {
     #                                         cat   vers  file
-    if ($l =~ m!href="(/projects/bacula/files/(.+?)/(.+?)/(.+?)/download)"!) {
+    if ($l =~ m!href="(/projects/bacula/files/([^/]+)/([^/]+)/([^/]+)/download)"!) {
+        print STDERR "$4\n";
         $cur = {
             dl  => $1,
             cat => $2,
             vers => $3,
-            file => $4,
+            file => $4
         };
     }
 
-    # the size and the date are just after
+    # the size, date, and downloads are just after
     if ($cur && $l =~ m!<td>([\d\.]+ [KMG]B)</td>!) {
         $cur->{size} = $1;
         do {
             $l = <FP>;
-            if ($l =~ m!<td>(.+?)</td>!) {
+            if ($l =~ m!<td>(\d{4}-\d{2}-\d{2})</td>!) {
                 $cur->{date} = $1;
+                print STDERR "  date: $1\n";
             }
-        } while (!$cur->{date});
+        } while (!$cur->{date} and !eof(FP));
+        do {
+            $l = <FP>;
+            if ($l =~ m!<td>([\d,]+)</td>!) {
+                $cur->{downloads} = $1;
+                print STDERR "  downloads: $1\n";
+            }
+        } while (!exists $cur->{downloads} and !eof(FP));
+
 
         # once we have a full $cur element, we can store it
         if (!exists $seen{$cur->{file}}) {
@@ -81,6 +91,8 @@ close(FP);
 
 print '
 <? require_once("inc/header.php"); ?>
+<? // This page is generated by sf2bacula_downloads.pl in eric s crontab, 
+   // no need to update it by hand ?>
 <table>
   <tr>
    <td class="contentTopic">
@@ -109,12 +121,13 @@ my $cat = 'bacula';
 sub print_cat
 {
     my ($cat) = @_;
+    my $row = 'odd';
 
     print '
    <tr>
      <td> <br><a name="', $cat, '"></a><font size="+1"><b>', $cat, ':</b></font>
 <table cellspacing="2">
-<tr><th>Name</th><th align="center">', ($cat !~ /rpm/)?'Signature':'', '</th><th>Size</th><th>Date</th></tr>
+<tr class="title"><th>Name</th><th align="center">', ($cat !~ /rpm/)?'Signature':'', '</th><th>Size</th><th>Date</th><th>Downloads</th></tr>
 ';
     foreach my $elt ( sort { $a->{file} cmp $b->{file} }  @{$cats{$cat}})
     {
@@ -122,15 +135,17 @@ sub print_cat
         if ($elt->{vers} eq $version || $elt->{vers} =~ /$depkgs_version/)
         {
             print "
-<tr>
+<tr class=\"$row\">
  <td><a href='https://sourceforge.net$elt->{dl}'>$elt->{file}</td>
- <td align='center'>", 
+ <td align=\"center\">", 
  ($cat !~ /rpm/)?"<a href='https://sourceforge.net/projects/bacula/files/$cat/$elt->{vers}/$elt->{file}.sig/download'>sig":"", 
  "</td>
- <td>$elt->{size}</td>
- <td>$elt->{date}</td>
+ <td align=\"right\">$elt->{size}</td>
+ <td align=\"center\">$elt->{date}</td>
+ <td align=\"center\">$elt->{downloads}</td>
 </tr>
 ";
+            if ($row eq 'odd') { $row = 'even'; } else { $row = 'odd'; }
         }
     }
     print '</table>
@@ -149,6 +164,6 @@ print_cat('depkgs-qt');
 
 print '
 </table>
+<small>', scalar(localtime), '</small>
 <? require_once("inc/footer.php"); ?>
 ';
-