3 # removals - generate an RSS feed of removals from Debian
4 # (C) Copyright 2005 Tollef Fog Heen <tfheen@err.no>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # version 2 as published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 use MIME::Base64 qw(encode_base64);
26 use POSIX qw(strftime);
27 use CGI qw/:standard/;
29 die "usage: $0 <configfile>\n" unless scalar @ARGV;
33 my $cfgfname = $ARGV[0];
34 open my $cfgfile, "<", $cfgfname
35 or die "config file $cfgfname not found: $!\n";
40 my ($key, $val) = split ": ", $_, 2;
41 warn "$0: warning: redefining config key $key\n" if defined $config->{$key};
42 $config->{$key} = $val;
46 for ( qw/input items title link description subject creator publisher rights language/ ) {
47 die "config option '$_' missing in $cfgfname\n" unless $config->{$_};
49 open REMOVALS, "<", $config->{input};
54 local $/ = "=========================================================================\n=========================================================================";
55 @removals = reverse <REMOVALS>;
58 my $rss = new XML::RSS (version => '1.0');
60 title => $config->{title},
61 link => $config->{link},
62 description => $config->{description},
64 date => POSIX::strftime ("%FT%R+00:00",gmtime()),
65 subject => $config->{subject},
66 creator => $config->{creator},
67 publisher => $config->{publisher},
68 rights => $config->{rights},
69 language => $config->{language},
72 updatePeriod => "hourly",
73 updateFrequency => "1",
74 updateBase => "1901-01-01T00:00+00:00",
78 my $num_to_display = $config->{items};
79 for my $removal (@removals ) {
80 my ($null, $date, $ftpmaster, $body, $reason);
81 $removal =~ s/=========================================================================//g;
82 $removal =~ m/\[Date: ([^]]+)\] \[ftpmaster: ([^]]+)\]/;
85 ($null, $body) = split /\n/, $removal, 2;
87 $body =~ m/---- Reason ---.*\n(.*)/;
89 my $link = encode_base64($date . $ftpmaster);
92 $rss->add_item(title => "$reason",
93 link => $config->{link} . "?" . $link,
94 description => qq[<pre>$body</pre>],
96 creator => "$ftpmaster",
100 $num_to_display -= 1;
101 last unless $num_to_display;
103 print $rss->as_string;