| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OTRS::OPM::Maker::Command::index; |
|
2
|
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
10225
|
use strict; |
|
|
14
|
|
|
|
|
33
|
|
|
|
14
|
|
|
|
|
440
|
|
|
4
|
14
|
|
|
14
|
|
80
|
use warnings; |
|
|
14
|
|
|
|
|
31
|
|
|
|
14
|
|
|
|
|
422
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Build index for an OPM repository |
|
7
|
|
|
|
|
|
|
|
|
8
|
14
|
|
|
14
|
|
90
|
use File::Basename; |
|
|
14
|
|
|
|
|
30
|
|
|
|
14
|
|
|
|
|
965
|
|
|
9
|
14
|
|
|
14
|
|
2227
|
use File::Find::Rule; |
|
|
14
|
|
|
|
|
34101
|
|
|
|
14
|
|
|
|
|
101
|
|
|
10
|
14
|
|
|
14
|
|
2781
|
use MIME::Base64 (); |
|
|
14
|
|
|
|
|
2623
|
|
|
|
14
|
|
|
|
|
341
|
|
|
11
|
14
|
|
|
14
|
|
1956
|
use Sys::Hostname; |
|
|
14
|
|
|
|
|
4193
|
|
|
|
14
|
|
|
|
|
781
|
|
|
12
|
14
|
|
|
14
|
|
1958
|
use Path::Class (); |
|
|
14
|
|
|
|
|
133596
|
|
|
|
14
|
|
|
|
|
423
|
|
|
13
|
14
|
|
|
14
|
|
2875
|
use XML::LibXML; |
|
|
14
|
|
|
|
|
204545
|
|
|
|
14
|
|
|
|
|
101
|
|
|
14
|
14
|
|
|
14
|
|
10455
|
use XML::LibXML::PrettyPrint; |
|
|
14
|
|
|
|
|
113194
|
|
|
|
14
|
|
|
|
|
182
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
14
|
|
|
14
|
|
3255
|
use OTRS::OPM::Maker -command; |
|
|
14
|
|
|
|
|
34
|
|
|
|
14
|
|
|
|
|
122
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub abstract { |
|
21
|
1
|
|
|
1
|
1
|
3663
|
return "build index for an OPM repository"; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub usage_desc { |
|
25
|
1
|
|
|
1
|
1
|
897
|
return "opmbuild index "; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub validate_args { |
|
29
|
7
|
|
|
7
|
1
|
8226
|
my ($self, $opt, $args) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
7
|
100
|
100
|
|
|
111
|
$self->usage_error( 'need path to directory that contains opm files' ) if |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
|
|
|
|
|
|
!$args || |
|
33
|
|
|
|
|
|
|
'ARRAY' ne ref $args || |
|
34
|
|
|
|
|
|
|
!$args->[0] || |
|
35
|
|
|
|
|
|
|
!-d $args->[0]; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub execute { |
|
39
|
2
|
|
|
2
|
1
|
2789
|
my ($self, $opt, $args) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
5
|
my $dir = $args->[0]; |
|
42
|
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
1417
|
my @opm_files = File::Find::Rule->file->name( '*.opm' )->in( $dir ); |
|
44
|
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
2081
|
my @packages; |
|
46
|
2
|
|
|
|
|
37
|
my $pp = XML::LibXML::PrettyPrint->new( |
|
47
|
|
|
|
|
|
|
indent_string => ' ', |
|
48
|
|
|
|
|
|
|
element => { |
|
49
|
|
|
|
|
|
|
compact => [qw( |
|
50
|
|
|
|
|
|
|
Vendor Name Description Version Framework |
|
51
|
|
|
|
|
|
|
ModuleRequired PackageRequired URL License |
|
52
|
|
|
|
|
|
|
File |
|
53
|
|
|
|
|
|
|
)], |
|
54
|
|
|
|
|
|
|
}, |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
100
|
for my $file ( sort @opm_files ) { |
|
58
|
2
|
|
|
|
|
61
|
my $parser = XML::LibXML->new; |
|
59
|
2
|
|
|
|
|
44
|
my $tree = $parser->parse_file( $file ); |
|
60
|
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
1129
|
$tree->setStandalone( 0 ); |
|
62
|
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
10
|
my $root_elem = $tree->getDocumentElement; |
|
64
|
2
|
|
|
|
|
17
|
$root_elem->setNodeName( 'Package' ); |
|
65
|
2
|
|
|
|
|
12
|
$root_elem->removeAttribute( 'version' ); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# retrieve file information |
|
68
|
2
|
|
|
|
|
9
|
my @files = $root_elem->findnodes( 'Filelist/File' ); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
FILE: |
|
71
|
2
|
|
|
|
|
106
|
for my $file ( @files ) { |
|
72
|
4
|
|
|
|
|
51
|
my $location = $file->findvalue( '@Location' ); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# keep only documentation in file list |
|
75
|
4
|
100
|
|
|
|
468
|
if ( $location !~ m{\A doc/}x ) { |
|
76
|
3
|
|
|
|
|
37
|
$file->parentNode->removeChild( $file ); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
1
|
|
|
|
|
21
|
my @child_nodes = $file->childNodes; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# clean nodes |
|
82
|
1
|
|
|
|
|
34
|
$file->removeChild( $_ ) for @child_nodes; |
|
83
|
1
|
|
|
|
|
6
|
$file->removeAttribute( 'Encode' ); |
|
84
|
1
|
|
|
|
|
6
|
$file->setNodeName( 'FileDoc' ); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# remove unnecessary nodes |
|
89
|
2
|
|
|
|
|
101
|
for my $node_name ( qw(Code Intro Database)) { |
|
90
|
6
|
|
|
|
|
10
|
for my $phase ( qw(Install Upgrade Reinstall Uninstall) ) { |
|
91
|
24
|
|
|
|
|
96
|
my @nodes = $root_elem->findnodes( $node_name . $phase ); |
|
92
|
24
|
|
|
|
|
569
|
$_->parentNode->removeChild( $_ ) for @nodes; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
2
|
|
|
|
|
4
|
for my $node_name ( qw(BuildHost BuildDate)) { |
|
97
|
4
|
|
|
|
|
60
|
my @nodes = $root_elem->findnodes( $node_name ); |
|
98
|
4
|
|
|
|
|
107
|
$_->parentNode->removeChild( $_ ) for @nodes; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
59
|
my $file_node = XML::LibXML::Element->new( 'File' ); |
|
102
|
2
|
|
|
|
|
36
|
(my $file_path = $file) =~ s/\Q$dir//; |
|
103
|
2
|
|
|
|
|
12
|
$file_node->appendText( $file_path ); |
|
104
|
2
|
|
|
|
|
13
|
$root_elem->addChild( $file_node ); |
|
105
|
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
5
|
$pp->pretty_print( $tree ); |
|
107
|
|
|
|
|
|
|
|
|
108
|
2
|
|
|
|
|
13018
|
my $xml = $tree->toString; |
|
109
|
2
|
|
|
|
|
95
|
$xml =~ s{<\?xml .*? \?> \s+}{}x; |
|
110
|
|
|
|
|
|
|
|
|
111
|
2
|
|
|
|
|
10
|
push @packages, $xml; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
621
|
print sprintf qq~ |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
%s |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
~, join "", @packages; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |