/[qa]/trunk/data/watch/update-sf-list
ViewVC logotype

Contents of /trunk/data/watch/update-sf-list

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2741 - (show annotations) (download)
Tue Apr 17 01:14:06 2012 UTC (13 months ago) by geissert
File size: 2481 byte(s)
Add set -u as well
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 -eu
21
22 scratch=/srv/scratch/qa.debian.org/sf-list
23 export scratch
24
25 mkdir -p "$scratch"
26
27 ret=0
28 rsync -Pvan --log-file=/dev/null --list-only ftp.heanet.ie::sourceforge > "$scratch/rsync-stdout.txt" || ret=$?
29 if [ $ret -ne 0 -a $ret -ne 23 -a $ret -ne 24 ] ; then
30 exit $ret
31 fi
32
33 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' < "$scratch/rsync-stdout.txt" > "$scratch/sf-list.new"
34
35 unlink "$scratch/rsync-stdout.txt"
36
37 perl -w <<'PCODE'
38
39 use strict;
40 use BerkeleyDB;
41
42 my %db;
43
44 tie %db, 'BerkeleyDB::Btree',
45 -Filename => "sf-list.db-new",
46 -Flags => DB_CREATE | DB_TRUNCATE,
47 -Mode => 0664
48 or die("Failed to open sf-list.db-new: $! $BerkeleyDB::Error\n");
49
50 sub gen_html;
51
52 open(LIST, '<', "$ENV{scratch}/sf-list.new")
53 or die("Failed to open sf-list.new: $!\n");
54
55 my $cur_project = undef;
56 my @files;
57
58 while(<LIST>) {
59 next unless(m,^\w/.{2}/([^/]+)/(?:([^/]+)|([^/]+)/(?:[^/]+/)*(.+))?$,);
60 my ($project, $file1, $mdir, $file2) = ($1, $2, $3, $4);
61 my $file = $file1 || $file2;
62
63 $mdir = $mdir || '';
64
65 next if ($mdir eq 'OldFiles');
66
67 $cur_project = $project unless (defined($cur_project));
68
69 if ($project ne $cur_project) {
70 $db{$cur_project} = gen_html;
71 $cur_project = $project;
72 }
73
74 push @files, $file;
75 }
76
77 if (@files) {
78 $db{$cur_project} = gen_html;
79 }
80
81 close(LIST);
82 untie %db;
83
84 sub gen_html {
85 my $html = '';
86 while (my $f = pop @files) {
87 $f =~ s/&/&amp;/g;
88 $f =~ s/</&lt;/g;
89 $f =~ s/>/&gt;/g;
90 $html .= "<a href='$f'>$f</a><br/>\n";
91 }
92 return $html;
93 }
94
95 PCODE
96
97 gzip -n "$scratch/sf-list.new"
98 mv sf-list.db-new sf-list.db
99 mv "$scratch/sf-list.new.gz" "$scratch/sf-list.gz"

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5