line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OTRS::OPM::Maker::Command::filetest; |
2
|
|
|
|
|
|
|
$OTRS::OPM::Maker::Command::filetest::VERSION = '0.19'; |
3
|
|
|
|
|
|
|
# ABSTRACT: check if filelist in .sopm includes the files on your disk |
4
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
9985
|
use strict; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
414
|
|
6
|
14
|
|
|
14
|
|
76
|
use warnings; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
364
|
|
7
|
|
|
|
|
|
|
|
8
|
14
|
|
|
14
|
|
6368
|
use File::Find::Rule; |
|
14
|
|
|
|
|
97795
|
|
|
14
|
|
|
|
|
128
|
|
9
|
14
|
|
|
14
|
|
2413
|
use Path::Class (); |
|
14
|
|
|
|
|
108941
|
|
|
14
|
|
|
|
|
311
|
|
10
|
14
|
|
|
14
|
|
2532
|
use XML::LibXML; |
|
14
|
|
|
|
|
168301
|
|
|
14
|
|
|
|
|
103
|
|
11
|
|
|
|
|
|
|
|
12
|
14
|
|
|
14
|
|
3530
|
use OTRS::OPM::Maker -command; |
|
14
|
|
|
|
|
36
|
|
|
14
|
|
|
|
|
122
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub abstract { |
15
|
1
|
|
|
1
|
1
|
3307
|
return "Check if filelist in .sopm includes the files on your disk"; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub usage_desc { |
19
|
1
|
|
|
1
|
1
|
895
|
return "opmbuild filetest "; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub validate_args { |
23
|
8
|
|
|
8
|
1
|
6799
|
my ($self, $opt, $args) = @_; |
24
|
|
|
|
|
|
|
|
25
|
8
|
100
|
100
|
|
|
111
|
$self->usage_error( 'need path to .sopm' ) if |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
26
|
|
|
|
|
|
|
!$args or |
27
|
|
|
|
|
|
|
'ARRAY' ne ref $args or |
28
|
|
|
|
|
|
|
!defined $args->[0] or |
29
|
|
|
|
|
|
|
$args->[0] !~ /\.sopm\z/ or |
30
|
|
|
|
|
|
|
!-f $args->[0]; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub execute { |
34
|
2
|
|
|
2
|
1
|
2219
|
my ($self, $opt, $args) = @_; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
17
|
my $file = $args->[0]; |
37
|
2
|
|
|
|
|
27
|
my $parser = XML::LibXML->new; |
38
|
2
|
|
|
|
|
48
|
my $tree = $parser->parse_file( $file ); |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
766
|
my $sopm_path = Path::Class::File->new( $file ); |
41
|
2
|
|
|
|
|
391
|
my $path = $sopm_path->dir; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
39
|
my $path_str = $path->stringify; |
44
|
2
|
|
|
|
|
96
|
my $ignore_files = File::Find::Rule->file->name(".*"); |
45
|
2
|
|
|
|
|
317
|
my @files_in_fs = File::Find::Rule->file |
46
|
|
|
|
|
|
|
->not( $ignore_files ) |
47
|
|
|
|
|
|
|
->in ( $path_str ); |
48
|
|
|
|
|
|
|
|
49
|
6
|
|
|
|
|
45
|
my %fs = map{ $_ =~ s{\A\Q$path_str\E/?}{}; $_ => 1 } |
|
6
|
|
|
|
|
20
|
|
50
|
2
|
|
|
|
|
2061
|
grep{ $_ !~ /\.git|CVS|svn/ }@files_in_fs; |
|
6
|
|
|
|
|
22
|
|
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
11
|
delete $fs{ $sopm_path->basename }; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
28
|
my $root_elem = $tree->getDocumentElement; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# retrieve file information |
57
|
2
|
|
|
|
|
21
|
my @files = $root_elem->findnodes( 'Filelist/File' ); |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
151
|
my @not_found; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
FILE: |
62
|
2
|
|
|
|
|
5
|
for my $file ( @files ) { |
63
|
4
|
|
|
|
|
19
|
my $name = $file->findvalue( '@Location' ); |
64
|
|
|
|
|
|
|
|
65
|
4
|
100
|
|
|
|
393
|
push @not_found, $name if !delete $fs{$name}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
2
|
100
|
|
|
|
8
|
if ( @not_found ) { |
69
|
|
|
|
|
|
|
print "Files listed in .sopm but not found on disk:\n", |
70
|
1
|
|
|
|
|
2
|
map{ " - $_\n" }@not_found; |
|
2
|
|
|
|
|
49
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
2
|
100
|
|
|
|
14
|
if ( %fs ) { |
74
|
|
|
|
|
|
|
print "Files found on disk but not listed in .sopm:\n", |
75
|
1
|
|
|
|
|
5
|
map{ " - $_\n" }sort keys %fs; |
|
2
|
|
|
|
|
24
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |