line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::SourceTree; |
2
|
18
|
|
|
18
|
|
141924
|
use strict; |
|
18
|
|
|
|
|
57
|
|
|
18
|
|
|
|
|
777
|
|
3
|
|
|
|
|
|
|
|
4
|
18
|
|
|
18
|
|
133
|
use vars qw( $VERSION @EXPORT_OK %EXPORT_TAGS $NOCASE ); |
|
18
|
|
|
|
|
47
|
|
|
18
|
|
|
|
|
1759
|
|
5
|
|
|
|
|
|
|
$VERSION = '0.008'; |
6
|
|
|
|
|
|
|
|
7
|
18
|
|
|
18
|
|
146
|
use File::Spec; |
|
18
|
|
|
|
|
46
|
|
|
18
|
|
|
|
|
487
|
|
8
|
18
|
|
|
18
|
|
135
|
use File::Find; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
1466
|
|
9
|
18
|
|
|
18
|
|
150
|
use Cwd 'abs_path'; |
|
18
|
|
|
|
|
54
|
|
|
18
|
|
|
|
|
1094
|
|
10
|
18
|
|
|
18
|
|
122
|
use Carp; |
|
18
|
|
|
|
|
49
|
|
|
18
|
|
|
|
|
1652
|
|
11
|
18
|
|
|
18
|
|
618
|
use Test::Smoke::LogMixin; |
|
18
|
|
|
|
|
45
|
|
|
18
|
|
|
|
|
1316
|
|
12
|
|
|
|
|
|
|
|
13
|
18
|
|
|
18
|
|
136
|
use base 'Exporter'; |
|
18
|
|
|
|
|
43
|
|
|
18
|
|
|
|
|
43998
|
|
14
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
15
|
|
|
|
|
|
|
mani_const => [qw( &ST_MISSING &ST_UNDECLARED )], |
16
|
|
|
|
|
|
|
const => [qw( &ST_MISSING &ST_UNDECLARED )], |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
@EXPORT_OK = @{ $EXPORT_TAGS{mani_const} }; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$NOCASE = $^O eq 'MSWin32' || $^O eq 'VMS'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Test::Smoke::SourceTree - Manipulate the perl source-tree |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Test::Smoke::SourceTree qw( :mani_const ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $tree = Test::Smoke::SourceTree->new( $tree_dir ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $mani_check = $tree->check_MANIFEST; |
33
|
|
|
|
|
|
|
foreach my $file ( sort keys %$mani_check ) { |
34
|
|
|
|
|
|
|
if ( $mani_check->{ $file } == ST_MISSING ) { |
35
|
|
|
|
|
|
|
print "MANIFEST declared '$file' but it is missing\n"; |
36
|
|
|
|
|
|
|
} elsif ( $mani_check->{ $file } == ST_UNDECLARED ) { |
37
|
|
|
|
|
|
|
print "MANIFEST did not declare '$file'\n"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$tree->clean_from_MANIFEST; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 CONSTANTS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item ST_MISSING |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item ST_UNDECLARED |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Define some constants |
56
|
|
|
|
|
|
|
sub ST_MISSING() { 1 } |
57
|
|
|
|
|
|
|
sub ST_UNDECLARED() { 0 } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 Test::Smoke::SourceTree->new( $tree_dir[, $verbose] ) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
C creates a new object, this is a simple scalar containing |
64
|
|
|
|
|
|
|
C<< File::Spec->rel2abs( $tree_dir) >>. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub new { |
69
|
34
|
|
|
34
|
1
|
14493
|
my $proto = shift; |
70
|
34
|
100
|
|
|
|
121
|
my $class = ref $proto ? ref $proto : $proto; |
71
|
34
|
|
|
|
|
203
|
my ($dir, $verbose) = @_; |
72
|
|
|
|
|
|
|
|
73
|
34
|
100
|
|
|
|
488
|
croak sprintf "Usage: my \$tree = %s->new( )", __PACKAGE__ |
74
|
|
|
|
|
|
|
unless @_; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# it should be a directory! |
77
|
33
|
|
|
|
|
654
|
my $cwd = abs_path(File::Spec->curdir); |
78
|
33
|
50
|
|
|
|
402
|
chdir $dir or croak "Cannot chdir($dir): $!"; |
79
|
|
|
|
|
|
|
# try not to trip over an absolute-path to something that somehow is a |
80
|
|
|
|
|
|
|
# symlink. abs_path('.') will give you the real-path; that will fail... |
81
|
33
|
100
|
|
|
|
512
|
my $tree_dir = File::Spec->file_name_is_absolute($dir) |
82
|
|
|
|
|
|
|
? $dir |
83
|
|
|
|
|
|
|
: abs_path(File::Spec->curdir); |
84
|
33
|
|
100
|
|
|
349
|
my $self = { |
85
|
|
|
|
|
|
|
tree_dir => $tree_dir, |
86
|
|
|
|
|
|
|
verbose => $verbose || 0, |
87
|
|
|
|
|
|
|
}; |
88
|
33
|
|
|
|
|
296
|
chdir $cwd; |
89
|
|
|
|
|
|
|
|
90
|
33
|
|
|
|
|
271
|
return bless $self, $class; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 $tree->tree_dir |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Get the directory. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
281
|
|
|
281
|
1
|
5668
|
sub tree_dir { return $_[0]->{tree_dir} } |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 $tree->verbose |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Get verbosity. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
372
|
|
|
372
|
1
|
6076
|
sub verbose { return $_[0]->{verbose} } |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 $tree->canonpath( ) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
C returns the canonical name for the path, |
112
|
|
|
|
|
|
|
see L. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub canonpath { |
117
|
5
|
|
|
5
|
1
|
13564
|
my $self = shift; |
118
|
5
|
|
|
|
|
23
|
return File::Spec->canonpath( $self->tree_dir ); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 $tree->rel2abs( [$base_dir] ) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
C returns the absolute path, see L. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub rel2abs { |
128
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
129
|
1
|
|
|
|
|
13
|
return File::Spec->rel2abs( $self->tree_dir, @_ ); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 $tree->abs2rel( [$base_dir] ) |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
C returns a relative path, |
135
|
|
|
|
|
|
|
see L. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub abs2rel { |
140
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
141
|
1
|
|
|
|
|
3
|
return File::Spec->abs2rel( $self->tree_dir, @_ ); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 $tree->mani2abs( $file[, $base_path] ) |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
C returns the absolute filename of C<$file>, which should |
147
|
|
|
|
|
|
|
be in "MANIFEST" format (i.e. using '/' as directory separator). |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub mani2abs { |
152
|
200
|
|
|
200
|
1
|
307
|
my $self = shift; |
153
|
|
|
|
|
|
|
|
154
|
200
|
|
|
|
|
335
|
my $path = shift; |
155
|
200
|
|
|
|
|
1040
|
my @dirs = split m{/+}, $path; |
156
|
200
|
|
|
|
|
483
|
my $file = pop @dirs; |
157
|
200
|
50
|
|
|
|
702
|
if ( $^O eq 'VMS' ) { |
158
|
0
|
|
|
|
|
0
|
my @parts = split m/\./, $file; |
159
|
0
|
|
|
|
|
0
|
my $last = pop @parts; |
160
|
|
|
|
|
|
|
@parts and |
161
|
0
|
0
|
|
|
|
0
|
$file = join( "_", map { s/[^\w-]/_/g; $_ } @parts ) . ".$last"; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
162
|
|
|
|
|
|
|
} |
163
|
200
|
100
|
|
|
|
487
|
@dirs and $file = join '/', @dirs, $file; |
164
|
200
|
|
|
|
|
446
|
my @split_path = split m|/|, $file; |
165
|
200
|
|
|
|
|
444
|
my $base_path = File::Spec->rel2abs( $self->tree_dir, @_ ); |
166
|
200
|
|
|
|
|
1818
|
return File::Spec->catfile( $base_path, @split_path ); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 $tree->mani2absdir( $dir[, $base_path] ) |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
C returns the absolute dirname of C<$dir>, which should |
172
|
|
|
|
|
|
|
be in "MANIFEST" format (i.e. using '/' as directory separator). |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub mani2absdir { |
177
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
0
|
my @split_path = split m|/|, shift; |
180
|
0
|
|
|
|
|
0
|
my $base_path = File::Spec->rel2abs( $self->tree_dir, @_ ); |
181
|
0
|
|
|
|
|
0
|
return File::Spec->catdir( $base_path, @split_path ); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 $tree->abs2mani( $file ) |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
C returns the MANIFEST style filename. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub abs2mani { |
191
|
62
|
|
|
62
|
1
|
125
|
my $self = shift; |
192
|
62
|
|
|
|
|
141
|
my ($source_file) = @_; |
193
|
|
|
|
|
|
|
|
194
|
62
|
|
|
|
|
380
|
my $relfile = File::Spec->abs2rel( |
195
|
|
|
|
|
|
|
File::Spec->canonpath( $source_file ), $self->tree_dir |
196
|
|
|
|
|
|
|
); |
197
|
62
|
|
|
|
|
435
|
$self->log_debug("[abs2mani($source_file)] $relfile"); |
198
|
|
|
|
|
|
|
|
199
|
62
|
|
|
|
|
723
|
my( undef, $directories, $file ) = File::Spec->splitpath( $relfile ); |
200
|
62
|
|
66
|
|
|
369
|
my @dirs = grep $_ && length $_ => File::Spec->splitdir( $directories ); |
201
|
62
|
|
|
|
|
143
|
push @dirs, $file; |
202
|
62
|
|
|
|
|
239
|
return join '/', @dirs; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 $tree->check_MANIFEST( @ignore ) |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
C reads the B file from C<< $self->tree_dir >> and |
208
|
|
|
|
|
|
|
compares it with the actual contents of C<< $self->tree_dir >>. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Returns a hashref with suspicious entries (if any) as keys that have a |
211
|
|
|
|
|
|
|
value of either B (not in directory) or B |
212
|
|
|
|
|
|
|
(not in MANIFEST). |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub check_MANIFEST { |
217
|
12
|
|
|
12
|
1
|
1120
|
my $self = shift; |
218
|
|
|
|
|
|
|
|
219
|
12
|
|
|
|
|
32
|
my %manifest = %{ $self->_read_mani_file( 'MANIFEST' ) }; |
|
12
|
|
|
|
|
86
|
|
220
|
12
|
|
|
|
|
206
|
$self->log_debug("Found %d entries in MANIFEST", scalar(keys %manifest)); |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
my %ignore = map { |
223
|
70
|
50
|
|
|
|
209
|
my $entry = $NOCASE ? uc $_ : $_; |
224
|
70
|
|
|
|
|
217
|
$entry => undef |
225
|
|
|
|
|
|
|
} ( ".patch", "MANIFEST.SKIP", '.git', '.gitignore', '.mailmap', @_ ), |
226
|
12
|
|
|
|
|
41
|
keys %{ $self->_read_mani_file( 'MANIFEST.SKIP', 1 ) }; |
|
12
|
|
|
|
|
41
|
|
227
|
12
|
|
|
|
|
88
|
$self->log_debug("Found %d entries in MANIFEST.SKIP", scalar(keys %ignore)); |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
# Walk the tree, remove all found files from %manifest |
230
|
|
|
|
|
|
|
# and add other files to %manifest |
231
|
|
|
|
|
|
|
# unless they are in the ignore list |
232
|
12
|
|
|
|
|
196
|
my $cwd = abs_path(File::Spec->curdir); |
233
|
12
|
50
|
|
|
|
53
|
chdir $self->tree_dir or die "Cannot chdir($self->tree_dir): $!"; |
234
|
12
|
|
|
|
|
136
|
require File::Find; |
235
|
|
|
|
|
|
|
File::Find::find( |
236
|
|
|
|
|
|
|
sub { |
237
|
262
|
100
|
|
262
|
|
10437
|
-f or return; |
238
|
164
|
|
|
|
|
944
|
my $cpath = File::Spec->canonpath($File::Find::name); |
239
|
164
|
|
|
|
|
2098
|
my (undef, $dirs, $file) = File::Spec->splitpath($cpath); |
240
|
164
|
|
66
|
|
|
1201
|
my @dirs = grep $_ && length $_ => File::Spec->splitdir($dirs); |
241
|
164
|
50
|
|
|
|
497
|
$^O eq 'VMS' and $file =~ s/\.$//; |
242
|
164
|
|
|
|
|
405
|
my $mani_name = join '/', @dirs, $file; |
243
|
164
|
50
|
|
|
|
331
|
$NOCASE and $mani_name = uc $mani_name; |
244
|
164
|
100
|
|
|
|
381
|
if (exists $manifest{$mani_name}) { |
245
|
154
|
|
|
|
|
666
|
$self->log_debug("[manicheck] Matched $mani_name"); |
246
|
154
|
|
|
|
|
3062
|
delete $manifest{$mani_name}; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
else { |
249
|
10
|
100
|
|
|
|
1837
|
if (!grep $mani_name =~ /$_/, keys %ignore) { |
250
|
2
|
|
|
|
|
24
|
$self->log_debug("[manicheck] Undeclared $mani_name"); |
251
|
2
|
|
|
|
|
26
|
$manifest{$mani_name} = ST_UNDECLARED; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
else { |
254
|
8
|
|
|
|
|
69
|
$self->log_debug("[manicheck] Skipped $mani_name"); |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
}, |
258
|
12
|
|
|
|
|
1501
|
'.' |
259
|
|
|
|
|
|
|
); |
260
|
12
|
|
|
|
|
277
|
chdir $cwd; |
261
|
12
|
|
|
|
|
92
|
$self->log_debug("[manicheck] %d entries missing", scalar(keys %manifest)); |
262
|
|
|
|
|
|
|
|
263
|
12
|
|
|
|
|
104
|
return \%manifest; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head2 $self->_read_mani_file( $path[, $no_croak] ) |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
C<_read_mani_file()> reads the contents of C<$path> like it is a |
269
|
|
|
|
|
|
|
MANIFEST typeof file and returns a ref to hash with all values set |
270
|
|
|
|
|
|
|
C. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=cut |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub _read_mani_file { |
275
|
25
|
|
|
25
|
|
609
|
my $self = shift; |
276
|
25
|
|
|
|
|
106
|
my( $path, $no_croak ) = @_; |
277
|
|
|
|
|
|
|
|
278
|
25
|
|
|
|
|
77
|
my $manifile = $self->mani2abs( $path ); |
279
|
25
|
|
|
|
|
112
|
local *MANIFEST; |
280
|
25
|
100
|
|
|
|
902
|
open MANIFEST, "< $manifile" or do { |
281
|
12
|
50
|
|
|
|
160
|
$no_croak and return { }; |
282
|
0
|
|
|
|
|
0
|
croak( "Can't open '$manifile': $!" ); |
283
|
|
|
|
|
|
|
}; |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
my %manifest = map { |
286
|
13
|
|
|
|
|
482
|
m|(\S+)|; |
|
157
|
|
|
|
|
445
|
|
287
|
157
|
50
|
|
|
|
405
|
my $entry = $NOCASE ? uc $1 : $1; |
288
|
157
|
50
|
|
|
|
350
|
if ( $^O eq 'VMS' ) { |
289
|
0
|
|
|
|
|
0
|
my @dirs = split m|/|, $entry; |
290
|
0
|
|
|
|
|
0
|
my $file = pop @dirs; |
291
|
0
|
|
|
|
|
0
|
my @parts = split /[.@#]/, $file; |
292
|
0
|
0
|
|
|
|
0
|
if ( @parts > 1 ) { |
293
|
0
|
|
0
|
|
|
0
|
my $ext = ( pop @parts ) || ''; |
294
|
0
|
|
|
|
|
0
|
$file = join( "_", @parts ) . ".$ext"; |
295
|
|
|
|
|
|
|
} |
296
|
0
|
0
|
|
|
|
0
|
$entry = @dirs ? join( "/", @dirs, $file ) : $file; |
297
|
|
|
|
|
|
|
} |
298
|
157
|
|
|
|
|
498
|
( $entry => ST_MISSING ); |
299
|
|
|
|
|
|
|
} ; |
300
|
13
|
|
|
|
|
180
|
close MANIFEST; |
301
|
|
|
|
|
|
|
|
302
|
13
|
|
|
|
|
193
|
return \%manifest; |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head2 $tree->clean_from_MANIFEST( ) |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
C removes all files from the source-tree that are |
308
|
|
|
|
|
|
|
not declared in the B file. |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=cut |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub clean_from_MANIFEST { |
313
|
4
|
|
|
4
|
1
|
10
|
my $self = shift; |
314
|
|
|
|
|
|
|
|
315
|
4
|
|
|
|
|
16
|
my $mani_check = $self->check_MANIFEST( @_ ); |
316
|
|
|
|
|
|
|
my @to_remove = grep { |
317
|
4
|
|
|
|
|
18
|
$mani_check->{ $_ } == ST_UNDECLARED |
|
0
|
|
|
|
|
0
|
|
318
|
|
|
|
|
|
|
} keys %$mani_check; |
319
|
|
|
|
|
|
|
|
320
|
4
|
|
|
|
|
18
|
foreach my $entry ( @to_remove ) { |
321
|
0
|
|
|
|
|
0
|
my $file = $self->mani2abs( $entry ); |
322
|
0
|
|
|
|
|
0
|
1 while unlink $file; |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=head2 copy_from_MANIFEST( $dest_dir ) |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
C<_copy_from_MANIFEST()> uses the B file from C<$self->tree_dir> |
329
|
|
|
|
|
|
|
to copy a source-tree to C<< $dest_dir >>. |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=cut |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub copy_from_MANIFEST { |
334
|
4
|
|
|
4
|
1
|
16
|
my ($self, $dest_dir) = @_; |
335
|
|
|
|
|
|
|
|
336
|
4
|
|
|
|
|
18
|
my $manifest = $self->mani2abs( 'MANIFEST' ); |
337
|
|
|
|
|
|
|
|
338
|
4
|
|
|
|
|
26
|
local *MANIFEST; |
339
|
4
|
50
|
|
|
|
232
|
open MANIFEST, "< $manifest" or do { |
340
|
0
|
|
|
|
|
0
|
carp "Can't open '$manifest': $!\n"; |
341
|
0
|
|
|
|
|
0
|
return undef; |
342
|
|
|
|
|
|
|
}; |
343
|
|
|
|
|
|
|
|
344
|
4
|
|
|
|
|
62
|
$self->log_info("Reading from '%s'", $manifest); |
345
|
|
|
|
|
|
|
my @manifest_files = map { |
346
|
4
|
50
|
|
|
|
206
|
/^([^\s]+)/ ? $1 : $_ |
|
82
|
|
|
|
|
286
|
|
347
|
|
|
|
|
|
|
} ; |
348
|
4
|
|
|
|
|
58
|
close MANIFEST; |
349
|
4
|
|
|
|
|
30
|
my $dot_patch = $self->mani2abs( '.patch' ); |
350
|
4
|
100
|
|
|
|
174
|
-f $dot_patch and push @manifest_files, '.patch'; |
351
|
|
|
|
|
|
|
|
352
|
4
|
|
|
|
|
36
|
$self->log_info("%s: %d items OK", $manifest, scalar @manifest_files); |
353
|
|
|
|
|
|
|
|
354
|
4
|
100
|
|
|
|
115
|
File::Path::mkpath( $dest_dir, $self->verbose ) unless -d $dest_dir; |
355
|
4
|
|
|
|
|
23
|
my $dest = $self->new( $dest_dir ); |
356
|
|
|
|
|
|
|
|
357
|
4
|
|
|
|
|
32
|
require File::Basename; |
358
|
4
|
|
|
|
|
1720
|
require File::Copy; |
359
|
4
|
|
|
|
|
7773
|
foreach my $file ( @manifest_files ) { |
360
|
83
|
50
|
|
|
|
175
|
$file or next; |
361
|
|
|
|
|
|
|
|
362
|
83
|
|
|
|
|
167
|
my $dest_name = $dest->mani2abs( $file ); |
363
|
83
|
|
|
|
|
2333
|
my $dest_path = File::Basename::dirname( $dest_name ); |
364
|
|
|
|
|
|
|
|
365
|
83
|
100
|
|
|
|
1439
|
File::Path::mkpath( $dest_path, $self->verbose ) unless -d $dest_path; |
366
|
|
|
|
|
|
|
|
367
|
83
|
|
|
|
|
329
|
my $abs_file = $self->mani2abs( $file ); |
368
|
83
|
|
|
|
|
1547
|
my $mode = ( stat $abs_file )[2] & 07777; |
369
|
83
|
|
33
|
|
|
1827
|
-f $dest_name and 1 while unlink $dest_name; |
370
|
83
|
|
|
|
|
329
|
my $ok = File::Copy::syscopy( $abs_file, $dest_name ); |
371
|
83
|
50
|
33
|
|
|
25769
|
$ok and $ok &&= chmod $mode, $dest_name; |
372
|
83
|
50
|
|
|
|
198
|
if ($ok) { |
373
|
83
|
50
|
|
|
|
376
|
$self->log_debug("%s -> %s: %sOK", $abs_file, $dest_name, ($ok ? "" : "NOT ")); |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
else { |
376
|
0
|
|
|
|
|
|
$self->log_warn("copy '$file' ($dest_path): $!"); |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
1; |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=head1 COPYRIGHT |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
(c) 2002-2015, All rights reserved. |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
* Abe Timmerman |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
390
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
See: |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=over 4 |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=item * L |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
=item * L |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
=back |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
403
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
404
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
=cut |