about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-10-16 08:59:55 +0000
committerEric Wong <e@80x24.org>2019-10-16 09:00:26 +0000
commit3c39f9c942a6975245fda878e9b957d8d3367662 (patch)
tree10c2ea542787ff08dae59ddd3f13f129ed63dd76 /lib/PublicInbox
parent28264f7af4d9f4fab951f0613a0b08b6e98af7d3 (diff)
downloadpublic-inbox-3c39f9c942a6975245fda878e9b957d8d3367662.tar.gz
"mainrepo" ws a bad name and artifact from the early days when I
intended for there to be a "spamrepo" (now just the
ENV{PI_EMERGENCY} Maildir).  With v2, "mainrepo" can be
especially confusing, since v2 needs at least two git
repositories (epoch + all.git) to function and we shouldn't
confuse users by having them point to a git repository for v2.

Much of our documentation already references "INBOX_DIR" for
command-line arguments, so use "inboxdir" as the
git-config(1)-friendly variant for that.

"mainrepo" remains supported indefinitely for compatibility.
Users may need to revert to old versions, or may be referring
to old documentation and must not be forced to change config
files to account for this change.

So if you're using "mainrepo" today, I do NOT recommend changing
it right away because other bugs can lurk.

Link: https://public-inbox.org/meta/874l0ice8v.fsf@alyssa.is/
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/Admin.pm8
-rw-r--r--lib/PublicInbox/AdminEdit.pm4
-rw-r--r--lib/PublicInbox/AltId.pm4
-rw-r--r--lib/PublicInbox/Config.pm10
-rw-r--r--lib/PublicInbox/Inbox.pm14
-rw-r--r--lib/PublicInbox/InboxWritable.pm2
-rw-r--r--lib/PublicInbox/Search.pm6
-rw-r--r--lib/PublicInbox/SearchIdx.pm8
-rw-r--r--lib/PublicInbox/V2Writable.pm16
-rw-r--r--lib/PublicInbox/WwwAtomStream.pm2
-rw-r--r--lib/PublicInbox/WwwListing.pm2
-rw-r--r--lib/PublicInbox/WwwStream.pm2
-rw-r--r--lib/PublicInbox/WwwText.pm3
-rw-r--r--lib/PublicInbox/Xapcmd.pm4
14 files changed, 46 insertions, 39 deletions
diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm
index 2b25cf01..e9fb5d6f 100644
--- a/lib/PublicInbox/Admin.pm
+++ b/lib/PublicInbox/Admin.pm
@@ -61,7 +61,7 @@ sub detect_indexlevel ($) {
                         $l = $m;
                 } elsif ($m ne '') {
                         warn <<"";
-$ibx->{mainrepo} has unexpected indexlevel in Xapian: $m
+$ibx->{inboxdir} has unexpected indexlevel in Xapian: $m
 
                 }
         }
@@ -74,7 +74,7 @@ sub unconfigured_ibx ($$) {
         PublicInbox::Inbox->new({
                 name => $name,
                 address => [ "$name\@example.com" ],
-                mainrepo => $dir,
+                inboxdir => $dir,
                 # TODO: consumers may want to warn on this:
                 #-unconfigured => 1,
         });
@@ -101,12 +101,12 @@ sub resolve_inboxes ($;$) {
                 $cfg->each_inbox(sub {
                         my ($ibx) = @_;
                         $ibx->{version} ||= 1;
-                        my $path = abs_path($ibx->{mainrepo});
+                        my $path = abs_path($ibx->{inboxdir});
                         if (defined($path)) {
                                 $dir2ibx{$path} = $ibx;
                         } else {
                                 warn <<EOF;
-W: $ibx->{name} $ibx->{mainrepo}: $!
+W: $ibx->{name} $ibx->{inboxdir}: $!
 EOF
                         }
                 });
diff --git a/lib/PublicInbox/AdminEdit.pm b/lib/PublicInbox/AdminEdit.pm
index 2e2a8629..d4a92266 100644
--- a/lib/PublicInbox/AdminEdit.pm
+++ b/lib/PublicInbox/AdminEdit.pm
@@ -25,7 +25,7 @@ sub check_editable ($) {
                 # it's possible for a Xapian directory to exist,
                 # but Search::Xapian to go missing/broken.
                 # Make sure it's purged in that case:
-                $ibx->over or die "no over.sqlite3 in $ibx->{mainrepo}\n";
+                $ibx->over or die "no over.sqlite3 in $ibx->{inboxdir}\n";
 
                 # $ibx->{search} is populated by $ibx->over call
                 my $xdir_ro = $ibx->{search}->xdir(1);
@@ -51,7 +51,7 @@ sub check_editable ($) {
 # $rewrites = [ array commits keyed by epoch ]
 sub show_rewrites ($$$) {
         my ($fh, $ibx, $rewrites) = @_;
-        print $fh "$ibx->{mainrepo}:";
+        print $fh "$ibx->{inboxdir}:";
         if (scalar @$rewrites) {
                 my $epoch = -1;
                 my @out = map {;
diff --git a/lib/PublicInbox/AltId.pm b/lib/PublicInbox/AltId.pm
index 6103d52e..b4daaed2 100644
--- a/lib/PublicInbox/AltId.pm
+++ b/lib/PublicInbox/AltId.pm
@@ -32,9 +32,9 @@ sub new {
         my $f = $params{file} or die "file: required for $type spec $spec\n";
         unless (index($f, '/') == 0) {
                 if (($ibx->{version} || 1) == 1) {
-                        $f = "$ibx->{mainrepo}/public-inbox/$f";
+                        $f = "$ibx->{inboxdir}/public-inbox/$f";
                 } else {
-                        $f = "$ibx->{mainrepo}/$f";
+                        $f = "$ibx->{inboxdir}/$f";
                 }
         }
         bless {
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 509de0a0..2da202f9 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -93,7 +93,7 @@ sub each_inbox {
         # may auto-vivify if config file is non-existent:
         foreach my $section (@{$self->{-section_order}}) {
                 next if $section !~ m!\Apublicinbox\.([^/]+)\z!;
-                defined($self->{"publicinbox.$1.mainrepo"}) or next;
+                defined($self->{"publicinbox.$1.inboxdir"}) or next;
                 my $ibx = lookup_name($self, $1) or next;
                 $cb->($ibx);
         }
@@ -362,12 +362,16 @@ sub _fill {
         my ($self, $pfx) = @_;
         my $ibx = {};
 
-        foreach my $k (qw(mainrepo filter url newsgroup
+        foreach my $k (qw(inboxdir filter url newsgroup
                         infourl watch watchheader httpbackendmax
                         replyto feedmax nntpserver indexlevel)) {
                 my $v = $self->{"$pfx.$k"};
                 $ibx->{$k} = $v if defined $v;
         }
+
+        # backwards compatibility:
+        $ibx->{inboxdir} //= $self->{"$pfx.mainrepo"};
+
         foreach my $k (qw(obfuscate)) {
                 my $v = $self->{"$pfx.$k"};
                 defined $v or next;
@@ -385,7 +389,7 @@ sub _fill {
                 }
         }
 
-        return unless $ibx->{mainrepo};
+        return unless $ibx->{inboxdir};
         my $name = $pfx;
         $name =~ s/\Apublicinbox\.//;
 
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 85f56acb..5feb2154 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -109,7 +109,7 @@ sub new {
         _set_limiter($opts, $pi_config, 'httpbackend');
         _set_uint($opts, 'feedmax', 25);
         $opts->{nntpserver} ||= $pi_config->{'publicinbox.nntpserver'};
-        my $dir = $opts->{mainrepo};
+        my $dir = $opts->{inboxdir};
         if (defined $dir && -f "$dir/inbox.lock") {
                 $opts->{version} = 2;
         }
@@ -129,7 +129,7 @@ sub git_epoch {
         my ($self, $epoch) = @_;
         ($self->{version} || 1) == 2 or return;
         $self->{"$epoch.git"} ||= eval {
-                my $git_dir = "$self->{mainrepo}/git/$epoch.git";
+                my $git_dir = "$self->{inboxdir}/git/$epoch.git";
                 my $g = PublicInbox::Git->new($git_dir);
                 $g->{-httpbackend_limiter} = $self->{-httpbackend_limiter};
                 # no cleanup needed, we never cat-file off this, only clone
@@ -140,7 +140,7 @@ sub git_epoch {
 sub git {
         my ($self) = @_;
         $self->{git} ||= eval {
-                my $git_dir = $self->{mainrepo};
+                my $git_dir = $self->{inboxdir};
                 $git_dir .= '/all.git' if (($self->{version} || 1) == 2);
                 my $g = PublicInbox::Git->new($git_dir);
                 $g->{-httpbackend_limiter} = $self->{-httpbackend_limiter};
@@ -157,7 +157,7 @@ sub max_git_epoch {
         my $changed = git($self)->alternates_changed;
         if (!defined($cur) || $changed) {
                 $self->git->cleanup if $changed;
-                my $gits = "$self->{mainrepo}/git";
+                my $gits = "$self->{inboxdir}/git";
                 if (opendir my $dh, $gits) {
                         my $max = -1;
                         while (defined(my $git_dir = readdir($dh))) {
@@ -177,7 +177,7 @@ sub mm {
         $self->{mm} ||= eval {
                 require PublicInbox::Msgmap;
                 _cleanup_later($self);
-                my $dir = $self->{mainrepo};
+                my $dir = $self->{inboxdir};
                 if (($self->{version} || 1) >= 2) {
                         PublicInbox::Msgmap->new_file("$dir/msgmap.sqlite3");
                 } else {
@@ -220,7 +220,7 @@ sub description {
         my ($self) = @_;
         my $desc = $self->{description};
         return $desc if defined $desc;
-        $desc = try_cat("$self->{mainrepo}/description");
+        $desc = try_cat("$self->{inboxdir}/description");
         local $/ = "\n";
         chomp $desc;
         $desc =~ s/\s+/ /smg;
@@ -232,7 +232,7 @@ sub cloneurl {
         my ($self) = @_;
         my $url = $self->{cloneurl};
         return $url if $url;
-        $url = try_cat("$self->{mainrepo}/cloneurl");
+        $url = try_cat("$self->{inboxdir}/cloneurl");
         my @url = split(/\s+/s, $url);
         local $/ = "\n";
         chomp @url;
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index 4b22149f..174e4245 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -35,7 +35,7 @@ sub init_inbox {
         # TODO: honor skip_artnum
         my $v = $self->{version} || 1;
         if ($v == 1) {
-                my $dir = $self->{mainrepo} or die "no mainrepo in inbox\n";
+                my $dir = $self->{inboxdir} or die "no inboxdir in inbox\n";
                 PublicInbox::Import::init_bare($dir);
         } else {
                 my $v2w = importer($self);
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index a0e6a93b..06a84c34 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -126,9 +126,9 @@ chomp @HELP;
 sub xdir ($;$) {
         my ($self, $rdonly) = @_;
         if ($self->{version} == 1) {
-                "$self->{mainrepo}/public-inbox/xapian" . SCHEMA_VERSION;
+                "$self->{inboxdir}/public-inbox/xapian" . SCHEMA_VERSION;
         } else {
-                my $dir = "$self->{mainrepo}/xap" . SCHEMA_VERSION;
+                my $dir = "$self->{inboxdir}/xap" . SCHEMA_VERSION;
                 return $dir if $rdonly;
 
                 my $shard = $self->{shard};
@@ -173,7 +173,7 @@ sub new {
         my ($class, $ibx) = @_;
         ref $ibx or die "BUG: expected PublicInbox::Inbox object: $ibx";
         my $self = bless {
-                mainrepo => $ibx->{mainrepo},
+                inboxdir => $ibx->{inboxdir},
                 altid => $ibx->{altid},
                 version => $ibx->{version} // 1,
         }, $class;
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 1b1a21b7..aed3875a 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -32,7 +32,7 @@ sub new {
         my ($class, $ibx, $creat, $shard) = @_;
         ref $ibx or die "BUG: expected PublicInbox::Inbox object: $ibx";
         my $levels = qr/\A(?:full|medium|basic)\z/;
-        my $mainrepo = $ibx->{mainrepo};
+        my $inboxdir = $ibx->{inboxdir};
         my $version = $ibx->{version} || 1;
         my $indexlevel = 'full';
         my $altid = $ibx->{altid};
@@ -49,7 +49,7 @@ sub new {
         }
         $ibx = PublicInbox::InboxWritable->new($ibx);
         my $self = bless {
-                mainrepo => $mainrepo,
+                inboxdir => $inboxdir,
                 -inbox => $ibx,
                 git => $ibx->git,
                 -altid => $altid,
@@ -58,7 +58,7 @@ sub new {
         }, $class;
         $ibx->umask_prepare;
         if ($version == 1) {
-                $self->{lock_path} = "$mainrepo/ssoma.lock";
+                $self->{lock_path} = "$inboxdir/ssoma.lock";
                 my $dir = $self->xdir;
                 $self->{over} = PublicInbox::OverIdx->new("$dir/over.sqlite3");
         } elsif ($version == 2) {
@@ -603,7 +603,7 @@ sub _msgmap_init {
         die "BUG: _msgmap_init is only for v1\n" if $self->{version} != 1;
         $self->{mm} ||= eval {
                 require PublicInbox::Msgmap;
-                PublicInbox::Msgmap->new($self->{mainrepo}, 1);
+                PublicInbox::Msgmap->new($self->{inboxdir}, 1);
         };
 }
 
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 627bcba9..6a88f62a 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -76,7 +76,7 @@ sub new {
         # $creat may be any true value, or 0/undef.  A hashref is true,
         # and $creat->{nproc} may be set to an integer
         my ($class, $v2ibx, $creat) = @_;
-        my $dir = $v2ibx->{mainrepo} or die "no mainrepo in inbox\n";
+        my $dir = $v2ibx->{inboxdir} or die "no inboxdir in inbox\n";
         unless (-d $dir) {
                 if ($creat) {
                         require File::Path;
@@ -304,7 +304,7 @@ sub idx_init {
                 # Now that all subprocesses are up, we can open the FDs
                 # for SQLite:
                 my $mm = $self->{mm} = PublicInbox::Msgmap->new_file(
-                        "$self->{-inbox}->{mainrepo}/msgmap.sqlite3", 1);
+                        "$self->{-inbox}->{inboxdir}/msgmap.sqlite3", 1);
                 $mm->{dbh}->begin_work;
         });
 }
@@ -315,7 +315,7 @@ sub idx_init {
 sub _replace_oids ($$$) {
         my ($self, $mime, $replace_map) = @_;
         $self->done;
-        my $pfx = "$self->{-inbox}->{mainrepo}/git";
+        my $pfx = "$self->{-inbox}->{inboxdir}/git";
         my $rewrites = []; # epoch => commit
         my $max = $self->{epoch_max};
 
@@ -663,8 +663,8 @@ sub done {
 sub fill_alternates ($$) {
         my ($self, $epoch) = @_;
 
-        my $pfx = "$self->{-inbox}->{mainrepo}/git";
-        my $all = "$self->{-inbox}->{mainrepo}/all.git";
+        my $pfx = "$self->{-inbox}->{inboxdir}/git";
+        my $all = "$self->{-inbox}->{inboxdir}/all.git";
 
         unless (-d $all) {
                 PublicInbox::Import::init_bare($all);
@@ -690,7 +690,7 @@ sub fill_alternates ($$) {
 
 sub git_init {
         my ($self, $epoch) = @_;
-        my $git_dir = "$self->{-inbox}->{mainrepo}/git/$epoch.git";
+        my $git_dir = "$self->{-inbox}->{inboxdir}/git/$epoch.git";
         my @cmd = (qw(git init --bare -q), $git_dir);
         PublicInbox::Import::run_die(\@cmd);
         @cmd = (qw/git config/, "--file=$git_dir/config",
@@ -703,7 +703,7 @@ sub git_init {
 sub git_dir_latest {
         my ($self, $max) = @_;
         $$max = -1;
-        my $pfx = "$self->{-inbox}->{mainrepo}/git";
+        my $pfx = "$self->{-inbox}->{inboxdir}/git";
         return unless -d $pfx;
         my $latest;
         opendir my $dh, $pfx or die "opendir $pfx: $!\n";
@@ -935,7 +935,7 @@ sub update_last_commit ($$$$) {
         last_epoch_commit($self, $i, $cmt);
 }
 
-sub git_dir_n ($$) { "$_[0]->{-inbox}->{mainrepo}/git/$_[1].git" }
+sub git_dir_n ($$) { "$_[0]->{-inbox}->{inboxdir}/git/$_[1].git" }
 
 sub last_commits ($$) {
         my ($self, $epoch_max) = @_;
diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm
index 05659f1f..83984d37 100644
--- a/lib/PublicInbox/WwwAtomStream.pm
+++ b/lib/PublicInbox/WwwAtomStream.pm
@@ -84,7 +84,7 @@ sub atom_header {
                 $self_url .= 'new.atom';
                 $page_id = "mailto:$ibx->{-primary_address}";
         }
-        my $mtime = (stat($ibx->{mainrepo}))[9] || time;
+        my $mtime = (stat($ibx->{inboxdir}))[9] || time;
 
         qq(<?xml version="1.0" encoding="us-ascii"?>\n) .
         qq(<feed\nxmlns="http://www.w3.org/2005/Atom"\n) .
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index 1d4029f0..c5e16eb2 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -141,7 +141,7 @@ sub fingerprint ($) {
 sub manifest_add ($$;$$) {
         my ($manifest, $ibx, $epoch, $default_desc) = @_;
         my $url_path = "/$ibx->{name}";
-        my $git_dir = $ibx->{mainrepo};
+        my $git_dir = $ibx->{inboxdir};
         if (defined $epoch) {
                 $git_dir .= "/git/$epoch.git";
                 $url_path .= "/git/$epoch.git";
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index f5338c39..6696cc35 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -98,7 +98,7 @@ sub _html_end {
                 $seen{$http} = 1;
                 for my $i (0..$max) {
                         # old parts my be deleted:
-                        -d "$ibx->{mainrepo}/git/$i.git" or next;
+                        -d "$ibx->{inboxdir}/git/$i.git" or next;
                         my $url = "$http/$i";
                         $seen{$url} = 1;
                         push @urls, "$url $dir/git/$i.git";
diff --git a/lib/PublicInbox/WwwText.pm b/lib/PublicInbox/WwwText.pm
index bcda665c..1c7b92bd 100644
--- a/lib/PublicInbox/WwwText.pm
+++ b/lib/PublicInbox/WwwText.pm
@@ -145,6 +145,9 @@ sub inbox_config ($$$) {
 ; see public-inbox-config(5) manpage for more details:
 ; https://public-inbox.org/public-inbox-config.html
 [publicinbox "$name"]
+        inboxdir = /path/to/top-level-inbox
+        ; note: public-inbox before v1.2.0 used "mainrepo"
+        ; instead of "inboxdir", both remain supported after 1.2
         mainrepo = /path/to/top-level-inbox
 EOS
         for my $k (qw(address listid)) {
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index 819d7829..22e56f42 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -153,7 +153,7 @@ sub run {
         my ($ibx, $task, $opt) = @_; # task = 'cpdb' or 'compact'
         my $cb = \&${\"PublicInbox::Xapcmd::$task"};
         PublicInbox::Admin::progress_prepare($opt ||= {});
-        my $dir = $ibx->{mainrepo} or die "no mainrepo in inbox\n";
+        my $dir = $ibx->{inboxdir} or die "no inboxdir in inbox\n";
         runnable_or_die($XAPIAN_COMPACT) if $opt->{compact};
         my $reindex; # v1:{ from => $x40 }, v2:{ from => [ $x40, $x40, .. ] } }
         my $from; # per-epoch ranges
@@ -181,7 +181,7 @@ sub run {
         if ($v == 1) {
                 if (defined $reshard) {
                         warn
-"--reshard=$reshard ignored for v1 $ibx->{mainrepo}\n";
+"--reshard=$reshard ignored for v1 $ibx->{inboxdir}\n";
                 }
                 my $old_parent = dirname($old);
                 same_fs_or_die($old_parent, $old);