line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::Syncer::Rsync; |
2
|
11
|
|
|
11
|
|
85
|
use warnings; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
365
|
|
3
|
11
|
|
|
11
|
|
81
|
use strict; |
|
11
|
|
|
|
|
35
|
|
|
11
|
|
|
|
|
475
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.029'; |
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
75
|
use base 'Test::Smoke::Syncer::Base'; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
6325
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 Test::Smoke::Syncer::Rsync |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This handles syncing with the B program. |
12
|
|
|
|
|
|
|
It should only be visible from the "parent-package" so no direct |
13
|
|
|
|
|
|
|
user-calls on this. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
11
|
|
|
11
|
|
94
|
use Cwd; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
757
|
|
18
|
11
|
|
|
11
|
|
124
|
use Test::Smoke::LogMixin; |
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
536
|
|
19
|
11
|
|
|
11
|
|
4585
|
use Test::Smoke::Util::Execute; |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
429
|
|
20
|
11
|
|
|
11
|
|
120
|
use Text::ParseWords; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
4886
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 Test::Smoke::Syncer::Rsync->new( %args ) |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This crates the new object. Keys for C<%args>: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
* ddir: destination directory ( ./perl-current ) |
27
|
|
|
|
|
|
|
* source: the rsync source ( ftp.linux.activestate.com::perl-current ) |
28
|
|
|
|
|
|
|
* opts: the options for rsync ( -az --delete ) |
29
|
|
|
|
|
|
|
* rsync: the full path to the rsync program ( rsync ) |
30
|
|
|
|
|
|
|
* v: verbose |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 $rsync->pre_sync() |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Create the destination directory is it doesn't exist. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub pre_sync { |
39
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
40
|
1
|
50
|
|
|
|
42
|
if (! -d $self->{ddir}) { |
41
|
0
|
|
|
|
|
0
|
require File::Path; |
42
|
0
|
|
|
|
|
0
|
open my $fh, '>', \my $output; |
43
|
0
|
|
|
|
|
0
|
my $stdout = select $fh; |
44
|
0
|
|
|
|
|
0
|
File::Path::mkpath($self->{ddir}, $self->verbose); |
45
|
0
|
|
|
|
|
0
|
select $stdout; |
46
|
0
|
|
|
|
|
0
|
$self->log_info($output); |
47
|
|
|
|
|
|
|
} |
48
|
1
|
|
|
|
|
47
|
$self->SUPER::pre_sync; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 $object->sync( ) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Do the actual sync using a call to the B program. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
B can also be used as a smart version of copy. If you |
56
|
|
|
|
|
|
|
use a local directory to rsync from, make sure the destination path |
57
|
|
|
|
|
|
|
ends with a I! (This does not seem to work for source |
58
|
|
|
|
|
|
|
paths mounted via NFS.) |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub sync { |
63
|
1
|
|
|
1
|
1
|
934
|
my $self = shift; |
64
|
1
|
|
|
|
|
19
|
$self->pre_sync; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $rsync = Test::Smoke::Util::Execute->new( |
67
|
|
|
|
|
|
|
command => $self->{rsync}, |
68
|
1
|
|
|
|
|
26
|
verbose => $self->verbose, |
69
|
|
|
|
|
|
|
); |
70
|
1
|
|
|
|
|
4311
|
my $cwd = cwd(); |
71
|
1
|
50
|
|
|
|
49
|
if (! chdir $self->{ddir}) { |
72
|
0
|
|
|
|
|
0
|
require Carp; |
73
|
0
|
|
|
|
|
0
|
Carp::croak( "[rsync] Cannot chdir($self->{ddir}): $!" ); |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
my $rsyncout = $rsync->run( |
76
|
|
|
|
|
|
|
shellwords($self->{opts}), |
77
|
|
|
|
|
|
|
($self->verbose ? "-v" : ""), |
78
|
|
|
|
|
|
|
$self->{source}, |
79
|
1
|
50
|
|
|
|
43
|
File::Spec->curdir, |
|
|
50
|
|
|
|
|
|
80
|
|
|
|
|
|
|
($self->verbose ? "" : ">" . File::Spec->devnull) |
81
|
|
|
|
|
|
|
); |
82
|
1
|
|
|
|
|
163
|
$self->log_debug($rsyncout); |
83
|
|
|
|
|
|
|
|
84
|
1
|
50
|
|
|
|
25
|
if (my $err = $rsync->exitcode ) { |
85
|
0
|
|
|
|
|
0
|
require Carp; |
86
|
0
|
|
|
|
|
0
|
Carp::carp( "Problem during rsync ($err)" ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
1
|
50
|
|
|
|
54
|
if ($self->is_git_dir()) { |
90
|
0
|
|
|
|
|
0
|
$self->make_dot_patch(); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
31
|
chdir $cwd; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
45
|
my $plevel = $self->check_dot_patch; |
96
|
1
|
|
|
|
|
35
|
$self->post_sync; |
97
|
1
|
|
|
|
|
25
|
return $plevel; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
(c) 2002-2013, All rights reserved. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
* Abe Timmerman |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
109
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
See: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
* , |
114
|
|
|
|
|
|
|
* |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
117
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
118
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |