user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
0efde1a8499572092ce821e1d49098d2fd6c298b blob 1970 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
#!perl -w
# 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 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]

  clone remote public-inboxes

options:

  --torsocks VAL      whether or not to wrap git and curl commands with
                      torsocks (default: `auto')
                      Must be one of: `auto', `no' or `yes'
  --verbose | -v      increase verbosity (may be repeated)
    --quiet | -q      increase verbosity (may be repeated)
    -C DIR            chdir to specified directory
EOF
GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@
		no-torsocks torsocks=s)) or die $help;
if ($opt->{help}) { print $help; exit };
require PublicInbox::Admin; # loads Config
PublicInbox::Admin::do_chdir(delete $opt->{C});
PublicInbox::Admin::setup_signals();
$SIG{PIPE} = 'IGNORE';

my ($url, $dst, $extra) = @ARGV;
die $help if !defined($url) || defined($extra);
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 PublicInbox::LEI;
require PublicInbox::LeiExternal;
require PublicInbox::LeiMirror;
require PublicInbox::LeiCurl;
require PublicInbox::Lock;

$url = PublicInbox::LeiExternal::ext_canonicalize($url);
my $lei = bless {
	env => \%ENV, opt => $opt, cmd => 'public-inbox-clone',
	0 => *STDIN{GLOB}, 2 => *STDERR{GLOB},
}, 'PublicInbox::LEI';
open $lei->{1}, '+<&=', 1 or die "dup: $!";
open $lei->{3}, '.' or die "open . $!";
my $mrr = bless {
	lei => $lei,
	src => $url,
	dst => $dst,
}, 'PublicInbox::LeiMirror';
$mrr->do_mirror;
$mrr->can('_wq_done_wait')->([$mrr, $lei], $$);
exit(($lei->{child_error} // 0) >> 8);
debug log:

solving 0efde1a8 ...
found 0efde1a8 in https://80x24.org/public-inbox.git

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).