line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
DPKG::Parse::Packages - Parse the Packages file |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use DPKG::Parse::Packages; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $packages = DPKG::Parse::Packages->new( |
10
|
|
|
|
|
|
|
'filename' => '/usr/src/packages/Packages', |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
while (my $entry = $packages->next_package) { |
13
|
|
|
|
|
|
|
print $entry->package . " " . $entry->version . "\n"; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $postfix = $packages->get_package('name' => 'postfix'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
L parses a dpkg/apt style Packages file and turns |
21
|
|
|
|
|
|
|
each entry into a L object. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
See L for more information on the get_package and next_package |
24
|
|
|
|
|
|
|
methods. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
See L for more information on the entry objects. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over 4 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package DPKG::Parse::Packages; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our $VERSION = '0.02'; # TRIAL |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
2
|
|
24988
|
use Params::Validate qw(:all); |
|
2
|
|
|
|
|
8018
|
|
|
2
|
|
|
|
|
319
|
|
39
|
2
|
|
|
2
|
|
477
|
use Class::C3; |
|
2
|
|
|
|
|
2292
|
|
|
2
|
|
|
|
|
11
|
|
40
|
2
|
|
|
2
|
|
59
|
use base qw(DPKG::Parse); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
460
|
|
41
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
42
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
158
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item new('filename' => '/usr/src/packages/Packages') |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Creates a new DPKG::Parse::Packages object. By default, it tries to open |
47
|
|
|
|
|
|
|
/usr/src/packages/Packages. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
sub new { |
51
|
2
|
|
|
2
|
1
|
50
|
my $pkg = shift; |
52
|
2
|
|
|
|
|
64
|
my %p = validate(@_, |
53
|
|
|
|
|
|
|
{ |
54
|
|
|
|
|
|
|
'filename' => { 'type' => SCALAR, 'default' => '/usr/src/packages/Packages', 'optional' => 1 }, |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
); |
57
|
2
|
|
|
|
|
15
|
my $ref = $pkg->next::method('filename' => $p{'filename'}); |
58
|
2
|
|
|
|
|
6
|
return $ref; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |