| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OPM::Maker::Command::filetest; |
|
2
|
|
|
|
|
|
|
$OPM::Maker::Command::filetest::VERSION = '1.16'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: check if filelist in .sopm includes the files on your disk |
|
4
|
|
|
|
|
|
|
|
|
5
|
22
|
|
|
22
|
|
16623
|
use strict; |
|
|
22
|
|
|
|
|
57
|
|
|
|
22
|
|
|
|
|
700
|
|
|
6
|
22
|
|
|
22
|
|
121
|
use warnings; |
|
|
22
|
|
|
|
|
53
|
|
|
|
22
|
|
|
|
|
670
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
22
|
|
|
22
|
|
128
|
use Carp qw(croak); |
|
|
22
|
|
|
|
|
45
|
|
|
|
22
|
|
|
|
|
1077
|
|
|
9
|
22
|
|
|
22
|
|
4915
|
use File::Find::Rule; |
|
|
22
|
|
|
|
|
77469
|
|
|
|
22
|
|
|
|
|
229
|
|
|
10
|
22
|
|
|
22
|
|
5332
|
use Path::Class (); |
|
|
22
|
|
|
|
|
265846
|
|
|
|
22
|
|
|
|
|
1066
|
|
|
11
|
22
|
|
|
22
|
|
10525
|
use Text::Gitignore qw(match_gitignore); |
|
|
22
|
|
|
|
|
22216
|
|
|
|
22
|
|
|
|
|
1483
|
|
|
12
|
22
|
|
|
22
|
|
6275
|
use XML::LibXML; |
|
|
22
|
|
|
|
|
398523
|
|
|
|
22
|
|
|
|
|
185
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
22
|
|
|
22
|
|
6902
|
use OPM::Maker -command; |
|
|
22
|
|
|
|
|
62
|
|
|
|
22
|
|
|
|
|
192
|
|
|
15
|
22
|
|
|
|
|
16132
|
use OPM::Maker::Utils qw( |
|
16
|
|
|
|
|
|
|
reformat_size |
|
17
|
|
|
|
|
|
|
check_args_sopm |
|
18
|
22
|
|
|
22
|
|
105369
|
); |
|
|
22
|
|
|
|
|
62
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub abstract { |
|
21
|
1
|
|
|
1
|
1
|
3386
|
return "Check if filelist in .sopm includes the files on your disk"; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub usage_desc { |
|
25
|
1
|
|
|
1
|
1
|
1495
|
return "opmbuild filetest "; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub validate_args { |
|
29
|
16
|
|
|
16
|
1
|
19302
|
my ($self, $opt, $args) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
16
|
|
|
|
|
69
|
my $sopm = check_args_sopm( $args ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
16
|
100
|
|
|
|
124
|
$self->usage_error( 'need path to .sopm' ) if |
|
34
|
|
|
|
|
|
|
!$sopm; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub execute { |
|
38
|
12
|
|
|
12
|
1
|
12448
|
my ($self, $opt, $args) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
12
|
|
|
|
|
51
|
my $file = check_args_sopm( $args ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
11
|
|
|
|
|
23
|
my %opts; |
|
43
|
11
|
50
|
|
|
|
1294
|
if ( !$ENV{OPM_UNSECURE} ) { |
|
44
|
11
|
|
|
|
|
47
|
%opts = ( |
|
45
|
|
|
|
|
|
|
no_network => 1, |
|
46
|
|
|
|
|
|
|
expand_entities => 0, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
11
|
|
|
|
|
153
|
my $size = -s $file; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# if file is big, but not "too big" |
|
53
|
11
|
|
|
|
|
29
|
my $max_size = 31_457_280; |
|
54
|
11
|
100
|
|
|
|
45
|
if ( $ENV{OPM_MAX_SIZE} ) { |
|
55
|
7
|
|
|
|
|
28
|
$max_size = reformat_size( $ENV{OPM_MAX_SIZE} ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
11
|
100
|
|
|
|
36
|
if ( $size > $max_size ) { |
|
59
|
1
|
|
|
|
|
254
|
croak "$file too big (max size: $max_size bytes)"; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
10
|
50
|
|
|
|
1129
|
if ( $size > 10_000_000 ) { |
|
63
|
0
|
|
|
|
|
0
|
$opts{huge} = 1; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
10
|
|
|
|
|
94
|
my $parser = XML::LibXML->new( %opts ); |
|
67
|
10
|
|
|
|
|
1003
|
my $tree = $parser->parse_file( $file ); |
|
68
|
|
|
|
|
|
|
|
|
69
|
10
|
|
|
|
|
3764
|
my $sopm_path = Path::Class::File->new( $file ); |
|
70
|
10
|
|
|
|
|
1879
|
my $path = $sopm_path->dir; |
|
71
|
|
|
|
|
|
|
|
|
72
|
10
|
|
|
|
|
180
|
my $path_str = $path->stringify; |
|
73
|
10
|
|
|
|
|
502
|
my $hidden_files = File::Find::Rule->file->name(".*"); |
|
74
|
10
|
|
|
|
|
1601
|
my @files_in_fs = File::Find::Rule->file |
|
75
|
|
|
|
|
|
|
->not( $hidden_files ) |
|
76
|
|
|
|
|
|
|
->in ( $path_str ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
31
|
|
|
|
|
205
|
my %fs = map{ $_ =~ s{\A\Q$path_str\E/?}{}; $_ => 1 } |
|
|
31
|
|
|
|
|
106
|
|
|
79
|
10
|
|
|
|
|
15147
|
grep{ $_ !~ /\.git|CVS|svn/ }@files_in_fs; |
|
|
31
|
|
|
|
|
137
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
10
|
|
|
|
|
53
|
delete $fs{ $sopm_path->basename }; |
|
82
|
|
|
|
|
|
|
|
|
83
|
10
|
|
|
|
|
80
|
my $ignore_file = Path::Class::File->new( |
|
84
|
|
|
|
|
|
|
$path->stringify, |
|
85
|
|
|
|
|
|
|
'.opmbuild_filetest_ignore', |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
|
|
88
|
10
|
|
|
|
|
1136
|
my $root_elem = $tree->getDocumentElement; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# retrieve file information |
|
91
|
10
|
|
|
|
|
83
|
my @files = $root_elem->findnodes( 'Filelist/File' ); |
|
92
|
|
|
|
|
|
|
|
|
93
|
10
|
|
|
|
|
663
|
my @not_found; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
FILE: |
|
96
|
10
|
|
|
|
|
27
|
for my $file ( @files ) { |
|
97
|
19
|
|
|
|
|
81
|
my $name = $file->findvalue( '@Location' ); |
|
98
|
|
|
|
|
|
|
|
|
99
|
19
|
100
|
|
|
|
1833
|
push @not_found, $name if !delete $fs{$name}; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
10
|
100
|
|
|
|
36
|
if ( @not_found ) { |
|
103
|
|
|
|
|
|
|
print "Files listed in .sopm but not found on disk:\n", |
|
104
|
1
|
|
|
|
|
2
|
map{ " - $_\n" }@not_found; |
|
|
2
|
|
|
|
|
64
|
|
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
10
|
|
|
|
|
22
|
my @patterns; |
|
108
|
10
|
|
|
|
|
19
|
eval { |
|
109
|
10
|
|
|
|
|
45
|
@patterns = $ignore_file->slurp( |
|
110
|
|
|
|
|
|
|
chomp => 1, |
|
111
|
|
|
|
|
|
|
iomode => '<:encoding(utf-8)', |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
}; |
|
114
|
|
|
|
|
|
|
|
|
115
|
10
|
100
|
|
|
|
9566
|
if ( @patterns ) { |
|
116
|
1
|
|
|
|
|
11
|
my @ignore = match_gitignore( |
|
117
|
|
|
|
|
|
|
[ @patterns ], |
|
118
|
|
|
|
|
|
|
keys %fs, |
|
119
|
|
|
|
|
|
|
); |
|
120
|
|
|
|
|
|
|
|
|
121
|
1
|
50
|
|
|
|
227
|
if ( @ignore ) { |
|
122
|
1
|
|
|
|
|
5
|
delete @fs{@ignore}; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
10
|
100
|
|
|
|
72
|
if ( %fs ) { |
|
127
|
|
|
|
|
|
|
print "Files found on disk but not listed in .sopm:\n", |
|
128
|
1
|
|
|
|
|
4
|
map{ " - $_\n" }sort keys %fs; |
|
|
2
|
|
|
|
|
38
|
|
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |