line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::Syncer::Rsync; |
2
|
11
|
|
|
11
|
|
91
|
use warnings; |
|
11
|
|
|
|
|
38
|
|
|
11
|
|
|
|
|
419
|
|
3
|
11
|
|
|
11
|
|
90
|
use strict; |
|
11
|
|
|
|
|
43
|
|
|
11
|
|
|
|
|
484
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.029'; |
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
81
|
use base 'Test::Smoke::Syncer::Base'; |
|
11
|
|
|
|
|
37
|
|
|
11
|
|
|
|
|
6229
|
|
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
|
|
86
|
use Cwd; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
695
|
|
18
|
11
|
|
|
11
|
|
98
|
use Test::Smoke::LogMixin; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
526
|
|
19
|
11
|
|
|
11
|
|
4447
|
use Test::Smoke::Util::Execute; |
|
11
|
|
|
|
|
33
|
|
|
11
|
|
|
|
|
415
|
|
20
|
11
|
|
|
11
|
|
122
|
use Text::ParseWords; |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
4822
|
|
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
|
8
|
my $self = shift; |
40
|
1
|
50
|
|
|
|
54
|
if (! -d $self->{ddir}) { |
41
|
1
|
|
|
|
|
35
|
require File::Path; |
42
|
1
|
|
|
1
|
|
140
|
open my $fh, '>', \my $output; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
21
|
|
43
|
1
|
|
|
|
|
1738
|
my $stdout = select $fh; |
44
|
1
|
|
|
|
|
62
|
File::Path::mkpath($self->{ddir}, $self->verbose); |
45
|
1
|
|
|
|
|
16
|
select $stdout; |
46
|
1
|
|
|
|
|
15
|
$self->log_info($output); |
47
|
|
|
|
|
|
|
} |
48
|
1
|
|
|
|
|
24
|
$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
|
914
|
my $self = shift; |
64
|
1
|
|
|
|
|
16
|
$self->pre_sync; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $rsync = Test::Smoke::Util::Execute->new( |
67
|
|
|
|
|
|
|
command => $self->{rsync}, |
68
|
1
|
|
|
|
|
9
|
verbose => $self->verbose, |
69
|
|
|
|
|
|
|
); |
70
|
1
|
|
|
|
|
3272
|
my $cwd = cwd(); |
71
|
1
|
50
|
|
|
|
59
|
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
|
|
|
|
41
|
File::Spec->curdir, |
|
|
50
|
|
|
|
|
|
80
|
|
|
|
|
|
|
($self->verbose ? "" : ">" . File::Spec->devnull) |
81
|
|
|
|
|
|
|
); |
82
|
1
|
|
|
|
|
118
|
$self->log_debug($rsyncout); |
83
|
|
|
|
|
|
|
|
84
|
1
|
50
|
|
|
|
35
|
if (my $err = $rsync->exitcode ) { |
85
|
0
|
|
|
|
|
0
|
require Carp; |
86
|
0
|
|
|
|
|
0
|
Carp::carp( "Problem during rsync ($err)" ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
1
|
50
|
|
|
|
104
|
if ($self->is_git_dir()) { |
90
|
0
|
|
|
|
|
0
|
$self->make_dot_patch(); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
41
|
chdir $cwd; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
62
|
my $plevel = $self->check_dot_patch; |
96
|
1
|
|
|
|
|
52
|
$self->post_sync; |
97
|
1
|
|
|
|
|
51
|
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 |