line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::Syncer::Hardlink; |
2
|
11
|
|
|
11
|
|
65
|
use warnings; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
296
|
|
3
|
11
|
|
|
11
|
|
48
|
use strict; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
321
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.029'; |
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
54
|
use base 'Test::Smoke::Syncer::Base'; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
4117
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 Test::Smoke::Syncer::Hardlink |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This handles syncing by copying the source-tree from a local directory |
12
|
|
|
|
|
|
|
using the B function. This can be used as an alternative for |
13
|
|
|
|
|
|
|
B. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Thanks to Nicholas Clark for donating this suggestion! |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require File::Find; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 Test::Smoke::Syncer::Hardlink->new( %args ) |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Keys for C<%args>: |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
* ddir: destination directory |
26
|
|
|
|
|
|
|
* hdir: source directory |
27
|
|
|
|
|
|
|
* v: verbose |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 $syncer->sync( ) |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
C uses the B module to make the hardlink forest in {ddir}. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub sync { |
38
|
5
|
|
|
5
|
1
|
6584
|
my $self = shift; |
39
|
|
|
|
|
|
|
|
40
|
5
|
|
|
|
|
73
|
$self->pre_sync; |
41
|
5
|
100
|
|
|
|
748
|
require File::Copy unless $self->{haslink}; |
42
|
|
|
|
|
|
|
|
43
|
5
|
100
|
|
|
|
3143
|
-d $self->{ddir} or File::Path::mkpath( $self->{ddir} ); |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
38
|
my $source_dir = File::Spec->canonpath( $self->{hdir} ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
File::Find::find( sub { |
48
|
40
|
|
|
40
|
|
2007
|
my $dest = File::Spec->abs2rel( $File::Find::name, $source_dir ); |
49
|
|
|
|
|
|
|
# nasty thing in older File::Spec::Win32::abs2rel() |
50
|
40
|
50
|
|
|
|
144
|
$^O eq 'MSWin32' and $dest =~ s|^[a-z]:(?![/\\])||i; |
51
|
40
|
|
|
|
|
226
|
$dest = File::Spec->catfile( $self->{ddir}, $dest ); |
52
|
40
|
100
|
|
|
|
492
|
if ( -d ) { |
53
|
10
|
|
|
|
|
918
|
mkdir $dest, (stat _)[2] & 07777; |
54
|
|
|
|
|
|
|
} else { |
55
|
30
|
|
33
|
|
|
590
|
-e $dest and 1 while unlink $dest; |
56
|
30
|
50
|
|
|
|
88
|
$self->{v} > 1 and print "link $_ $dest"; |
57
|
|
|
|
|
|
|
my $ok = $self->{haslink} |
58
|
30
|
100
|
|
|
|
439
|
? link $_, $dest |
59
|
|
|
|
|
|
|
: File::Copy::copy( $_, $dest ); |
60
|
30
|
50
|
|
|
|
1997
|
if ( $self->{v} > 1 ) { |
61
|
0
|
0
|
|
|
|
0
|
print $ok ? " OK\n" : " $!\n"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
5
|
|
|
|
|
451
|
}, $source_dir ); |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
|
|
97
|
$self->clean_from_directory( $source_dir ); |
67
|
|
|
|
|
|
|
|
68
|
5
|
|
|
|
|
73
|
$self->post_sync; |
69
|
5
|
|
|
|
|
42
|
return $self->check_dot_patch(); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 COPYRIGHT |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
(c) 2002-2013, All rights reserved. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
* Abe Timmerman |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
81
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
See: |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
* , |
86
|
|
|
|
|
|
|
* |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
89
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
90
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |