about summary refs log tree commit homepage
path: root/script/public-inbox-index
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-08-11 00:23:48 +0000
committerEric Wong <e@80x24.org>2016-08-11 02:28:40 +0000
commit58a5bb3e18901237b1ca34ef8f03f696be27d305 (patch)
tree1725220ed46271629d71b3c5af3b8b2b328755a1 /script/public-inbox-index
parentc357e8699d99e20e1033e13bd1e2faa9856fb456 (diff)
downloadpublic-inbox-58a5bb3e18901237b1ca34ef8f03f696be27d305.tar.gz
For some existing mailing list archives, messages are identified
by serial number (such as NNTP article numbers in gmane).  Those
links may become inaccessible (as is the current case for
gmane), so ensure users can still search based on old serial
numbers.

Now, I run the following periodically to get article numbers
from gmane (while news.gmane.org remains):

	NNTPSERVER=news.gmane.org
	export NNTPSERVER
	GROUP=gmane.comp.version-control.git
	perl -I lib scripts/xhdr-num2mid $GROUP --msgmap=/path/to/gmane.sqlite3

(I might integrate this further with public-inbox-* scripts one day).

My ~/.public-inbox/config as an added "altid" snippet which now
looks like this:

[publicinbox "git"]
	address = git@vger.kernel.org
	mainrepo = /path/to/git.vger.git
	newsgroup = inbox.comp.version-control.git

	; relative pathnames expand to $mainrepo/public-inbox/$file
	altid = serial:gmane:file=gmane.sqlite3

And run "public-inbox-index --reindex /path/to/git.vger.git"
periodically.

This ought to allow searching for "gmane:12345" to work for
Xapian-enabled instances.

Disclaimer: while public-inbox supports NNTP and stable article
serial numbers, use of those for public links is discouraged
since it encourages centralization.
Diffstat (limited to 'script/public-inbox-index')
-rwxr-xr-xscript/public-inbox-index21
1 files changed, 18 insertions, 3 deletions
diff --git a/script/public-inbox-index b/script/public-inbox-index
index 61f21d70..1431b99e 100755
--- a/script/public-inbox-index
+++ b/script/public-inbox-index
@@ -9,8 +9,10 @@
 use strict;
 use warnings;
 use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
+use Cwd 'abs_path';
 my $usage = "public-inbox-index GIT_DIR";
 use PublicInbox::Config;
+my $config = PublicInbox::Config->new;
 eval { require PublicInbox::SearchIdx };
 if ($@) {
         print STDERR "Search::Xapian required for $0\n";
@@ -42,8 +44,8 @@ sub resolve_git_dir {
                 };
                 close $fh or die "error in $cmd: $!\n";
                 chomp $dir;
-                return $cd if ($dir eq '.' && defined $cd);
-                $dir;
+                return abs_path($cd) if ($dir eq '.' && defined $cd);
+                abs_path($dir);
         }
 }
 
@@ -56,13 +58,26 @@ if (@ARGV) {
 sub usage { print STDERR "Usage: $usage\n"; exit 1 }
 usage() unless @dirs;
 
+foreach my $k (keys %$config) {
+        $k =~ /\Apublicinbox\.([^\.]+)\.mainrepo\z/ or next;
+        my $name = $1;
+        my $v = $config->{$k};
+        for my $i (0..$#dirs) {
+                next if $dirs[$i] ne $v;
+                my $ibx = $config->lookup_name($name);
+                $dirs[$i] = $ibx if $ibx;
+        }
+}
+
 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";
+        if (!ref $git_dir && ! -d $git_dir) {
+                die "$git_dir does not appear to be a git repository\n";
+        }
         my $s = PublicInbox::SearchIdx->new($git_dir, 1);
         $s->index_sync({ reindex => $reindex });
 }