public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob d1ce723162e47686647cd26a690a9df60e4c9933 1288 bytes (raw)
$ git show v1.4.0:scripts/import_vger_from_mbox	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
#!/usr/bin/perl -w
# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use warnings;
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
use PublicInbox::InboxWritable;
my $usage = "usage: $0 NAME EMAIL DIR <MBOX\n";
my $dry_run;
my $version = 2;
my $variant = 'mboxrd';
my $filter = 'PublicInbox::Filter::Vger';
my %opts = (
	'n|dry-run' => \$dry_run,
	'V|version=i' => \$version,
	'F|format=s' => \$variant,
	'filter=s' => \$filter,
);
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 $inboxdir = shift or die $usage; # /path/to/v2/repo
my $ibx = {
	inboxdir => $inboxdir,
	name => $name,
	version => $version,
	address => [ $email ],
	filter => $filter,
};
$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), $inboxdir) == 0 or die;
	}
}
$ibx = PublicInbox::InboxWritable->new($ibx);
binmode STDIN;
$ibx->import_mbox(\*STDIN, $variant);

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git