line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
287553
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
717
|
|
2
|
|
|
|
|
|
|
package Parse::Debian::Packages; |
3
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
1
|
|
|
1
|
1
|
70
|
my $class = shift; |
7
|
1
|
|
|
|
|
18
|
my $fh = shift; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
6
|
return bless { fh => $fh }, $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub next { |
13
|
1
|
|
|
1
|
1
|
578
|
my $self = shift; |
14
|
1
|
|
|
|
|
7
|
my $fh = $self->{fh}; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
2
|
my %parsed; |
17
|
1
|
|
|
|
|
397769
|
while (<$fh>) { |
18
|
15
|
100
|
|
|
|
48
|
last if /^$/; |
19
|
14
|
100
|
|
|
|
481
|
if (my ($key, $value) = m/^(\S+): (.*)/) { |
20
|
13
|
|
|
|
|
152
|
$parsed{$key} = $value; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else { |
23
|
1
|
|
|
|
|
7
|
s/ //; |
24
|
1
|
|
|
|
|
3
|
s/^\.$//; |
25
|
1
|
|
|
|
|
5
|
$parsed{body} .= $_; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
20
|
return %parsed; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub as_hash { |
33
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
34
|
0
|
|
|
|
|
|
my $parser = $class->new(@_); |
35
|
0
|
|
|
|
|
|
my %hash; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
while (my %package = $parser->next) { |
38
|
0
|
|
|
|
|
|
$hash{ $package{Package} } = \%package; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
return \%hash; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Parse::Debian::Packages - parse the data from a debian Packages.gz |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
use YAML; |
53
|
|
|
|
|
|
|
use IO::File; |
54
|
|
|
|
|
|
|
use Parse::Debian::Packages; |
55
|
|
|
|
|
|
|
my $fh = IO::File->new("Packages"); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $parser = Parse::Debian::Packages->new( $fh ); |
58
|
|
|
|
|
|
|
while (my %package = $parser->next) { |
59
|
|
|
|
|
|
|
print Dump \%package; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This module parses the Packages files used by the debian package |
65
|
|
|
|
|
|
|
management tools. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
It presents itself as an iterator. Each call of the ->next method |
68
|
|
|
|
|
|
|
will return the next package found in the file. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
For laziness, we take a filehandle in to the constructor. Please open |
71
|
|
|
|
|
|
|
the file for us. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 new( $filehandle ) |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 next |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Iterate to the next package in the file, returns either a hash |
80
|
|
|
|
|
|
|
containing a package description, or false at end of file. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 as_hash( $filehandle ) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Return all the packages from a filehandle as a hash of hashes. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Richard Clamp <richardc@unixbeard.net> with as_hash implementation by |
89
|
|
|
|
|
|
|
Thomas Klausner. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright (C) 2003,2005,2012 Richard Clamp. All Rights Reserved. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
96
|
|
|
|
|
|
|
under the same terms as Perl itself. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SEE ALSO |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Module::Packaged |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|