| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OPM::Maker::Command::filetest; |
|
2
|
|
|
|
|
|
|
$OPM::Maker::Command::filetest::VERSION = '1.17'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: check if filelist in .sopm includes the files on your disk |
|
4
|
|
|
|
|
|
|
|
|
5
|
22
|
|
|
22
|
|
14325
|
use strict; |
|
|
22
|
|
|
|
|
48
|
|
|
|
22
|
|
|
|
|
578
|
|
|
6
|
22
|
|
|
22
|
|
98
|
use warnings; |
|
|
22
|
|
|
|
|
37
|
|
|
|
22
|
|
|
|
|
533
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
22
|
|
|
22
|
|
96
|
use Carp qw(croak); |
|
|
22
|
|
|
|
|
36
|
|
|
|
22
|
|
|
|
|
882
|
|
|
9
|
22
|
|
|
22
|
|
4152
|
use File::Find::Rule; |
|
|
22
|
|
|
|
|
65370
|
|
|
|
22
|
|
|
|
|
234
|
|
|
10
|
22
|
|
|
22
|
|
4607
|
use Path::Class (); |
|
|
22
|
|
|
|
|
222805
|
|
|
|
22
|
|
|
|
|
591
|
|
|
11
|
22
|
|
|
22
|
|
9028
|
use Text::Gitignore qw(match_gitignore); |
|
|
22
|
|
|
|
|
18489
|
|
|
|
22
|
|
|
|
|
1179
|
|
|
12
|
22
|
|
|
22
|
|
5416
|
use XML::LibXML; |
|
|
22
|
|
|
|
|
334119
|
|
|
|
22
|
|
|
|
|
149
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
22
|
|
|
22
|
|
5897
|
use OPM::Maker -command; |
|
|
22
|
|
|
|
|
49
|
|
|
|
22
|
|
|
|
|
156
|
|
|
15
|
22
|
|
|
|
|
12982
|
use OPM::Maker::Utils qw( |
|
16
|
|
|
|
|
|
|
reformat_size |
|
17
|
|
|
|
|
|
|
check_args_sopm |
|
18
|
22
|
|
|
22
|
|
88026
|
); |
|
|
22
|
|
|
|
|
53
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub abstract { |
|
21
|
1
|
|
|
1
|
1
|
2878
|
return "Check if filelist in .sopm includes the files on your disk"; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub usage_desc { |
|
25
|
1
|
|
|
1
|
1
|
1296
|
return "opmbuild filetest "; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub validate_args { |
|
29
|
16
|
|
|
16
|
1
|
14714
|
my ($self, $opt, $args) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
16
|
|
|
|
|
46
|
my $sopm = check_args_sopm( $args ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
16
|
100
|
|
|
|
77
|
$self->usage_error( 'need path to .sopm' ) if |
|
34
|
|
|
|
|
|
|
!$sopm; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub execute { |
|
38
|
12
|
|
|
12
|
1
|
11220
|
my ($self, $opt, $args) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
12
|
|
|
|
|
44
|
my $file = check_args_sopm( $args ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
11
|
|
|
|
|
21
|
my %opts; |
|
43
|
11
|
50
|
|
|
|
1144
|
if ( !$ENV{OPM_UNSECURE} ) { |
|
44
|
11
|
|
|
|
|
37
|
%opts = ( |
|
45
|
|
|
|
|
|
|
no_network => 1, |
|
46
|
|
|
|
|
|
|
expand_entities => 0, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
11
|
|
|
|
|
128
|
my $size = -s $file; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# if file is big, but not "too big" |
|
53
|
11
|
|
|
|
|
25
|
my $max_size = 31_457_280; |
|
54
|
11
|
100
|
|
|
|
32
|
if ( $ENV{OPM_MAX_SIZE} ) { |
|
55
|
7
|
|
|
|
|
24
|
$max_size = reformat_size( $ENV{OPM_MAX_SIZE} ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
11
|
100
|
|
|
|
32
|
if ( $size > $max_size ) { |
|
59
|
1
|
|
|
|
|
219
|
croak "$file too big (max size: $max_size bytes)"; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
10
|
50
|
|
|
|
24
|
if ( $size > 10_000_000 ) { |
|
63
|
0
|
|
|
|
|
0
|
$opts{huge} = 1; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
10
|
|
|
|
|
72
|
my $parser = XML::LibXML->new( %opts ); |
|
67
|
10
|
|
|
|
|
841
|
my $tree = $parser->parse_file( $file ); |
|
68
|
|
|
|
|
|
|
|
|
69
|
10
|
|
|
|
|
3220
|
my $sopm_path = Path::Class::File->new( $file ); |
|
70
|
10
|
|
|
|
|
1292
|
my $path = $sopm_path->dir; |
|
71
|
|
|
|
|
|
|
|
|
72
|
10
|
|
|
|
|
147
|
my $path_str = $path->stringify; |
|
73
|
10
|
|
|
|
|
400
|
my $hidden_files = File::Find::Rule->file->name(".*"); |
|
74
|
10
|
|
|
|
|
2322
|
my @files_in_fs = File::Find::Rule->file |
|
75
|
|
|
|
|
|
|
->not( $hidden_files ) |
|
76
|
|
|
|
|
|
|
->in ( $path_str ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
31
|
|
|
|
|
170
|
my %fs = map{ $_ =~ s{\A\Q$path_str\E/?}{}; $_ => 1 } |
|
|
31
|
|
|
|
|
91
|
|
|
79
|
10
|
|
|
|
|
11752
|
grep{ $_ !~ /\.git|CVS|svn/ }@files_in_fs; |
|
|
31
|
|
|
|
|
109
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
10
|
|
|
|
|
55
|
delete $fs{ $sopm_path->basename }; |
|
82
|
|
|
|
|
|
|
|
|
83
|
10
|
|
|
|
|
64
|
my $ignore_file = Path::Class::File->new( |
|
84
|
|
|
|
|
|
|
$path->stringify, |
|
85
|
|
|
|
|
|
|
'.opmbuild_filetest_ignore', |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
|
|
88
|
10
|
|
|
|
|
947
|
my $root_elem = $tree->getDocumentElement; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# retrieve file information |
|
91
|
10
|
|
|
|
|
69
|
my @files = $root_elem->findnodes( 'Filelist/File' ); |
|
92
|
|
|
|
|
|
|
|
|
93
|
10
|
|
|
|
|
572
|
my @not_found; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
FILE: |
|
96
|
10
|
|
|
|
|
20
|
for my $file ( @files ) { |
|
97
|
19
|
|
|
|
|
65
|
my $name = $file->findvalue( '@Location' ); |
|
98
|
|
|
|
|
|
|
|
|
99
|
19
|
100
|
|
|
|
1549
|
push @not_found, $name if !delete $fs{$name}; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
10
|
100
|
|
|
|
26
|
if ( @not_found ) { |
|
103
|
|
|
|
|
|
|
print "Files listed in .sopm but not found on disk:\n", |
|
104
|
1
|
|
|
|
|
2
|
map{ " - $_\n" }@not_found; |
|
|
2
|
|
|
|
|
58
|
|
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
10
|
|
|
|
|
19
|
my @patterns; |
|
108
|
10
|
|
|
|
|
17
|
eval { |
|
109
|
10
|
|
|
|
|
37
|
@patterns = $ignore_file->slurp( |
|
110
|
|
|
|
|
|
|
chomp => 1, |
|
111
|
|
|
|
|
|
|
iomode => '<:encoding(utf-8)', |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
}; |
|
114
|
|
|
|
|
|
|
|
|
115
|
10
|
100
|
|
|
|
8146
|
if ( @patterns ) { |
|
116
|
1
|
|
|
|
|
6
|
my @ignore = match_gitignore( |
|
117
|
|
|
|
|
|
|
[ @patterns ], |
|
118
|
|
|
|
|
|
|
keys %fs, |
|
119
|
|
|
|
|
|
|
); |
|
120
|
|
|
|
|
|
|
|
|
121
|
1
|
50
|
|
|
|
171
|
if ( @ignore ) { |
|
122
|
1
|
|
|
|
|
3
|
delete @fs{@ignore}; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
10
|
100
|
|
|
|
57
|
if ( %fs ) { |
|
127
|
|
|
|
|
|
|
print "Files found on disk but not listed in .sopm:\n", |
|
128
|
1
|
|
|
|
|
4
|
map{ " - $_\n" }sort keys %fs; |
|
|
2
|
|
|
|
|
37
|
|
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__END__ |