#!/usr/bin/perl -w
# Copyright (C) 2016-2018 all contributors
# License: AGPL-3.0+
use strict;
use warnings;
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
use PublicInbox::MIME;
use PublicInbox::InboxWritable;
use PublicInbox::Import;
use PublicInbox::MDA;
my $usage = "usage: $0 NAME EMAIL DIR \$dry_run,
'V|version=i' => \$version,
'F|format=s' => \$variant,
);
GetOptions(%opts) or die $usage;
if ($variant ne 'mboxrd' && $variant ne 'mboxo') {
die "Unsupported mbox variant: $variant\n";
}
my $name = shift or die $usage; # git
my $email = shift or die $usage; # git@vger.kernel.org
my $mainrepo = shift or die $usage; # /path/to/v2/repo
my $ibx = {
mainrepo => $mainrepo,
name => $name,
version => $version,
address => [ $email ],
filter => 'PublicInbox::Filter::Vger',
};
$ibx = PublicInbox::Inbox->new($ibx);
unless ($dry_run) {
if ($version >= 2) {
require PublicInbox::V2Writable;
PublicInbox::V2Writable->new($ibx, 1)->init_inbox(0);
} else {
system(qw(git init --bare -q), $mainrepo) == 0 or die;
}
}
$ibx = PublicInbox::InboxWritable->new($ibx);
binmode STDIN;
$ibx->import_mbox(\*STDIN, $variant);