| 1 |
#!/bin/sh
|
| 2 |
|
| 3 |
####################
|
| 4 |
# Copyright (C) 2009 by Raphael Geissert <atomo64@gmail.com>
|
| 5 |
#
|
| 6 |
# This file is free software: you can redistribute it and/or modify
|
| 7 |
# it under the terms of the GNU General Public License as published by
|
| 8 |
# the Free Software Foundation, either version 2 of the License, or
|
| 9 |
# (at your option) any later version.
|
| 10 |
#
|
| 11 |
# This file is distributed in the hope that it will be useful,
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
# GNU General Public License for more details.
|
| 15 |
#
|
| 16 |
# You should have received a copy of the GNU General Public License
|
| 17 |
# along with this file. If not, see <http://www.gnu.org/licenses/>.
|
| 18 |
####################
|
| 19 |
|
| 20 |
set -e
|
| 21 |
|
| 22 |
rsync -Pvan --log-file=/dev/null --list-only ftp.heanet.ie::sourceforge |
|
| 23 |
sed -rn 's/^-.+[0-9]{4}\/[0-9]{2}\/[0-9]{2}[[:space:]]+[0-9]{2}:[0-9]{2}:[0-9]{2}[[:space:]]+(.+)$/\1/;T;p' > sf-list.new
|
| 24 |
|
| 25 |
perl -w <<'PCODE'
|
| 26 |
|
| 27 |
use strict;
|
| 28 |
use BerkeleyDB;
|
| 29 |
|
| 30 |
my %db;
|
| 31 |
|
| 32 |
tie %db, 'BerkeleyDB::Btree',
|
| 33 |
-Filename => "sf-list.db-new",
|
| 34 |
-Flags => DB_CREATE | DB_TRUNCATE,
|
| 35 |
-Mode => 0664
|
| 36 |
or die("Failed to open sf-list.db-new: $! $BerkeleyDB::Error\n");
|
| 37 |
|
| 38 |
sub gen_html;
|
| 39 |
|
| 40 |
open(LIST, '< sf-list.new')
|
| 41 |
or die("Failed to open sf-list.new: $!\n");
|
| 42 |
|
| 43 |
my $cur_project = undef;
|
| 44 |
my @files;
|
| 45 |
|
| 46 |
while(<LIST>) {
|
| 47 |
next unless(m,^\w/project/.{2}/([^/]+)/(?:([^/]+)|([^/]+)/(?:[^/]+/)*(.+))?$,);
|
| 48 |
my ($project, $file1, $mdir, $file2) = ($1, $2, $3, $4);
|
| 49 |
my $file = $file1 || $file2;
|
| 50 |
|
| 51 |
$mdir = $mdir || '';
|
| 52 |
|
| 53 |
next if ($mdir eq 'OldFiles');
|
| 54 |
|
| 55 |
$cur_project = $project unless (defined($cur_project));
|
| 56 |
|
| 57 |
if ($project ne $cur_project) {
|
| 58 |
$db{$cur_project} = gen_html;
|
| 59 |
$cur_project = $project;
|
| 60 |
}
|
| 61 |
|
| 62 |
push @files, $file;
|
| 63 |
}
|
| 64 |
|
| 65 |
if (@files) {
|
| 66 |
$db{$cur_project} = gen_html;
|
| 67 |
}
|
| 68 |
|
| 69 |
close(LIST);
|
| 70 |
untie %db;
|
| 71 |
|
| 72 |
sub gen_html {
|
| 73 |
my $html = '';
|
| 74 |
while (my $f = pop @files) {
|
| 75 |
$f =~ s/&/&/;
|
| 76 |
$f =~ s/</</;
|
| 77 |
$f =~ s/>/>/;
|
| 78 |
$html .= "<a href='$f'>$f</a><br/>\n";
|
| 79 |
}
|
| 80 |
return $html;
|
| 81 |
}
|
| 82 |
|
| 83 |
PCODE
|
| 84 |
|
| 85 |
gzip -n sf-list.new
|
| 86 |
mv sf-list.db-new sf-list.db
|
| 87 |
mv sf-list.new.gz sf-list.gz
|