bin/rrr-client

filter: Statementstmt 71.4% 20 / 28 Branchbran 11.1% 2 / 18 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 39.7% 27 / 68 CC 1 SCAR 0.0
CC
1
Cov
39%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« bin/rrr-update ↑ Summary bin/rrr-overview »
1 #!/usr/bin/perl
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Pod::Usage qw(pod2usage);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 rrr-client - continously mirror recent updates
10  
11 =head1 SYNOPSIS
12  
13 rrr-client [options]
14  
15 rrr-client --source some.mirror::module/ --target /some/dir/
16  
17 =head1 OPTIONS
18  
19 =over 8
20  
21 =cut
22  
23 1 my @opt = <<'=back' =~ /B<--(\S+)>/g;
24  
25 =item B<--help|h>
26  
27 Prints a brief message and exits.
28  
29 =item B<--max-files-per-connection=i>
30  
31 Defaults to 20000. Same as max_files_per_connection in
32 File::Rsync::Mirror::Recent
33  
34 =item B<--password=s>
35  
36 Password if the rsync source requires it. Can also be set by setting
37 the environment variable RSYNC_PASSWORD.
38  
39 =item B<--rsync-timeout=i>
40  
41 Defaults to 30. Same as C<timeout> within C<rsync_options> in
42 File::Rsync::Mirror::Recent
43  
44 =item B<--runstatusfile=s>
45  
46 Only needed for debugging. Path to the internally used status file.
47 Argument is passed through to the File::Rsync::Mirror::Recent object.
48  
49 =item B<--skip-deletes!>
50  
51 Defaults to false. If true, skips all delete events in the index files
52 which means no files are being deleted that have been deleted upstream.
53  
54 =item B<--source=s>
55  
56 Source to mirror from, including the name of the RECENT metadata file.
57 For example C<cpan-rsync.perl.org::CPAN/RECENT.recent>.
58  
59 =item B<--target=s>
60  
61 Destination directory for the mirror.
62  
63 =item B<--tmpdir=s>
64  
65 Directory for temporary files; should be on the same file system
66 partition as the C<--target> directory.
67  
68 =item B<--user=s>
69  
70 Username if the rsync source requires it.
71  
72 =item B<--verbose!>
73  
74 Defaults to false. Note: Older versions of rrr-client defaulted to
75 being verbose.
76  
77 =item B<--verboselog=s>
78  
79 Path to the logfile to write verbose progress information to.
80  
81 =back
82  
83 =head1 DESCRIPTION
84  
85 Mirror a remote directory based on a set of RECENT* files provided by
86 the remote server.
87  
88 =cut
89  
90 1 our %Opt;
91 1 ▶GetOptions
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions(\%main::Opt, @opt) or pod2usage(1) 1 0 1
92 (\%Opt,
93 @opt,
94 ) or pod2usage(1);
95  
96 1 ▶if ($Opt{help}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::Opt{"help"}) 1 0 1
97 1 pod2usage(0);
98 }
99 0 ▶pod2usage(1) unless $Opt{source} and $Opt{target};
Branch: 1 branch
BranchTrueFalseTotal
unless $main::Opt{"source"} and $main::Opt{"target"} 0 0 0
Condition0%0/3
$main::Opt{"source"} and $main::Opt{"target"}
!ll&&!rl&&r
000
MC/DC0%0/2
$main::Opt{"source"} and $main::Opt{"target"}
$main::Opt{"source"} $main::Opt{"target"}
Truth table0%0/3
A and B
A= $main::Opt{"source"}B= $main::Opt{"target"}
ABresult
0X0
100
111
100  
101 0 ▶$ENV{RSYNC_PASSWORD} = $Opt{password} if $Opt{password};
Branch: 1 branch
BranchTrueFalseTotal
if $main::Opt{"password"} 0 0 0
102 0 ▶$Opt{"max-files-per-connection"} ||= 20000;
Condition0%0/2
$main::Opt{"max-files-per-connection"} ||= 20000
l!l
00
MC/DC0%0/1
$main::Opt{"max-files-per-connection"} ||= 20000
$main::Opt{"max-files-per-connection"}
Truth table0%0/2
A
A= $main::Opt{"max-files-per-connection"}
Aresult
11
00
103 0 ▶$Opt{"rsync-timeout"} ||= 30;
Condition0%0/2
$main::Opt{"rsync-timeout"} ||= 30
l!l
00
MC/DC0%0/1
$main::Opt{"rsync-timeout"} ||= 30
$main::Opt{"rsync-timeout"}
Truth table0%0/2
A
A= $main::Opt{"rsync-timeout"}
Aresult
11
00
104 0 ▶$Opt{"skip-deletes"} ||=0;
Condition0%0/2
$main::Opt{"skip-deletes"} ||= 0
l!l
00
MC/DC0%0/1
$main::Opt{"skip-deletes"} ||= 0
$main::Opt{"skip-deletes"}
Truth table0%0/2
A
A= $main::Opt{"skip-deletes"}
Aresult
11
00
105 0 ▶$Opt{verbose} ||= 0;
Condition0%0/2
$main::Opt{"verbose"} ||= 0
l!l
00
MC/DC0%0/1
$main::Opt{"verbose"} ||= 0
$main::Opt{"verbose"}
Truth table0%0/2
A
A= $main::Opt{"verbose"}
Aresult
11
00
106  
107 1 ▶use File::Rsync::Mirror::Recent;
Subroutine BEGIN: called CC=1 SCAR=0.0
108 my $rrr = File::Rsync::Mirror::Recent->new
109 (
110 ignore_link_stat_errors => 1,
111 localroot => $Opt{target},
112 max_files_per_connection => $Opt{"max-files-per-connection"},
113 remote => ($Opt{user} ? $Opt{user} . '@' : '') . $Opt{source},
114 rsync_options => {
115 compress => 1,
116 links => 1,
117 'safe-links' => 1,
118 times => 1,
119 checksum => 0,
120 timeout => $Opt{"rsync-timeout"},
121 ($Opt{tmpdir} ? ('temp-dir' => $Opt{tmpdir}) : ()),
122 },
123 ($Opt{runstatusfile} ? (runstatusfile => $Opt{runstatusfile}) : ()),
124 ($Opt{tmpdir} ? (tempdir => $Opt{tmpdir}) : ()),
125 verbose => $Opt{verbose},
126 0 ▶ ($Opt{verboselog} ? (verboselog => $Opt{verboselog}) : ()),
Branch: 5 branches
BranchTrueFalseTotal
$main::Opt{'user'} ? : 0 0 0
$main::Opt{'tmpdir'} ? : 0 0 0
$main::Opt{'runstatusfile'} ? : 0 0 0
$main::Opt{'tmpdir'} ? : 0 0 0
$main::Opt{'verboselog'} ? : 0 0 0
127 # _logfilefordone => "recent-rmirror-donelog.log",
128 );
129  
130 0 $rrr->rmirror ( "skip-deletes" => $Opt{"skip-deletes"}, loop => 1 );
« bin/rrr-update ↑ Summary bin/rrr-overview »