#!/bin/sh #################### # Copyright (C) 2009 by Raphael Geissert # # This file is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this file. If not, see . #################### set -e rsync -Pvan --log-file=/dev/null --list-only ftp.heanet.ie::sourceforge | 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 perl -w <<'PCODE' use strict; use BerkeleyDB; my %db; tie %db, 'BerkeleyDB::Btree', -Filename => "sf-list.db-new", -Flags => DB_CREATE | DB_TRUNCATE, -Mode => 0664 or die("Failed to open sf-list.db-new: $! $BerkeleyDB::Error\n"); sub gen_html; open(LIST, '< sf-list.new') or die("Failed to open sf-list.new: $!\n"); my $cur_project = undef; my @files; while() { next unless(m,^\w/project/.{2}/([^/]+)/[^/]+/[^/]+/(.+)$,); my ($project, $file) = ($1, $2); $cur_project = $project unless (defined($cur_project)); if ($project ne $cur_project) { $db{$cur_project} = gen_html; $cur_project = $project; } push @files, $file; } if (@files) { $db{$cur_project} = gen_html; } close(LIST); untie %db; sub gen_html { my $html = ''; while (my $f = pop @files) { $f =~ s/&/&/; $f =~ s//>/; $html .= "$f
\n"; } return $html; } PCODE gzip -n sf-list.new mv sf-list.db-new sf-list.db mv sf-list.new.gz sf-list.gz