| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alien::Packages::RpmDB; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
923
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
76
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Alien::Packages::RpmDB - acesses the RPM database directly |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = "0.003"; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require Alien::Packages::Base; |
|
16
|
1
|
|
|
1
|
|
6
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
537
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@ISA = qw(Alien::Packages::Base); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 ISA |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Alien::Packages::RpmDB |
|
23
|
|
|
|
|
|
|
ISA Alien::Packages::Base |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 usable |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Returns true when the rpm database can be accessed via L. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub usable |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
2
|
50
|
|
2
|
1
|
10
|
unless ( defined( $INC{'RPM/Database.pm'} ) ) |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
2
|
|
|
|
|
4
|
eval { |
|
38
|
2
|
|
|
|
|
9183
|
require RPM; |
|
39
|
0
|
|
|
|
|
0
|
require RPM::Database; |
|
40
|
|
|
|
|
|
|
}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
2
|
50
|
|
|
|
19
|
defined( $INC{'RPM.pm'} ) and RPM->import(qw($err)); |
|
43
|
2
|
50
|
|
|
|
10
|
defined( $INC{'RPM/Database.pm'} ) and RPM::Database->import(); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
43
|
return $INC{'RPM/Database.pm'}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 new |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Instantiates a new Alien::Packages::RpmDB object and initializes a |
|
52
|
|
|
|
|
|
|
connection to the rpm database. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
0
|
|
|
0
|
1
|
|
my ( $class, @options ) = @_; |
|
59
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@options); |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my %h; |
|
62
|
0
|
0
|
|
|
|
|
tie %h, "RPM::Database" or croak $RPM::err; |
|
63
|
0
|
0
|
|
|
|
|
$self->{rpmdb} = \%h unless ($RPM::err); |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $self; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 pkgtype |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns the pkg type "rpm". |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub pkgtype |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
0
|
|
|
0
|
1
|
|
return "rpm"; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 list_packages |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Queries the list of installed I packages from the database. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub list_packages |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
|
88
|
0
|
|
|
|
|
|
my @packages; |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
while ( my ( $rpm_name, $rpm_header ) = each( %{ $self->{rpmdb} } ) ) |
|
|
0
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
{ |
|
92
|
0
|
|
|
|
|
|
my @nvr = $rpm_header->NVR(); |
|
93
|
0
|
|
|
|
|
|
push( @packages, [ $nvr[0], $nvr[1], $rpm_header->summary() ] ); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return @packages; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 list_fileowners |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Queries the list of I packages from the database which have an |
|
102
|
|
|
|
|
|
|
association to the requested file(s). |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub list_fileowners |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
0
|
|
|
0
|
1
|
|
my ( $self, @files ) = @_; |
|
109
|
0
|
|
|
|
|
|
my %file_owners; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
foreach my $file (@files) |
|
112
|
|
|
|
|
|
|
{ |
|
113
|
0
|
|
|
|
|
|
my ($rpm_header) = ( tied %{ $self->{rpmdb} } )->find_by_file($file); |
|
|
0
|
|
|
|
|
|
|
|
114
|
0
|
0
|
|
|
|
|
if ($rpm_header) |
|
115
|
|
|
|
|
|
|
{ |
|
116
|
0
|
|
|
|
|
|
my @nvr = $rpm_header->NVR(); |
|
117
|
0
|
|
|
|
|
|
push( @{ $file_owners{$file} }, { Package => $nvr[0] } ); |
|
|
0
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
return %file_owners; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Jens Rehsack, C<< >> |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Copyright 2010 Jens Rehsack. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
133
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
134
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |