The current manifest.js.gz generation in WWW doesn't account for
PSGI mount prefixes (and grokmirror 1.x appears to work fine).
In other words, <https://yhbt.net/lore/lkml/manifest.js.gz>
currently has keys like "/lkml/git/0.git" and not
"/lore/lkml/git/0.git" where "/lore" is the PSGI mount prefix.
This works fine with the prefix accounted for in my grokmirror
(1.x) repos.conf like this:
site = https://yhbt.net/lore/
manifest = https://yhbt.net/lore/manifest.js.gz
Adding the PSGI mount prefix in manifest.js.gz is probably not
desirable since it would force the prefix into the locally
cloned path by grokmirror, and all the cloned directories
would have the remote PSGI mount prefix prepended to the
toplevel.
So, "lei add-external --mirror" needs to account for PSGI
mount prefixes by deducing the prefix based on available keys
in the manifest.js.gz hash table.
t/lei-import.t
t/lei-index.t
t/lei-lcat.t
t/lei-import.t
t/lei-index.t
t/lei-lcat.t
t/lei-mirror.t
t/lei-p2q.t
t/lei-q-kw.t
t/lei-mirror.t
t/lei-p2q.t
t/lei-q-kw.t
index_cloned_inbox($self, 2);
}
index_cloned_inbox($self, 2);
}
+# PSGI mount prefixes and manifest.js.gz prefixes don't always align...
+sub deduce_epochs ($$) {
+ my ($m, $path) = @_;
+ my ($v1_bare, @v2_epochs);
+ my $path_pfx = '';
+ do {
+ $v1_bare = $m->{$path};
+ @v2_epochs = grep(m!\A\Q$path\E/git/[0-9]+\.git\z!, keys %$m);
+ } while (!defined($v1_bare) && !@v2_epochs &&
+ $path =~ s!\A(/[^/]+)/!/! and $path_pfx .= $1);
+ ($path_pfx, $v1_bare, @v2_epochs);
+}
+
sub try_manifest {
my ($self) = @_;
my $uri = URI->new($self->{src});
sub try_manifest {
my ($self) = @_;
my $uri = URI->new($self->{src});
die "$uri: error decoding `$js': $@" if $@;
ref($m) eq 'HASH' or die "$uri unknown type: ".ref($m);
die "$uri: error decoding `$js': $@" if $@;
ref($m) eq 'HASH' or die "$uri unknown type: ".ref($m);
- my $v1_bare = $m->{$path};
- my @v2_epochs = grep(m!\A\Q$path\E/git/[0-9]+\.git\z!, keys %$m);
+ my ($path_pfx, $v1_bare, @v2_epochs) = deduce_epochs($m, $path);
if (@v2_epochs) {
# It may be possible to have v1 + v2 in parallel someday:
$lei->err(<<EOM) if defined $v1_bare;
if (@v2_epochs) {
# It may be possible to have v1 + v2 in parallel someday:
$lei->err(<<EOM) if defined $v1_bare;
# @v2_epochs
# ignoring $v1_bare (use --inbox-version=1 to force v1 instead)
EOM
# @v2_epochs
# ignoring $v1_bare (use --inbox-version=1 to force v1 instead)
EOM
- @v2_epochs = map { $uri->path($_); $uri->clone } @v2_epochs;
+ @v2_epochs = map {
+ $uri->path($path_pfx.$_);
+ $uri->clone
+ } @v2_epochs;
clone_v2($self, \@v2_epochs);
clone_v2($self, \@v2_epochs);
+ } elsif (defined $v1_bare) {
- } elsif (my @maybe = grep(m!\Q$path\E!, keys %$m)) {
- die "E: confused by <$uri>, possible matches:\n@maybe";
- die "E: confused by <$uri>";
+ die "E: confused by <$uri>, possible matches:\n\t",
+ join(', ', sort keys %$m), "\n";
--- /dev/null
+use Plack::Builder;
+use PublicInbox::WWW;
+my $www = PublicInbox::WWW->new;
+$www->preload;
+builder {
+ enable 'Head';
+ mount '/pfx' => builder { sub { $www->call(@_) } };
+ mount '/' => builder { sub { $www->call(@_) } };
+};
my ($tmpdir, $for_destroy) = tmpdir();
my $http = 'http://'.tcp_host_port($sock);
my ($ro_home, $cfg_path) = setup_public_inboxes;
my ($tmpdir, $for_destroy) = tmpdir();
my $http = 'http://'.tcp_host_port($sock);
my ($ro_home, $cfg_path) = setup_public_inboxes;
-my $cmd = [ qw(-httpd -W0), "--stdout=$tmpdir/out", "--stderr=$tmpdir/err" ];
+my $cmd = [ qw(-httpd -W0 ./t/lei-mirror.psgi),
+ "--stdout=$tmpdir/out", "--stderr=$tmpdir/err" ];
my $td = start_script($cmd, { PI_CONFIG => $cfg_path }, { 3 => $sock });
test_lei({ tmpdir => $tmpdir }, sub {
my $home = $ENV{HOME};
my $td = start_script($cmd, { PI_CONFIG => $cfg_path }, { 3 => $sock });
test_lei({ tmpdir => $tmpdir }, sub {
my $home = $ENV{HOME};
lei_ok('ls-external');
unlike($lei_out, qr!\Q$t2-fail\E!, 'not added to ls-external');
lei_ok('ls-external');
unlike($lei_out, qr!\Q$t2-fail\E!, 'not added to ls-external');
+ lei_ok('add-external', "$t1-pfx", '--mirror', "$http/pfx/t1/",
+ \'--mirror v1 w/ PSGI prefix');
+
my %phail = (
HTTPS => 'https://public-inbox.org/' . 'phail',
ONION =>
my %phail = (
HTTPS => 'https://public-inbox.org/' . 'phail',
ONION =>