From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EDAF01F626 for ; Tue, 21 Feb 2023 12:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1676981865; bh=SJaxShnw7nXyr3eG/SVoWERHxzrkxOITvouVcp9sUpM=; h=From:To:Subject:Date:From; b=4Yg4oZ/FaH6j80zFxOgTkC383GypOmxjZ9fc/wOpsOZcOlgNH3f64//a7efyDqMQV V9Rdwj4oVt6sVmuL7lmKtE64bgAK6y7lP060nDCJTbry1/FZvHsGQ+wVHHzeJaYHa9 JOlcdBZrW3jSIkMYEWQUUP/CPiztOJsTCD4VyH8Y= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei_mirror: support --remote-manifest=URL Date: Tue, 21 Feb 2023 12:17:44 +0000 Message-Id: <20230221121744.359679-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Since PublicInbox::WWW already generates manifest.js.gz, I'm using an alternate path with PublicInbox::WwwStatic to host the manifest.js.gz for coderepos at an alternate location. The following snippet lets me host https://yhbt.net/lore/pub/manifest.js.gz for mirrored git repositories, while https://yhbt.net/lore/manifest.js.gz (no `pub') remains for inbox mirroring. ==> sample.psgi <== use PublicInbox::WWW; use PublicInbox::WwwStatic; my $www = PublicInbox::WWW->new; # use default PI_CONFIG my $st = PublicInbox::WwwStatic->new(docroot => '/path/to/code'); my $www_cb = sub { my ($env) = @_; if ($env->{PATH_INFO} eq '/pub/manifest.js.gz') { local $env->{PATH_INFO} = '/manifest.js.gz'; my $res = $st->call($env); return $res if $res->[0] != 404; } $www->call($env); }; builder { enable 'ReverseProxy'; enable 'Head'; mount '/lore' => $www_cb; } --- lib/PublicInbox/LeiMirror.pm | 8 +++++++- script/public-inbox-clone | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 4dedac9b..e4aa620e 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -1110,7 +1110,13 @@ sub try_manifest { $self->{-torsocks} //= $curl->torsocks($lei, $uri) or return; my $path = $uri->path; chop($path) eq '/' or die "BUG: $uri not canonicalized"; - $uri->path($path . '/manifest.js.gz'); + my $rmf = $lei->{opt}->{'remote-manifest'} // '/manifest.js.gz'; + if ($rmf =~ m!\A[^/:]+://!) { + $uri = URI->new($rmf); + } else { + $rmf = "/$rmf" if index($rmf, '/') != 0; + $uri->path($path.$rmf); + } my $manifest = $self->{-manifest} // "$self->{dst}/manifest.js.gz"; my %opt = (UNLINK => 1, SUFFIX => '.tmp', TMPDIR => 1); if (!$self->{dry_run} && $manifest =~ m!\A(.+?)/[^/]+\z! and -d $1) { diff --git a/script/public-inbox-clone b/script/public-inbox-clone index 598979bc..10ad3487 100755 --- a/script/public-inbox-clone +++ b/script/public-inbox-clone @@ -27,7 +27,7 @@ EOF # support both :/ GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ include|I=s@ exclude=s@ inbox-config=s inbox-version=i objstore=s manifest=s - project-list|projectslist=s post-update-hook=s@ + remote-manifest=s project-list|projectslist=s post-update-hook=s@ prune|p keep-going|k exit-code dry-run|n jobs|j=i no-torsocks torsocks=s epoch=s)) or die $help; if ($opt->{help}) { print $help; exit };