diff options
author | Eric Wong <e@80x24.org> | 2016-02-27 21:57:57 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-02-27 21:57:57 +0000 |
commit | 052f26f3ada1042afa5acadbecc48b487f4e2d52 (patch) | |
tree | b6b30f94cdb20534ffc074359db30084c9858fa6 /public-inbox-index | |
parent | 617f35dacbd4e5972bf2d82411b45009bbc79a42 (diff) | |
download | public-inbox-052f26f3ada1042afa5acadbecc48b487f4e2d52.tar.gz |
This seems to match more closely with what is expected of Perl packages based on how blib is used. Hopefully makes the top-level source tree less cluttered and things easier-to-find.
Diffstat (limited to 'public-inbox-index')
-rwxr-xr-x | public-inbox-index | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/public-inbox-index b/public-inbox-index deleted file mode 100755 index 578d91d5..00000000 --- a/public-inbox-index +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/perl -w -# Copyright (C) 2015 all contributors <meta@public-inbox.org> -# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) -# Basic tool to create a Xapian search index for a git repository -# configured for public-inbox. -# Usage with libeatmydata <https://www.flamingspork.com/projects/libeatmydata/> -# highly recommended: eatmydata public-inbox-index GIT_DIR - -use strict; -use warnings; -my $usage = "public-inbox-index GIT_DIR"; -use PublicInbox::Config; -eval { require PublicInbox::SearchIdx }; -if ($@) { - print STDERR "Search::Xapian required for $0\n"; - exit 1; -} -my @dirs; - -sub resolve_git_dir { - my ($cd) = @_; - my @cmd = qw(git rev-parse --git-dir); - my $cmd = join(' ', @cmd); - my $pid = open my $fh, '-|'; - defined $pid or die "forking $cmd failed: $!\n"; - if ($pid == 0) { - if (defined $cd) { - chdir $cd or die "chdir $cd failed: $!\n"; - } - exec @cmd; - die "Failed to exec $cmd: $!\n"; - } else { - my $dir = eval { - local $/; - <$fh>; - }; - close $fh or die "error in $cmd: $!\n"; - chomp $dir; - return $cd if ($dir eq '.' && defined $cd); - $dir; - } -} - -if (@ARGV) { - @dirs = map { resolve_git_dir($_) } @ARGV; -} else { - @dirs = (resolve_git_dir()); -} - -sub usage { print STDERR "Usage: $usage\n"; exit 1 } -usage() unless @dirs; - -foreach my $dir (@dirs) { - index_dir($dir); -} - -sub index_dir { - my ($git_dir) = @_; - -d $git_dir or die "$git_dir does not appear to be a git repository\n"; - - system('git', "--git-dir=$git_dir", 'update-server-info') and - die "git update-server-info failed for $git_dir"; - my $s = PublicInbox::SearchIdx->new($git_dir, 1); - $s->index_sync; -} |