#!/usr/bin/perl -w
-# Copyright (C) 2014-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2014-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Initializes a public-inbox, basically a wrapper for git-init(1)
PublicInbox::Admin::require_or_die('-base');
use PublicInbox::Config;
use PublicInbox::InboxWritable;
+use PublicInbox::Import;
use File::Temp qw/tempfile/;
use PublicInbox::Lock;
use File::Basename qw/dirname/;
use Fcntl qw(:DEFAULT);
use Cwd qw/abs_path/;
-sub x { system(@_) and die join(' ', @_). " failed: $?\n" }
my $version = undef;
my $indexlevel = undef;
my $skip_epoch;
+my $jobs;
my %opts = (
'V|version=i' => \$version,
'L|indexlevel=s' => \$indexlevel,
'S|skip|skip-epoch=i' => \$skip_epoch,
+ 'j|jobs=i' => \$jobs,
);
GetOptions(%opts) or usage();
PublicInbox::Admin::indexlevel_ok_or_die($indexlevel) if defined $indexlevel;
});
my $creat_opt = {};
+if (defined $jobs) {
+ die "--jobs is only supported for -V2 inboxes\n" if $version == 1;
+ die "--jobs=$jobs must be >= 1\n" if $jobs <= 0;
+ $creat_opt->{nproc} = $jobs;
+}
+
PublicInbox::InboxWritable->new($ibx, $creat_opt)->init_inbox(0, $skip_epoch);
# needed for git prior to v2.1.0
foreach my $addr (@address) {
next if $seen{lc($addr)};
- x(@x, "--add", "$pfx.address", $addr);
+ PublicInbox::Import::run_die([@x, "--add", "$pfx.address", $addr]);
}
-x(@x, "$pfx.url", $http_url);
-x(@x, "$pfx.inboxdir", $inboxdir);
+PublicInbox::Import::run_die([@x, "$pfx.url", $http_url]);
+PublicInbox::Import::run_die([@x, "$pfx.inboxdir", $inboxdir]);
if (defined($indexlevel)) {
- x(@x, "$pfx.indexlevel", $indexlevel);
+ PublicInbox::Import::run_die([@x, "$pfx.indexlevel", $indexlevel]);
}
# needed for git prior to v2.1.0