]> git.decadent.org.uk Git - dak.git/blobdiff - tools/removals.pl
LOCAL: Remove replay check
[dak.git] / tools / removals.pl
index 839fc618c9e060f7fe929825589c1b3a55950af7..d4392a4e92aa678b300607cc39917daa6f04ba22 100755 (executable)
@@ -2,6 +2,7 @@
 
 #    removals - generate an RSS feed of removals from Debian
 #    (C) Copyright 2005 Tollef Fog Heen <tfheen@err.no>
+#    (C) Copyright 2010 Uli Martens <uli@youam.net>
 #
 #    This program is free software; you can redistribute it and/or
 #    modify it under the terms of the GNU General Public License
@@ -26,7 +27,27 @@ use XML::RSS;
 use POSIX qw(strftime);
 use CGI qw/:standard/;
 
-open REMOVALS, "</srv/ftp.debian.org/web/removals.txt";
+die "usage: $0 <configfile>\n" unless scalar @ARGV;
+
+my $config;
+
+my $cfgfname = $ARGV[0];
+open my $cfgfile, "<", $cfgfname
+       or die "config file $cfgfname not found: $!\n";
+while (<$cfgfile>){
+       chomp;
+       s/#.*//;
+       next if m/^$/;
+       my ($key, $val) = split ": ", $_, 2;
+       warn "$0: warning: redefining config key $key\n" if defined $config->{$key};
+       $config->{$key} = $val;
+}
+close $cfgfile;
+
+for ( qw/input items title link description subject creator publisher rights language/ ) {
+       die "config option '$_' missing in $cfgfname\n" unless $config->{$_};
+}
+open REMOVALS, "<", $config->{input};
 
 my @removals;
 
@@ -37,16 +58,16 @@ my @removals;
 
 my $rss = new XML::RSS (version => '1.0');
 $rss->channel(
-                         title        => "Removals from Debian",
-                         link         => "http://ftp-master.debian.org/removals.txt",
-                         description  => "List of all the removals from Debian's archives",
+                         title        => $config->{title},
+                         link         => $config->{link},
+                         description  => $config->{description},
                          dc => {
                                         date       => POSIX::strftime ("%FT%R+00:00",gmtime()),
-                                        subject    => "Removals from Debian",
-                                        creator    => 'tfheen@debian.org',
-                                        publisher  => 'joerg@debian.org',
-                                        rights     => 'Copyright 2005, Tollef Fog Heen',
-                                        language   => 'en-us',
+                                        subject    => $config->{subject},
+                                        creator    => $config->{creator},
+                                        publisher  => $config->{publisher},
+                                        rights     => $config->{rights},
+                                        language   => $config->{language},
                                        },
                          syn => {
                                          updatePeriod     => "hourly",
@@ -55,9 +76,9 @@ $rss->channel(
                                         }
                         );
 
-my $num_to_display = 16;
+my $num_to_display = $config->{items};
 for my $removal (@removals ) {
-  my ($null, $date, $ftpmaster, $body, $reason);
+  my ($null, $date, $ftpmaster, $body, $packages, $reason);
   $removal =~ s/=========================================================================//g;
   $removal =~ m/\[Date: ([^]]+)\] \[ftpmaster: ([^]]+)\]/;
   $date = $1;
@@ -66,11 +87,19 @@ for my $removal (@removals ) {
   chomp $body;
   $body =~ m/---- Reason ---.*\n(.*)/;
   $reason = $1;
+  $packages = join( ", ",
+    map { ( my $p = $_ ) =~ s/^\s*(.+?) \|.+/$1/; $p }
+    grep {/.+\|.+\|.+/} split( /\n/, $body ) );
+  $packages
+    = ( substr $packages, 0,
+    ( $config->{titlelength} - length($reason) - 6 ) )
+    . " ..."
+    if length("$packages: $reason") > $config->{titlelength};
   my $link =  encode_base64($date . $ftpmaster);
   chomp($link);
 
-  $rss->add_item(title       => "$reason",
-                                link        => "http://ftp-master.debian.org/removals.txt?" . $link,
+  $rss->add_item(title       => "$packages: $reason",
+                                link        => $config->{link} . "?" . $link,
                                 description => qq[<pre>$body</pre>],
                                 dc => {
                                                creator => "$ftpmaster",