2 # Copyright (C) 2015-2019 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # Basic tool to create a Xapian search index for a git repository
5 # configured for public-inbox.
6 # Usage with libeatmydata <https://www.flamingspork.com/projects/libeatmydata/>
7 # highly recommended: eatmydata public-inbox-index INBOX_DIR
11 use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
12 my $usage = "public-inbox-index INBOX_DIR";
13 use PublicInbox::Admin;
14 PublicInbox::Admin::require_or_die('-index');
16 my $opt = { quiet => -1 };
17 GetOptions($opt, qw(verbose|v+ reindex jobs|j=i prune indexlevel|L=s))
18 or die "bad command-line args\n$usage";
19 die "--jobs must be positive\n" if defined $opt->{jobs} && $opt->{jobs} <= 0;
22 my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV);
23 PublicInbox::Admin::require_or_die('-index');
24 unless (@ibxs) { print STDERR "Usage: $usage\n"; exit 1 }
26 foreach my $ibx (@ibxs) {
27 # XXX: users can shoot themselves in the foot, with opt->{indexlevel}
28 $ibx->{indexlevel} //= $opt->{indexlevel} //
29 PublicInbox::Admin::detect_indexlevel($ibx);
30 PublicInbox::Admin::scan_ibx_modules($mods, $ibx);
33 PublicInbox::Admin::require_or_die(keys %$mods);
34 PublicInbox::Admin::progress_prepare($opt);
35 PublicInbox::Admin::index_inbox($_, undef, $opt) for @ibxs;