diff options
Diffstat (limited to 'script/public-inbox-clone')
-rwxr-xr-x | script/public-inbox-clone | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/script/public-inbox-clone b/script/public-inbox-clone index 54059d03..c3e64485 100755 --- a/script/public-inbox-clone +++ b/script/public-inbox-clone @@ -2,14 +2,14 @@ # Copyright (C) all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> # Wrapper to git clone remote public-inboxes -use strict; -use v5.10.1; +use v5.12; use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev); my $opt = {}; my $help = <<EOF; # the following should fit w/o scrolling in 80x24 term: -usage: public-inbox-clone INBOX_URL [DESTINATION] +usage: public-inbox-clone [OPTIONS] INBOX_URL [INBOX_DIR] + public-inbox-clone [OPTIONS] ROOT_URL [DESTINATION] - clone remote public-inboxes + clone remote public-inboxes or grokmirror manifests options: @@ -17,12 +17,23 @@ options: --torsocks VAL whether or not to wrap git and curl commands with torsocks (default: `auto') Must be one of: `auto', `no' or `yes' + --dry-run | -n show what would be cloned without cloning --verbose | -v increase verbosity (may be repeated) - --quiet | -q increase verbosity (may be repeated) + --quiet | -q disable progress reporting -C DIR chdir to specified directory + +See public-inbox-clone(1) man page for --manifest, --remote-manifest, +--objstore, --project-list, --post-update-hook, --include, --exclude, +--prune, --keep-going, --jobs, --inbox-config EOF -GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ - no-torsocks torsocks=s epoch=s)) or die $help; + +# cgit calls it `project-list', grokmirror calls it `projectslist', +# 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 + remote-manifest=s project-list|projectslist=s post-update-hook=s@ + prune|p keep-going|k exit-code purge + dry-run|n jobs|j=i no-torsocks torsocks=s epoch=s)) or die $help; if ($opt->{help}) { print $help; exit }; require PublicInbox::Admin; # loads Config PublicInbox::Admin::do_chdir(delete $opt->{C}); @@ -35,12 +46,10 @@ defined($dst) or ($dst) = ($url =~ m!/([^/]+)/?\z!); index($dst, "\n") >= 0 and die "`\\n' not allowed in `$dst'"; # n.b. this is still a truckload of code... -require URI; +require File::Spec; require PublicInbox::LEI; require PublicInbox::LeiExternal; require PublicInbox::LeiMirror; -require PublicInbox::LeiCurl; -require PublicInbox::Lock; $url = PublicInbox::LeiExternal::ext_canonicalize($url); my $lei = bless { @@ -52,8 +61,10 @@ open $lei->{3}, '.' or die "open . $!"; my $mrr = bless { lei => $lei, src => $url, - dst => $dst, + dst => File::Spec->canonpath($dst), }, 'PublicInbox::LeiMirror'; + +$? = 0; $mrr->do_mirror; -$mrr->can('_wq_done_wait')->([$mrr, $lei], $$); +$mrr->can('_wq_done_wait')->($$, $mrr, $lei); exit(($lei->{child_error} // 0) >> 8); |