X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-init;h=ae4a575ca3ba80423fcc0fa0579256a0386baacb;hb=16870b42ac68a8704467989cb20c2c571e4749ab;hp=6852f64a9e5793b13a3077524f8ab1fa15c5ef70;hpb=3f3867da5e5ff10b941e942c9974ddbf1e5464c1;p=public-inbox.git diff --git a/script/public-inbox-init b/script/public-inbox-init index 6852f64a..ae4a575c 100755 --- a/script/public-inbox-init +++ b/script/public-inbox-init @@ -5,9 +5,8 @@ use strict; use v5.10.1; use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/; use Fcntl qw(:DEFAULT); -my $usage = 'public-inbox-init NAME INBOX_DIR HTTP_URL ADDRESS [ADDRESS..]'; my $help = < \$version, 'L|index-level|indexlevel=s' => \$indexlevel, 'S|skip|skip-epoch=i' => \$skip_epoch, - 'N|skip-artnum=i' => \$skip_artnum, + 'skip-artnum=i' => \$skip_artnum, 'j|jobs=i' => \$jobs, - 'help|?' => \$show_help, + 'ng|newsgroup=s' => \$ng, + 'skip-docdata' => \$skip_docdata, + 'help|h' => \$show_help, ); my $usage_cb = sub { - print STDERR "Usage: $usage\n"; + print STDERR $help; exit 1; }; GetOptions(%opts) or $usage_cb->(); @@ -53,7 +57,11 @@ my $inboxdir = shift @ARGV or $usage_cb->(); my $http_url = shift @ARGV or $usage_cb->(); my (@address) = @ARGV; @address or $usage_cb->(); -my %seen; + +$ng =~ m![^A-Za-z0-9/_\.\-\~\@\+\=:]! and + die "--newsgroup `$ng' is not valid\n"; +($ng =~ m!\A\.! || $ng =~ m!\.\z!) and + die "--newsgroup `$ng' must not start or end with `.'\n"; require PublicInbox::Config; my $pi_config = PublicInbox::Config->default_file; @@ -84,7 +92,7 @@ sysopen($lockfh, $lockfile, O_RDWR|O_CREAT|O_EXCL) or do { exit(255); }; my $auto_unlink = UnlinkMe->new($lockfile); -my $perm; +my ($perm, %seen); if (-e $pi_config) { open(my $oh, '<', $pi_config) or die "unable to read $pi_config: $!\n"; my @st = stat($oh); @@ -170,6 +178,12 @@ if (defined $jobs) { require PublicInbox::InboxWritable; $ibx = PublicInbox::InboxWritable->new($ibx, $creat_opt); +if ($skip_docdata) { + $ibx->{indexlevel} //= 'full'; # ensure init_inbox writes xdb + $ibx->{indexlevel} eq 'basic' and + die "--skip-docdata ignored with --indexlevel=basic\n"; + $ibx->{-skip_docdata} = $skip_docdata; +} $ibx->init_inbox(0, $skip_epoch, $skip_artnum); # needed for git prior to v2.1.0 @@ -185,6 +199,7 @@ PublicInbox::Import::run_die([@x, "$pfx.inboxdir", $inboxdir]); if (defined($indexlevel)) { PublicInbox::Import::run_die([@x, "$pfx.indexlevel", $indexlevel]); } +PublicInbox::Import::run_die([@x, "$pfx.newsgroup", $ng]) if $ng ne ''; # needed for git prior to v2.1.0 if (defined $perm) {