2 # Copyright (C) 2013-2019 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 # One-off script to convert an slrnpull news spool to Maildir
7 ./slrnspool2maildir SLRNPULL_ROOT/news/foo/bar /path/to/maildir/
12 use Email::LocalDelivery;
13 sub usage { "Usage:\n".join('',grep(/\t/, `head -n 12 $0`)) }
14 my $spool = shift @ARGV or die usage();
15 my $dir = shift @ARGV or die usage();
16 -d $dir or die "$dir is not a directory\n";
17 $dir .= '/' unless $dir =~ m!/\z!;
18 foreach my $sub (qw(cur new tmp)) {
21 mkdir $nd or die "mkdir $nd failed: $!\n";
24 foreach my $n (grep(/\d+\z/, glob("$spool/*"))) {
25 if (open my $fh, '<', $n) {
26 my $f = Email::Filter->new(data => eval { local $/; <$fh> });
29 # gmane rewrites Received headers, which increases spamminess
30 # Some older archives set Original-To
31 foreach my $x (qw(Received To)) {
32 my @h = $s->header("Original-$x");
34 $s->header_set($x, @h);
35 $s->header_set("Original-$x");
39 # triggers for the SA HEADER_SPAM rule
40 foreach my $drop (qw(Approved)) { $s->header_set($drop) }
42 # appears to be an old gmane bug:
43 $s->header_set('connect()');
48 warn "Failed to open $n: $!\n";