line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PPM::Make::RepositorySummary; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
15547
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
5
|
2
|
|
|
2
|
|
393
|
use PPM::Make::Util qw(parse_ppd ppd2cpan_version); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use File::Copy; |
7
|
|
|
|
|
|
|
use XML::Writer; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.9903'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
my $class = shift; |
13
|
|
|
|
|
|
|
my %args = @_; |
14
|
|
|
|
|
|
|
my $rep = $args{rep}; |
15
|
|
|
|
|
|
|
die qq{Please supply the path to a repository of ppd files} |
16
|
|
|
|
|
|
|
unless $rep; |
17
|
|
|
|
|
|
|
die qq{The given repository directory "$rep" does not exist} |
18
|
|
|
|
|
|
|
unless -d $rep; |
19
|
|
|
|
|
|
|
opendir(my $dir, $rep) or die "Cannot opendir $rep: $!"; |
20
|
|
|
|
|
|
|
my @ppds = sort {lc $a cmp lc $b} grep {$_ =~ /\.ppd$/} readdir $dir; |
21
|
|
|
|
|
|
|
closedir($dir); |
22
|
|
|
|
|
|
|
die qq{The repository directory "$rep" contains no ppd files} |
23
|
|
|
|
|
|
|
unless (scalar @ppds > 0); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $no_ppm4 = $args{no_ppm4}; |
26
|
|
|
|
|
|
|
my $fhs = { |
27
|
|
|
|
|
|
|
summary => {file => 'summary.ppm', |
28
|
|
|
|
|
|
|
softpkg => \&summary_softpkg, |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
searchsummary => {file => 'searchsummary.ppm', |
31
|
|
|
|
|
|
|
softpkg => \&searchsummary_softpkg, |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
package_lst => {file => 'package.lst', |
34
|
|
|
|
|
|
|
softpkg => \&package_lst_softpkg, |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
unless ($no_ppm4) { |
38
|
|
|
|
|
|
|
$fhs->{package_xml} = {file => 'package.xml', |
39
|
|
|
|
|
|
|
softpkg => \&package_xml_softpkg, |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
my $self = {rep => $rep, |
43
|
|
|
|
|
|
|
ppds => \@ppds, |
44
|
|
|
|
|
|
|
no_ppm4 => $no_ppm4, |
45
|
|
|
|
|
|
|
arch => $args{arch}, |
46
|
|
|
|
|
|
|
fhs => $fhs, |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
bless $self, $class; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub summary { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
my $rep = $self->{rep}; |
54
|
|
|
|
|
|
|
my $fhs = $self->{fhs}; |
55
|
|
|
|
|
|
|
chdir($rep) or die qq{Cannot chdir to $rep: $!}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $arch = $self->{arch}; |
58
|
|
|
|
|
|
|
foreach my $key (keys %$fhs) { |
59
|
|
|
|
|
|
|
my $tmp = $fhs->{$key}->{file} . '.TMP'; |
60
|
|
|
|
|
|
|
open(my $fh, '>', $tmp) or die qq{Cannot open $tmp: $!}; |
61
|
|
|
|
|
|
|
my $writer = XML::Writer->new(OUTPUT => $fh, DATA_INDENT => 2); |
62
|
|
|
|
|
|
|
$fhs->{$key}->{fh} = $fh; |
63
|
|
|
|
|
|
|
$fhs->{$key}->{writer} = $writer; |
64
|
|
|
|
|
|
|
my %attr; |
65
|
|
|
|
|
|
|
$attr{ARCHITECTURE} = $arch if $arch && $key eq 'package_xml'; |
66
|
|
|
|
|
|
|
$writer->xmlDecl('UTF-8'); |
67
|
|
|
|
|
|
|
$writer->startTag('REPOSITORYSUMMARY', %attr); |
68
|
|
|
|
|
|
|
$writer->setDataMode(1); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $ppds = $self->{ppds}; |
72
|
|
|
|
|
|
|
foreach my $ppd(@$ppds) { |
73
|
|
|
|
|
|
|
my $data; |
74
|
|
|
|
|
|
|
eval {$data = parse_ppd($ppd);}; |
75
|
|
|
|
|
|
|
if ($@) { |
76
|
|
|
|
|
|
|
warn qq{Error in parsing $ppd: $@}; |
77
|
|
|
|
|
|
|
next; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
unless ($data and (ref($data) eq 'HASH')) { |
80
|
|
|
|
|
|
|
warn qq{No valid ppd data available in $ppd}; |
81
|
|
|
|
|
|
|
next; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
foreach my $key (keys %$fhs) { |
84
|
|
|
|
|
|
|
$fhs->{$key}->{softpkg}->($fhs->{$key}->{writer}, $data); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
foreach my $key (keys %$fhs) { |
89
|
|
|
|
|
|
|
my $writer = delete $fhs->{$key}->{writer}; |
90
|
|
|
|
|
|
|
$writer->endTag('REPOSITORYSUMMARY'); |
91
|
|
|
|
|
|
|
$writer->end; |
92
|
|
|
|
|
|
|
close($fhs->{$key}->{fh}); |
93
|
|
|
|
|
|
|
my $real = $fhs->{$key}->{file}; |
94
|
|
|
|
|
|
|
my $tmp = $real . '.TMP'; |
95
|
|
|
|
|
|
|
move($tmp, $real) or warn qq{Cannot rename $tmp to $real: $!}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
return 1; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub summary_softpkg { |
101
|
|
|
|
|
|
|
my ($writer, $d) = @_; |
102
|
|
|
|
|
|
|
$writer->startTag('SOFTPKG' => NAME => $d->{SOFTPKG}->{NAME}, VERSION => $d->{SOFTPKG}->{VERSION}); |
103
|
|
|
|
|
|
|
for (qw/TITLE ABSTRACT AUTHOR/) { |
104
|
|
|
|
|
|
|
$writer->dataElement($_ => $d->{$_}); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
$writer->endTag('SOFTPKG'); |
107
|
|
|
|
|
|
|
return 1; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub searchsummary_softpkg { |
111
|
|
|
|
|
|
|
my ($writer, $d) = @_; |
112
|
|
|
|
|
|
|
$writer->startTag('SOFTPKG' => NAME => $d->{SOFTPKG}->{NAME}, VERSION => $d->{SOFTPKG}->{VERSION}); |
113
|
|
|
|
|
|
|
for (qw/TITLE ABSTRACT AUTHOR/) { |
114
|
|
|
|
|
|
|
$writer->dataElement($_ => $d->{$_}); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
my $imp = $d->{IMPLEMENTATION}; |
117
|
|
|
|
|
|
|
foreach my $item(@$imp) { |
118
|
|
|
|
|
|
|
$writer->startTag('IMPLEMENTATION'); |
119
|
|
|
|
|
|
|
$writer->emptyTag('ARCHITECTURE' => NAME => $item->{ARCHITECTURE}->{NAME}); |
120
|
|
|
|
|
|
|
$writer->endTag('IMPLEMENTATION'); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
$writer->endTag('SOFTPKG'); |
123
|
|
|
|
|
|
|
return 1; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub package_lst_softpkg { |
127
|
|
|
|
|
|
|
my ($writer, $d) = @_; |
128
|
|
|
|
|
|
|
$writer->startTag('SOFTPKG' => NAME => $d->{SOFTPKG}->{NAME}, VERSION => $d->{SOFTPKG}->{VERSION}); |
129
|
|
|
|
|
|
|
for (qw/TITLE ABSTRACT AUTHOR/) { |
130
|
|
|
|
|
|
|
$writer->dataElement($_ => $d->{$_}); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
my $imp = $d->{IMPLEMENTATION}; |
133
|
|
|
|
|
|
|
foreach my $item(@$imp) { |
134
|
|
|
|
|
|
|
$writer->startTag('IMPLEMENTATION'); |
135
|
|
|
|
|
|
|
my $deps = $item->{DEPENDENCY}; |
136
|
|
|
|
|
|
|
if (defined $deps and (ref($deps) eq 'ARRAY')) { |
137
|
|
|
|
|
|
|
foreach my $dep (@$deps) { |
138
|
|
|
|
|
|
|
$writer->emptyTag('DEPENDENCY' => NAME => $dep->{NAME}, VERSION => $dep->{VERSION}); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
foreach (qw(OS ARCHITECTURE)) { |
143
|
|
|
|
|
|
|
next unless $item->{$_}->{NAME}; |
144
|
|
|
|
|
|
|
$writer->emptyTag($_ => NAME => $item->{$_}->{NAME}); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
if (my $script = $item->{INSTALL}->{SCRIPT}) { |
148
|
|
|
|
|
|
|
my %attr; |
149
|
|
|
|
|
|
|
for (qw/EXEC HREF/) { |
150
|
|
|
|
|
|
|
next unless $item->{INSTALL}->{$_}; |
151
|
|
|
|
|
|
|
$attr{$_} = $item->{INSTALL}->{$_}; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
$writer->dataElement('INSTALL' => $script, %attr); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
$writer->emptyTag('CODEBASE' => HREF => $item->{CODEBASE}->{HREF}); |
156
|
|
|
|
|
|
|
$writer->endTag('IMPLEMENTATION'); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
$writer->endTag('SOFTPKG'); |
159
|
|
|
|
|
|
|
return 1; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub package_xml_softpkg { |
163
|
|
|
|
|
|
|
my ($writer, $d) = @_; |
164
|
|
|
|
|
|
|
my $s_version = ppd2cpan_version($d->{SOFTPKG}->{VERSION}); |
165
|
|
|
|
|
|
|
$writer->startTag('SOFTPKG' => NAME => $d->{SOFTPKG}->{NAME}, VERSION => $s_version); |
166
|
|
|
|
|
|
|
for (qw/ABSTRACT AUTHOR/) { |
167
|
|
|
|
|
|
|
$writer->dataElement($_ => $d->{$_}); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
my $imp = $d->{IMPLEMENTATION}; |
170
|
|
|
|
|
|
|
my $size = scalar @$imp; |
171
|
|
|
|
|
|
|
foreach my $item (@$imp) { |
172
|
|
|
|
|
|
|
$writer->startTag('IMPLEMENTATION'); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
if (my $arch = $item->{ARCHITECTURE}->{NAME}) { |
175
|
|
|
|
|
|
|
$writer->emptyTag('ARCHITECTURE' => NAME => $arch); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
if (my $script = $item->{INSTALL}->{SCRIPT}) { |
179
|
|
|
|
|
|
|
my %attr; |
180
|
|
|
|
|
|
|
for (qw/EXEC HREF/) { |
181
|
|
|
|
|
|
|
next unless $item->{INSTALL}->{$_}; |
182
|
|
|
|
|
|
|
$attr{$_} = $item->{INSTALL}->{$_}; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
$writer->dataElement('INSTALL' => $script, %attr); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
$writer->emptyTag('CODEBASE' => HREF => $item->{CODEBASE}->{HREF}); |
187
|
|
|
|
|
|
|
if ($size == 1) { |
188
|
|
|
|
|
|
|
$writer->endTag('IMPLEMENTATION'); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
my $provide = $item->{PROVIDE}; |
191
|
|
|
|
|
|
|
if ($provide and (ref($provide) eq 'ARRAY')) { |
192
|
|
|
|
|
|
|
foreach my $mod(@$provide) { |
193
|
|
|
|
|
|
|
my %attr; |
194
|
|
|
|
|
|
|
if ($mod->{VERSION}) { |
195
|
|
|
|
|
|
|
$attr{VERSION} = $mod->{VERSION}; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
$writer->emptyTag('PROVIDE' => NAME => $mod->{NAME}, %attr); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
my $deps = $item->{DEPENDENCY}; |
202
|
|
|
|
|
|
|
if ($deps and (ref($deps) eq 'ARRAY')) { |
203
|
|
|
|
|
|
|
foreach my $dep (@$deps) { |
204
|
|
|
|
|
|
|
# ppm4 819 doesn't seem to like version numbers |
205
|
|
|
|
|
|
|
# my $p_version = ppd2cpan_version($dep->{VERSION}); |
206
|
|
|
|
|
|
|
# $writer->emptyTag('REQUIRE' => NAME => $dep->{NAME}, VERSION => $p_version); |
207
|
|
|
|
|
|
|
$writer->emptyTag('REQUIRE' => NAME => $dep->{NAME}); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
if ($size > 1) { |
211
|
|
|
|
|
|
|
$writer->endTag('IMPLEMENTATION'); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
$writer->endTag('SOFTPKG'); |
216
|
|
|
|
|
|
|
return 1; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
1; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
__END__ |