From 80a4df6d606ac342eecdd968c1656a6aa3f1fbce Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 22 Oct 2009 14:46:30 +0200 Subject: [PATCH] ebl Add (again) tool to convert sourceforge download page to a simple and small one. --- docs/tools/sf2bacula_downloads.pl | 152 ++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100755 docs/tools/sf2bacula_downloads.pl diff --git a/docs/tools/sf2bacula_downloads.pl b/docs/tools/sf2bacula_downloads.pl new file mode 100755 index 00000000..94d9f553 --- /dev/null +++ b/docs/tools/sf2bacula_downloads.pl @@ -0,0 +1,152 @@ +#!/usr/bin/perl -w +use strict; + +=head HOWTO USE + +When you release a new version ex: 3.0.3 + - Modify the $version string + +When you add a new category + - Add a print_cat() at the end of the script + +To update the downloads.php file + +- Change the version on the top of the file +- ./sf2bacula_downloads.pl > downloads.php + +By default, it downloads the sourceforge page in the current directory + + +You can also use a previous output + + ./sf2bacula_downloads.pl > downloads.php + +=cut + +# bacula|depkgs | depkgs-qt +my $version = '3.0.3'; +if ($ARGV[0] =~ /^[\d\.]+$/) { + $version = shift(@ARGV); +} +my $depkgs_version = '18Feb09|28Jul09'; + +my $base = "http://bacula.svn.sourceforge.net/viewvc/bacula/tags/Release-$version/bacula"; +my $notes = "$base/ReleaseNotes"; +my $chglog = "$base/ChangeLog"; +my %cats; +my $cur; +my %seen; + +my $file = "sf_list_$$.html"; +my $cmd = "wget -O $file https://sourceforge.net/projects/bacula/files"; + +if ($ARGV[0] && -f $ARGV[0]) { + $file = $ARGV[0]; +} else { + system($cmd); +} + +open(FP, $file); +while (my $l = ) +{ + # cat vers file + if ($l =~ m!href="(/projects/bacula/files/(.+?)/(.+?)/(.+?)/download)"!) { + if ($cur && !exists $seen{$cur->{file}}) { + push @{$cats{$cur->{cat}}}, $cur; + $seen{$cur->{file}} = 1; + } + + $cur = { + dl => $1, + cat => $2, + vers => $3, + file => $4, + }; + } + + # the size and the date are just after + if ($l =~ m!([\d\.]+ [KMG]iB)!) { + $cur->{size} = $1; + do { + $l = ; + if ($l =~ m!(.+?)!) { + $cur->{date} = $1; + } + } while (!$cur->{date}); + } +} +close(FP); + +print ' + + + + + + + + +'; + +my $cat = 'bacula'; +#use Data::Dumper; +#print Data::Dumper::Dumper(\%cats); + +sub print_cat +{ + my ($cat) = @_; + + print ' + + + '; +} + +print_cat('bacula'); +print_cat('Win32_64'); +print_cat('rpms'); +print_cat('rpms-contrib-fschwarz'); +print_cat('rpms-contrib-psheaffer'); +print_cat('depkgs'); +print_cat('depkgs-qt'); + + +print ' +
+ Bacula downloads for version ', $version, ' +
+
+ Release Notes |  + ChangeLog |  + Sources |  + Win32/64 |  + RPM |  + Public Key |  + RPM Public Key +
+

', $cat, ': + + +'; + foreach my $elt ( sort { $a->{file} cmp $b->{file} } @{$cats{$cat}}) + { + next if ($elt->{file} =~ /\.sig/); # we skip signature file + if ($elt->{vers} eq $version || $elt->{vers} =~ /$depkgs_version/) + { + print " + + + + + + +"; + } + } + print '
Name', ($cat !~ /rpm/)?'Signature':'', 'SizeDate
$elt->{file}", + ($cat !~ /rpm/)?"sig":"", + "$elt->{size}$elt->{date}
+
+ +'; + -- 2.39.5