2 # Copyright (C) 2013-2021 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 use File::Glob qw(bsd_glob GLOB_NOSORT);
14 sub usage { "Usage:\n".join('',grep(/\t/, `head -n 12 $0`)) }
15 my $spool = shift @ARGV or die usage();
16 my $dir = shift @ARGV or die usage();
17 -d $dir or die "$dir is not a directory\n";
18 $dir .= '/' unless $dir =~ m!/\z!;
19 foreach my $sub (qw(cur new tmp)) {
22 mkdir $nd or die "mkdir $nd failed: $!\n";
25 foreach my $n (grep(/\d+\z/, bsd_glob("$spool/*", GLOB_NOSORT))) {
26 if (open my $fh, '<', $n) {
27 my $f = Email::Filter->new(data => do { local $/; <$fh> });
30 # gmane rewrites Received headers, which increases spamminess
31 # Some older archives set Original-To
32 foreach my $x (qw(Received To)) {
33 my @h = $s->header("Original-$x");
35 $s->header_set($x, @h);
36 $s->header_set("Original-$x");
40 # triggers for the SA HEADER_SPAM rule
41 foreach my $drop (qw(Approved)) { $s->header_set($drop) }
43 # appears to be an old gmane bug:
44 $s->header_set('connect()');
49 warn "Failed to open $n: $!\n";