line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Slackware::Slackget::SpecialFiles::FILELIST; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Slackware::Slackget::File; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
7
|
1
|
|
|
1
|
|
5
|
use Slackware::Slackget::Date; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
8
|
1
|
|
|
1
|
|
5
|
use Slackware::Slackget::Package; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
904
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Slackware::Slackget::SpecialFiles::FILELIST - An interface for the special file FILELIST.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 FILELIST.TXT file |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Slackware::Slackget::SpecialFiles::FILELIST; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $spec_file = Slackware::Slackget::SpecialFiles::FILELIST->new('FILELIST.TXT'); |
29
|
|
|
|
|
|
|
$spec_file->compil(); |
30
|
|
|
|
|
|
|
my $ref = $spec_file->get_file_list() ; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This class care about package-namespace, which is the root set of a package (slackware, extra or pasture for packages from Slackware) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 WARNINGS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
All classes from the Slackware::Slackget::SpecialFiles:: namespace need the followings methods : |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
- a contructor new() |
39
|
|
|
|
|
|
|
- a method compil() |
40
|
|
|
|
|
|
|
- a method get_result(), which one can be an alias on another method of the class. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Moreover, the get_result() methode need to return a hashref. Keys of this hashref are the filenames. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
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. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 new |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Take a file, a Slackware::Slackget::Config object and an id name : |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $spec_chk = Slackware::Slackget::SpecialFiles::CHECKSUMS->new('/home/packages/FILELIST.TXT',$config,'slackware'); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
The constructor return undef if the file does not exist. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
1
|
|
my ($class,$file,$config,$root) = @_ ; |
61
|
0
|
0
|
0
|
|
|
|
return undef if(!defined($config) && ref($config) ne 'Slackware::Slackget::Config') ; |
62
|
0
|
|
|
|
|
|
my $self={}; |
63
|
0
|
|
|
|
|
|
$self->{ROOT} = $root; |
64
|
0
|
|
|
|
|
|
$self->{config}=$config; |
65
|
0
|
0
|
0
|
|
|
|
return undef unless(defined($file) && -e $file); |
66
|
|
|
|
|
|
|
# print "[debug FILELIST] Loading $file as FILELIST\n"; |
67
|
0
|
|
|
|
|
|
$self->{FILE} = new Slackware::Slackget::File ($file,'file-encoding' => $config->{common}->{'file-encoding'}); |
68
|
0
|
|
|
|
|
|
$self->{DATA} = {}; |
69
|
0
|
|
|
|
|
|
bless($self,$class); |
70
|
0
|
|
|
|
|
|
return $self; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 FUNCTIONS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 compile |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This method take no arguments, and extract the list of couple (file/package-namespace). Those couple are store into an internal data structure. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$list->compile(); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub compile { |
84
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
85
|
0
|
0
|
|
|
|
|
if($self->{FILE}->Get_line(0)=~ /(\w+) (\w+) (\d+) ([\d:]+) \w+ (\d+)/) # match a date like : Tue Apr 5 12:56:29 PDT 2005 |
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
|
|
|
$self->{METADATA}->{'date'} = new Slackware::Slackget::Date ( |
88
|
|
|
|
|
|
|
'day-name' => $1, |
89
|
|
|
|
|
|
|
'day-number' => $3, |
90
|
|
|
|
|
|
|
'month' => $2, |
91
|
|
|
|
|
|
|
'hour' => $4, |
92
|
|
|
|
|
|
|
'year' => $6 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
} |
96
|
0
|
|
|
|
|
|
foreach ($self->{FILE}->Get_file()){ |
97
|
0
|
|
|
|
|
|
chomp; |
98
|
0
|
0
|
|
|
|
|
next if($_=~ /\.asc\s*\n*$/i); |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
if(my @m=$_=~/^([^\s]+)\s+(\d+)\s+(\w+)\s+(\w+)\s+(\d+)\s+(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\s+\.\/(.*)\/(.*)\.tgz\s*\n*$/gi){#(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\s+\.\/(.*)\/([^\/\s\n]*)\.tgz |
|
|
0
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# 1 2 3 4 5 6 7 8 9 10 11 12 |
102
|
0
|
|
|
|
|
|
$m[10].='/'; # a fucking bad hack :( |
103
|
0
|
0
|
|
|
|
|
next if ($m[10]=~ /(source|src)\//); |
104
|
|
|
|
|
|
|
# print "matching $m[11] : \n\t",join ' ; ',@m,"\n\n"; |
105
|
0
|
|
|
|
|
|
$self->{DATA}->{$m[11]} = new Slackware::Slackget::Package ( $m[11] ); |
106
|
0
|
0
|
|
|
|
|
$self->{DATA}->{$m[11]}->setValue('package-source',$self->{ROOT}) if($self->{ROOT}); |
107
|
0
|
|
|
|
|
|
$self->{DATA}->{$m[11]}->setValue('package-location',$m[10]); |
108
|
0
|
|
|
|
|
|
$self->{DATA}->{$m[11]}->setValue('compressed-size',int($m[4]/1024)); |
109
|
0
|
|
|
|
|
|
$self->{DATA}->{$m[11]}->setValue('package-date',new Slackware::Slackget::Date ( |
110
|
|
|
|
|
|
|
'year' => $m[5], |
111
|
|
|
|
|
|
|
'month-number' => $m[6], |
112
|
|
|
|
|
|
|
'day-number' => $m[7], |
113
|
|
|
|
|
|
|
'hour' => $m[8].':'.$m[9].':00' |
114
|
|
|
|
|
|
|
)); |
115
|
|
|
|
|
|
|
# $self->{FILE}->Write("packages/$m[11]_$self->{ROOT}.xml",$self->{DATA}->{$m[11]}->to_XML); |
116
|
|
|
|
|
|
|
# print "\nPAUSE\n";; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
elsif($_=~/\.tgz/i){ |
119
|
0
|
|
|
|
|
|
warn "Skipping $_ even if it's a .tgz (source: $self->{ROOT})\n"; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
0
|
|
|
|
|
|
$self->{FILE}->Close(); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# DEBUG ONLY |
125
|
|
|
|
|
|
|
# unlink("filelist_$self->{ROOT}.xml") if(-e "filelist_$self->{ROOT}.xml"); |
126
|
|
|
|
|
|
|
# print "saving filelist_$self->{ROOT}.xml\n"; |
127
|
|
|
|
|
|
|
# $self->{FILE}->Write("debug/filelist_$self->{ROOT}.xml",$self->to_XML); |
128
|
|
|
|
|
|
|
# $self->{FILE}->Close(); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 get_file_list |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Return a hashref build on this model |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$ref = { |
136
|
|
|
|
|
|
|
filename => Slackware::Slackget::Package |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $ref = $list->get_file_list ; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub get_file_list { |
144
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
145
|
0
|
|
|
|
|
|
return $self->{DATA} ; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 get_package |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Return informations relative to a packages as a hashref. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $hashref = $list->get_package($package_name) ; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub get_package { |
157
|
0
|
|
|
0
|
1
|
|
my ($self,$pack_name) = @_ ; |
158
|
0
|
|
|
|
|
|
return $self->{DATA}->{$pack_name} ; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 get_result |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Alias for get_file_list(). |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub get_result { |
168
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
169
|
0
|
|
|
|
|
|
return $self->get_file_list(); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 get_date |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
return a Slackware::Slackget::Date object, which is the date of the FILELIST.TXT |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
my $date = $list->get_date ; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub get_date { |
181
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
182
|
0
|
|
|
|
|
|
return $self->{METADATA}->{'date'} ; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 to_XML (deprecated) |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Same as to_xml(), provided for backward compatibility. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub to_XML { |
192
|
0
|
|
|
0
|
1
|
|
return to_xml(@_); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 to_xml |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
return a string containing all packages name carriage return separated. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
WARNING: ONLY FOR DEBUG |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
my $string = $list->to_xml(); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub to_xml { |
206
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
207
|
0
|
|
|
|
|
|
my $xml = "\n"; |
208
|
0
|
|
|
|
|
|
foreach (keys(%{$self->{DATA}})){ |
|
0
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
$xml .= $self->{DATA}->{$_}->to_XML ; |
210
|
|
|
|
|
|
|
} |
211
|
0
|
|
|
|
|
|
$xml .= "\n"; |
212
|
0
|
|
|
|
|
|
return $xml; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 meta_to_XML (deprecated) |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Same as meta_to_xml(), provided for backward compatibility. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=cut |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub meta_to_XML { |
222
|
0
|
|
|
0
|
1
|
|
return meta_to_xml(@_); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head2 meta_to_xml |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Return an XML encoded string which represent the meta informations of the FILELIST.TXT file. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
my $xml_string = $list->meta_to_xml ; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub meta_to_xml |
234
|
|
|
|
|
|
|
{ |
235
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
236
|
0
|
|
|
|
|
|
my $xml = "\t\n"; |
237
|
0
|
0
|
|
|
|
|
$xml .= "\t\t".$self->get_date()->to_XML()."\n" if(defined($self->get_date)); |
238
|
0
|
|
|
|
|
|
$xml = "\t\n"; |
239
|
0
|
|
|
|
|
|
return $xml; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 AUTHOR |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
DUPUIS Arnaud, C<< >> |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 BUGS |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
249
|
|
|
|
|
|
|
C, or through the web interface at |
250
|
|
|
|
|
|
|
L. |
251
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
252
|
|
|
|
|
|
|
your bug as I make changes. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 SUPPORT |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
perldoc Slackware::Slackget |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
You can also look for information at: |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=over 4 |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item * Infinity Perl website |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
L |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item * slack-get specific website |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
L |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
L |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
L |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=item * CPAN Ratings |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
L |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=item * Search CPAN |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
L |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=back |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Copyright 2005 DUPUIS Arnaud, All Rights Reserved. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
301
|
|
|
|
|
|
|
under the same terms as Perl itself. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=cut |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
1; # End of Slackware::Slackget::SpecialFiles::FILELIST |