line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Packages::Rpm; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1084
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
769
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Alien::Packages::Rpm - get's information from RedHat Package Manager CLI |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = "0.003"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require Alien::Packages::Base; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@ISA = qw(Alien::Packages::Base); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 ISA |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Alien::Packages::Rpm |
22
|
|
|
|
|
|
|
ISA Alien::Packages::Base |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
require IPC::Cmd; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $rpm; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 usable |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Returns true when the rpm database access is not available (when |
35
|
|
|
|
|
|
|
L is not available) and the C command could be |
36
|
|
|
|
|
|
|
found in the path. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub usable |
41
|
|
|
|
|
|
|
{ |
42
|
1
|
50
|
|
1
|
1
|
10
|
unless ( defined($rpm) ) |
43
|
|
|
|
|
|
|
{ |
44
|
1
|
|
|
|
|
3
|
local $@; |
45
|
1
|
|
|
|
|
2
|
eval { require Alien::Packages::RpmDB; }; |
|
1
|
|
|
|
|
8
|
|
46
|
1
|
50
|
33
|
|
|
16
|
if ( !$@ && Alien::Packages::RpmDB->usable() ) |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
|
|
0
|
$rpm = ''; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else |
51
|
|
|
|
|
|
|
{ |
52
|
1
|
|
|
|
|
10
|
$rpm = IPC::Cmd::can_run('rpm'); |
53
|
1
|
|
50
|
|
|
422
|
$rpm ||= ''; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
12
|
return $rpm; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 list_packages |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns the list of installed I packages. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub list_packages |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
69
|
0
|
|
|
|
|
|
my @packages; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = |
72
|
|
|
|
|
|
|
$self->_run_ipc_cmd( |
73
|
|
|
|
|
|
|
command => [ $rpm, '-qa', '--queryformat', '"%{NAME}:%{VERSION}:%{RELEASE}:%{SUMMARY}\n"' ], |
74
|
|
|
|
|
|
|
verbose => 0, ); |
75
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
if ($success) |
77
|
|
|
|
|
|
|
{ |
78
|
0
|
|
|
|
|
|
my @pkglist = split( /\n/, $stdout_buf->[0] ); |
79
|
0
|
|
|
|
|
|
foreach my $pkg (@pkglist) |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
0
|
|
|
|
|
next if ( $pkg =~ m/^#/ ); |
82
|
0
|
|
|
|
|
|
my @pkg_details = split( ':', $pkg ); |
83
|
0
|
|
|
|
|
|
push( |
84
|
|
|
|
|
|
|
@packages, |
85
|
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
|
Package => $pkg_details[0], |
87
|
|
|
|
|
|
|
Version => $pkg_details[1], |
88
|
|
|
|
|
|
|
Release => $pkg_details[2], |
89
|
|
|
|
|
|
|
Summary => $pkg_details[3], |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return @packages; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 list_fileowners |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns the I packages which are associated to requested file(s). |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub list_fileowners |
105
|
|
|
|
|
|
|
{ |
106
|
0
|
|
|
0
|
1
|
|
my ( $self, @files ) = @_; |
107
|
0
|
|
|
|
|
|
my %file_owners; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
foreach my $file (@files) |
110
|
|
|
|
|
|
|
{ |
111
|
0
|
|
|
|
|
|
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = $self->_run_ipc_cmd( |
112
|
|
|
|
|
|
|
command => [ $rpm, '-qf', $file ], # XXX received with or without versions |
113
|
|
|
|
|
|
|
verbose => 0, ); |
114
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if ($success) |
116
|
|
|
|
|
|
|
{ |
117
|
0
|
|
|
|
|
|
chomp $stdout_buf->[0]; |
118
|
0
|
|
|
|
|
|
push( @{ $file_owners{$file} }, { Package => $stdout_buf->[0] } ); |
|
0
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return %file_owners; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 AUTHOR |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Jens Rehsack, C<< >> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Copyright 2010 Jens Rehsack. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
134
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
135
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |