2 # Copyright (C) 2015, all contributors <meta@public-inbox.org>
3 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
5 # Incremental (or one-shot) importer of a slrnpull news spool
7 export ORIGINAL_RECIPIENT=address@example.com
8 public-inbox-init $LISTNAME $GIT_DIR $HTTP_URL $ORIGINAL_RECIPIENT
9 ./import_slrnspool SLRNPULL_ROOT/news/foo/bar
13 use PublicInbox::Config;
15 use Email::LocalDelivery;
16 sub usage { "Usage:\n".join('',grep(/\t/, `head -n 10 $0`)) }
17 my $spool = shift @ARGV or die usage();
18 my $recipient = $ENV{ORIGINAL_RECIPIENT};
19 defined $recipient or die usage();
20 my $config = PublicInbox::Config->new;
21 my $cfg = $config->lookup($recipient);
22 defined $cfg or exit(1);
25 @mda = qw(public-inbox-mda);
27 @mda = (qw(ssoma-mda -1), $cfg->{mainrepo});
32 $cfg->{importslrnspoolstate} || 0;
37 my $f = PublicInbox::Config->default_file;
38 my @cmd = (qw/git config/, "--file=$f",
39 "publicinbox.$cfg->{listname}.importslrnspoolstate", $num);
40 system(@cmd) == 0 or die join(' ', @cmd). " failed: $?\n";
46 my $max = $n + $max_gap;
48 for (; $n < $max; $n++) {
50 print STDERR $fn, "\n";
51 open(my $fh, '<', $fn) or next;
53 my $f = Email::Filter->new(data => eval { local $/; <$fh> });
56 # gmane rewrites Received headers, which increases spamminess
57 # Some older archives set Original-To
58 foreach my $x (qw(Received To)) {
59 my @h = $s->header("Original-$x");
61 $s->header_set($x, @h);
62 $s->header_set("Original-$x");
66 # triggers for the SA HEADER_SPAM rule
67 foreach my $drop (qw(Approved)) { $s->header_set($drop) }
69 # appears to be an old gmane bug:
70 $s->header_set('connect()');