use warnings;
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
use Date::Parse qw/str2time/;
-use Email::MIME;
-$Email::MIME::ContentType::STRICT_PARAMS = 0; # user input is imperfect
+use PublicInbox::MIME;
use PublicInbox::Inbox;
use PublicInbox::V2Writable;
+use PublicInbox::Import;
my $usage = "usage: $0 NAME EMAIL DIR <MBOX\n";
my $dry_run;
-my %opts = ( 'n|dry-run' => \$dry_run );
+my $version = 2;
+my %opts = (
+ 'n|dry-run' => \$dry_run,
+ 'V|version=i' => \$version,
+);
GetOptions(%opts) or die $usage;
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 $v2ibx = {
+my $ibx = {
mainrepo => $mainrepo,
name => $name,
- version => 2,
+ version => $version,
-primary_address => $email,
};
-$v2ibx = PublicInbox::Inbox->new($v2ibx);
-my $im = $dry_run ? undef : PublicInbox::V2Writable->new($v2ibx, 1);
+$ibx = PublicInbox::Inbox->new($ibx);
+my $im;
+unless ($dry_run) {
+ if ($version >= 2) {
+ $im = PublicInbox::V2Writable->new($ibx, 1);
+ } else {
+ system(qw(git init --bare -q), $mainrepo);
+ my $git = PublicInbox::Git->new($mainrepo);
+ $im = PublicInbox::Import->new($git, $name, $email, $ibx);
+ }
+}
binmode STDIN;
my $msg = '';
use PublicInbox::Filter::Vger;
sub do_add ($$) {
my ($im, $msg) = @_;
$$msg =~ s/(\r?\n)+\z/$1/s;
- $msg = Email::MIME->new($$msg);
- $msg = $vger->scrub($msg);
+ my $mime = PublicInbox::MIME->new($msg);
+ $mime = $vger->scrub($mime);
return unless $im;
- $im->add($msg) or
+ $im->add($mime) or
warn "duplicate: ",
- $msg->header_obj->header_raw('Message-ID'), "\n";
+ $mime->header_obj->header_raw('Message-ID'), "\n";
}
# asctime: From example@example.com Fri Jun 23 02:56:55 2000