| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Slackware::Slackget::SpecialFiles::PACKAGES; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
65
|
|
|
|
2
|
|
|
|
|
58
|
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
37
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use Slackware::Slackget::File; |
|
|
2
|
|
|
|
|
1
|
|
|
|
2
|
|
|
|
|
44
|
|
|
7
|
2
|
|
|
2
|
|
7
|
use Slackware::Slackget::Date; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
31
|
|
|
8
|
2
|
|
|
2
|
|
9
|
use Slackware::Slackget::Package ; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1362
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Slackware::Slackget::SpecialFiles::PACKAGES - An interface for the special file PACKAGES.TXT |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 1.0.0 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This class contain all methods for the treatment of the PACKAGES.TXT file |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Slackware::Slackget::SpecialFiles::PACKAGES; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $pack = Slackware::Slackget::SpecialFiles::PACKAGES->new('PACKAGES.TXT','slackware'); |
|
29
|
|
|
|
|
|
|
... |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 WARNINGS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
All classes from the Slackware::Slackget::SpecialFiles:: namespace need the followings methods : |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
- a contructor new() |
|
36
|
|
|
|
|
|
|
- a method compil() |
|
37
|
|
|
|
|
|
|
- a method get_result(), which one can be an alias on another method of the class. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Moreover, the get_result() methode need to return a hashref. Keys of this hashref are the filenames. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Classes from ths namespace represent an abstraction of the special file they can manage so informations stored in the returned hashref must have a direct link with this special file. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 new |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Take a file, a Slackware::Slackget::Config object and an id name : |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $pack = Slackware::Slackget::SpecialFiles::PACKAGES->new('PACKAGES.TXT',$config,'slackware'); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
0
|
|
|
0
|
1
|
|
my ($class,$file,$config,$root) = @_ ; |
|
56
|
0
|
0
|
0
|
|
|
|
return undef if(!defined($config) && ref($config) ne 'Slackware::Slackget::Config') ; |
|
57
|
0
|
|
|
|
|
|
my $self={}; |
|
58
|
0
|
0
|
0
|
|
|
|
return undef unless(defined($file) && -e $file); |
|
59
|
|
|
|
|
|
|
# print "[debug PACKAGES] Loading $file as PACKAGES\n"; |
|
60
|
0
|
|
|
|
|
|
$self->{ROOT} = $root; |
|
61
|
0
|
|
|
|
|
|
$self->{config}=$config; |
|
62
|
0
|
|
|
|
|
|
$self->{FILE} = new Slackware::Slackget::File ($file,'file-encoding' => $config->{common}->{'file-encoding'}); |
|
63
|
0
|
|
|
|
|
|
$self->{DATA} = {}; |
|
64
|
0
|
|
|
|
|
|
$self->{METADATA} = {}; |
|
65
|
0
|
|
|
|
|
|
bless($self,$class); |
|
66
|
0
|
|
|
|
|
|
return $self; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 compile |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Take no argument, and compile the informations contains in the PACKAGES.TXT file into the internal data structure of slack-get. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$pack->compile ; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub compile { |
|
81
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
82
|
0
|
|
|
|
|
|
$self->get_meta; |
|
83
|
0
|
|
|
|
|
|
foreach (@{$self->create_entities}){ |
|
|
0
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $pack = new Slackware::Slackget::Package (1); |
|
85
|
0
|
0
|
|
|
|
|
$pack->setValue('package-source',$self->{ROOT}) if($self->{ROOT}); |
|
86
|
0
|
|
|
|
|
|
$pack->extract_informations($_); |
|
87
|
0
|
|
|
|
|
|
$pack->grab_info_from_description ; |
|
88
|
0
|
0
|
|
|
|
|
print STDERR "Error: informations extraction have failed\n" if(!$pack->get_id); |
|
89
|
|
|
|
|
|
|
# print "PACKAGING of ",$pack->get_id,"\n";$pack->print_full_info; |
|
90
|
0
|
|
|
|
|
|
$self->{DATA}->{$pack->get_id} = $pack ; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
0
|
|
|
|
|
|
$self->{FILE}->Close ; |
|
93
|
|
|
|
|
|
|
### DEBUG ONLY |
|
94
|
|
|
|
|
|
|
# $self->{FILE}->Write("debug/packages_$self->{ROOT}.xml",$self->to_XML); |
|
95
|
|
|
|
|
|
|
# $self->{FILE}->Close ; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 create_entities |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This method take the whole file PACKAGES.TXT and split it into entity (one package or meta informations) |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub create_entities { |
|
105
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
106
|
0
|
|
|
|
|
|
my @entities = (); |
|
107
|
0
|
|
|
|
|
|
my $idx = -1; |
|
108
|
0
|
|
|
|
|
|
foreach ($self->{FILE}->Get_selection($self->{'starting-position'})){ |
|
109
|
0
|
0
|
|
|
|
|
if($_=~ /^PACKAGE NAME:/){ |
|
110
|
0
|
|
|
|
|
|
$idx++; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
0
|
0
|
|
|
|
|
next if($_=~ /^\s*(#|\|-*handy-ruler)/i); |
|
113
|
0
|
|
|
|
|
|
$entities[$idx] .= $_ ; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
0
|
|
|
|
|
|
return \@entities ; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 get_meta |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This method parse the 10 first lines of the PACKAGES.TXT and extract globals informations. It define the 'starting-position' object tag (this information is only for coders). |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$pack->get_meta(); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub get_meta { |
|
127
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
128
|
0
|
|
|
|
|
|
my $l = 0; |
|
129
|
0
|
|
|
|
|
|
foreach ($self->{FILE}->Get_selection(0,15)){ |
|
130
|
0
|
0
|
|
|
|
|
if($_=~ /PACKAGES.TXT; (\w+) (\w+) (\d+) ([\d:]+) (\w+) (\d+)/){ |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$self->{METADATA}->{'date'} = new Slackware::Slackget::Date ( |
|
132
|
|
|
|
|
|
|
'day-name' => $1, |
|
133
|
|
|
|
|
|
|
'day-number' => $3, |
|
134
|
|
|
|
|
|
|
'month' => $2, |
|
135
|
|
|
|
|
|
|
'hour' => $4, |
|
136
|
|
|
|
|
|
|
'year' => $6 |
|
137
|
|
|
|
|
|
|
); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
elsif($_=~ /Total size of all packages \(compressed\):\s+(\d+) MB/){ |
|
140
|
0
|
|
|
|
|
|
$self->{METADATA}->{'compressed-size'} = $1; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
elsif($_=~ /Total size of all packages \(uncompressed\):\s+(\d+) MB/){ |
|
143
|
0
|
|
|
|
|
|
$self->{METADATA}->{'uncompressed-size'} = $1; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
elsif($_=~ /^PACKAGE NAME:/) |
|
146
|
|
|
|
|
|
|
{ |
|
147
|
0
|
|
|
|
|
|
$self->{'starting-position'}=$l; |
|
148
|
0
|
|
|
|
|
|
last; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
0
|
|
|
|
|
|
$l++; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 get_result |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Not yet implemented. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub get_result { |
|
161
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 get_package |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Return informations relative to a packages as a hashref. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
my $hashref = $list->get_package($package_name) ; |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub get_package { |
|
173
|
0
|
|
|
0
|
1
|
|
my ($self,$pack_name) = @_ ; |
|
174
|
0
|
|
|
|
|
|
return $self->{DATA}->{$pack_name} ; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 get_date |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
return a Slackware::Slackget::Date object, which is the date of the PACKAGES.TXT |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $date = $pack->get_date ; |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub get_date { |
|
186
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
187
|
0
|
|
|
|
|
|
return $self->{METADATA}->{'date'} ; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 to_XML (deprecated) |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Same as to_xml(), provided for backward compatibility. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub to_XML { |
|
197
|
0
|
|
|
0
|
1
|
|
return to_xml(@_); |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 to_xml |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
return the package as an XML encoded string. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
$xml = $package->to_xml(); |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub to_xml |
|
209
|
|
|
|
|
|
|
{ |
|
210
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
211
|
0
|
|
|
|
|
|
my $xml = "<packages>\n"; |
|
212
|
0
|
|
|
|
|
|
foreach (keys(%{$self->{DATA}})){ |
|
|
0
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# print "XMLization of $_\n"; |
|
214
|
0
|
|
|
|
|
|
$xml .= $self->{DATA}->{$_}->to_xml ; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
0
|
|
|
|
|
|
$xml .= "</packages>\n"; |
|
217
|
0
|
|
|
|
|
|
return $xml; |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 AUTHOR |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
DUPUIS Arnaud, C<< <a.dupuis@infinityperl.org> >> |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 BUGS |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
227
|
|
|
|
|
|
|
C<bug-Slackware-Slackget@rt.cpan.org>, or through the web interface at |
|
228
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget>. |
|
229
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
230
|
|
|
|
|
|
|
your bug as I make changes. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 SUPPORT |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
perldoc Slackware::Slackget |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
You can also look for information at: |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=over 4 |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item * Infinity Perl website |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
L<http://www.infinityperl.org/category/slack-get> |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * slack-get specific website |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
L<http://slackget.infinityperl.org> |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget> |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Slackware-Slackget> |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Slackware-Slackget> |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=item * Search CPAN |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Slackware-Slackget> |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Copyright 2005 DUPUIS Arnaud, All Rights Reserved. |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
279
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=cut |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
1; # End of Slackware::Slackget::SpecialFiles::PACKAGES |