line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FreeBSD::Ports::INDEXhash; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23271
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
797
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
@EXPORT_OK = qw(INDEXhash); |
9
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
@EXPORT = (); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
FreeBSD::Ports::INDEXhash - Generates a hash out of the FreeBSD Ports index file. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 1.2.2 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '1.2.2'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use FreeBSD::Ports::INDEXhash qw/INDEXhash/; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my %hash=INDEXhash(); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
while(my ($name, $port) = each %hash){ |
32
|
|
|
|
|
|
|
print "Name: ".$name."\n". |
33
|
|
|
|
|
|
|
"Info: ".$port->{info}."\n". |
34
|
|
|
|
|
|
|
"Prefix: ".$port->{prefix}."\n". |
35
|
|
|
|
|
|
|
"Maintainer: ".$port->{maintainer}."\n". |
36
|
|
|
|
|
|
|
"WWW: ".$port->{www}."\n". |
37
|
|
|
|
|
|
|
"Categories: ".join(" ", @{$port->{categories}})."\n". |
38
|
|
|
|
|
|
|
"E-deps: ".join(" ", @{$port->{Edeps}})."\n". |
39
|
|
|
|
|
|
|
"B-deps: ".join(" ", @{$port->{Bdeps}})."\n". |
40
|
|
|
|
|
|
|
"P-deps: ".join(" ", @{$port->{Pdeps}})."\n". |
41
|
|
|
|
|
|
|
"R-deps: ".join(" ", @{$port->{Rdeps}})."\n". |
42
|
|
|
|
|
|
|
"F-deps: ".join(" ", @{$port->{Fdeps}})."\n". |
43
|
|
|
|
|
|
|
"\n"; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$keysInt++; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 EXPORT |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
INDEXhash |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 FUNCTIONS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 INDEXhash |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This parses the FreeBSD ports index file and a hash of it. Upon error it returns undef. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
If a path to it is not passed to this function, it chooses the file automatically. The |
60
|
|
|
|
|
|
|
PORTSDIR enviromental varaiable is respected if using automatically. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub INDEXhash { |
65
|
0
|
|
|
0
|
1
|
|
my $index=$_[0]; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if(!defined($index)){ |
68
|
0
|
0
|
|
|
|
|
if(!defined($ENV{PORTSDIR})){ |
69
|
0
|
|
|
|
|
|
$index="/usr/ports/INDEX-"; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
}else{ |
72
|
0
|
|
|
|
|
|
$index=$ENV{PORTSDIR}."/INDEX-"; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $fbsdversion=`uname -r`; |
76
|
0
|
|
|
|
|
|
chomp($fbsdversion); |
77
|
0
|
|
|
|
|
|
$fbsdversion =~ s/\..+// ; |
78
|
0
|
|
|
|
|
|
$index=$index.$fbsdversion; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if (! -f $index) { |
81
|
0
|
0
|
|
|
|
|
if(!defined($ENV{PORTSDIR})){ |
82
|
0
|
|
|
|
|
|
$index="/usr/ports/INDEX"; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
}else{ |
85
|
0
|
|
|
|
|
|
$index=$ENV{PORTSDIR}."/INDEX"; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#error out if the it is not a file |
92
|
0
|
0
|
|
|
|
|
if(! -f $index){ |
93
|
0
|
|
|
|
|
|
return undef; |
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#read the index file |
97
|
0
|
0
|
|
|
|
|
if(!open(INDEXFILE, $index)){ |
98
|
0
|
|
|
|
|
|
return undef; |
99
|
|
|
|
|
|
|
}; |
100
|
0
|
|
|
|
|
|
my @rawindex=; |
101
|
0
|
|
|
|
|
|
close(INDEXFILE); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
my %hash=(orginsN2D=>{}, originsD2N=>{}); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $rawindexInt=0; |
106
|
0
|
|
|
|
|
|
while(defined($rawindex[$rawindexInt])){ |
107
|
0
|
|
|
|
|
|
my @linesplit=split(/\|/, $rawindex[$rawindexInt]); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$hash{$linesplit[0]}={path=>$linesplit[1], |
110
|
|
|
|
|
|
|
prefix=>$linesplit[2], |
111
|
|
|
|
|
|
|
info=>$linesplit[3], |
112
|
|
|
|
|
|
|
maintainer=>$linesplit[5], |
113
|
|
|
|
|
|
|
www=>$linesplit[9], |
114
|
|
|
|
|
|
|
Bdeps=>[], |
115
|
|
|
|
|
|
|
Rdeps=>[], |
116
|
|
|
|
|
|
|
Edeps=>[], |
117
|
|
|
|
|
|
|
Pdeps=>[], |
118
|
|
|
|
|
|
|
Fdeps=>[], |
119
|
|
|
|
|
|
|
categories=>[] |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#builds the origin mappings |
123
|
0
|
|
|
|
|
|
$hash{originsN2D}{$linesplit[0]}=$linesplit[1]; |
124
|
0
|
|
|
|
|
|
$hash{originsD2N}{$linesplit[1]}=$linesplit[0]; |
125
|
|
|
|
|
|
|
#builds the short origin mappings |
126
|
0
|
|
|
|
|
|
$hash{soriginsN2D}{$linesplit[0]}=$linesplit[1]; |
127
|
0
|
|
|
|
|
|
$hash{soriginsN2D}{$linesplit[0]}=~s/\/usr\/ports\///; |
128
|
0
|
0
|
|
|
|
|
if (defined($ENV{PORTSDIR})) { |
129
|
0
|
|
|
|
|
|
$hash{soriginsN2D}{$linesplit[0]}=~s/$ENV{PORTSDIR}//; |
130
|
0
|
|
|
|
|
|
$hash{soriginsN2D}{$linesplit[0]}=~s/^\///; |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
|
$hash{soriginsD2N}{$hash{soriginsN2D}{$linesplit[0]}}=$linesplit[0]; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my $depsInt=0; |
135
|
0
|
|
|
|
|
|
chomp($linesplit[12]); |
136
|
0
|
|
|
|
|
|
my @Fdeps=split(/ /, $linesplit[12]); |
137
|
0
|
|
|
|
|
|
while(defined($Fdeps[$depsInt])){ |
138
|
0
|
|
|
|
|
|
push(@{$hash{$linesplit[0]}{Fdeps}}, $Fdeps[$depsInt]); |
|
0
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
$depsInt++; |
141
|
|
|
|
|
|
|
}; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
$depsInt=0; |
145
|
0
|
|
|
|
|
|
my @Pdeps=split(/ /, $linesplit[11]); |
146
|
0
|
|
|
|
|
|
while(defined($Pdeps[$depsInt])){ |
147
|
0
|
|
|
|
|
|
push(@{$hash{$linesplit[0]}{Pdeps}}, $Pdeps[$depsInt]); |
|
0
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
$depsInt++; |
150
|
|
|
|
|
|
|
}; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
$depsInt=0; |
153
|
0
|
|
|
|
|
|
my @Edeps=split(/ /, $linesplit[10]); |
154
|
0
|
|
|
|
|
|
while(defined($Edeps[$depsInt])){ |
155
|
0
|
|
|
|
|
|
push(@{$hash{$linesplit[0]}{Edeps}}, $Edeps[$depsInt]); |
|
0
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
$depsInt++; |
158
|
|
|
|
|
|
|
}; |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
$depsInt=0; |
161
|
0
|
|
|
|
|
|
my @Rdeps=split(/ /, $linesplit[8]); |
162
|
0
|
|
|
|
|
|
while(defined($Rdeps[$depsInt])){ |
163
|
0
|
|
|
|
|
|
push(@{$hash{$linesplit[0]}{Rdeps}}, $Rdeps[$depsInt]); |
|
0
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$depsInt++; |
166
|
|
|
|
|
|
|
}; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
$depsInt=0; |
169
|
0
|
|
|
|
|
|
my @Bdeps=split(/ /, $linesplit[7]); |
170
|
0
|
|
|
|
|
|
while(defined($Bdeps[$depsInt])){ |
171
|
0
|
|
|
|
|
|
push(@{$hash{$linesplit[0]}{Bdeps}}, $Bdeps[$depsInt]); |
|
0
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
$depsInt++; |
174
|
|
|
|
|
|
|
}; |
175
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
$depsInt=0; |
177
|
0
|
|
|
|
|
|
my @categories=split(/ /, $linesplit[6]); |
178
|
0
|
|
|
|
|
|
while(defined($categories[$depsInt])){ |
179
|
0
|
|
|
|
|
|
push(@{$hash{$linesplit[0]}{categories}}, $categories[$depsInt]); |
|
0
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
$depsInt++; |
182
|
|
|
|
|
|
|
}; |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
$rawindexInt++; |
185
|
|
|
|
|
|
|
}; |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
return %hash; |
188
|
|
|
|
|
|
|
}; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 HASH FORMAT |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Each entry, minus 'originsN2D' and 'originsD2N'. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 ports hash |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head3 info |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This is a short description of the port. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head3 prefix |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
This is the install prefix the port will try to use. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head3 maintainer |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
This is the email address for the port's maintainer. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head3 www |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
This is the web site of a port inquestion. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head3 Edeps |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This is the extract depends of a port. This is a array. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head3 Bdeps |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
This is the build depends for the port. This is a array. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head3 Pdeps |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
This is the package depends for a port. This is a array. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head3 Rdeps |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
This is the run depends of a port. This is a array. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head3 Fdeps |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
This is the fetch depends of a port. This is a array. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head3 categories |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This is all the categories a specific port falls under. This is a array. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 originsN2D |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
This contains a mapping of port names to the directory they are in. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 originsD2N |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This contains a mapping of directories to port names. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 soriginsD2N |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
This is the same as 'originsD2N', but does not everything prior to |
247
|
|
|
|
|
|
|
the ports directory is removed. This is to make it easy for matching |
248
|
|
|
|
|
|
|
packages to ports. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 originsN2D |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
This is the same as 'originsN2D', but does not everything prior to |
254
|
|
|
|
|
|
|
the ports directory is removed. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 AUTHOR |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 BUGS |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
263
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
264
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 SUPPORT |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
perldoc FreeBSD::Ports::INDEXhash |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
You can also look for information at: |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=over 4 |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
L |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
L |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=item * CPAN Ratings |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
L |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=item * Search CPAN |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
L |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=back |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
kevin brintnall for pointing out how useful the each function is. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
Yen-Ming Lee for pointing out the issue with Fdeps always being defined due to a new line on the end of it. |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
Copyright 2008 Zane C. Bowers, all rights reserved. |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
310
|
|
|
|
|
|
|
under the same terms as Perl itself. |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=cut |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
1; # End of FreeBSD::Ports::INDEXhash |