| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alien::Packages::PkgInfo; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1299
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
55
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
45
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use vars qw($VERSION @ISA); |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
833
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Alien::Packages::PkgInfo - handles Sun's pkginfo |
|
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::PkgInfo |
|
22
|
|
|
|
|
|
|
ISA Alien::Packages::Base |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
require File::Spec; |
|
27
|
|
|
|
|
|
|
require IPC::Cmd; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 usable |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Returns true when the commands C and C could be found in |
|
34
|
|
|
|
|
|
|
the path. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my ( $pkginfo, $pkgchk ); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub usable |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
1
|
50
|
|
1
|
1
|
9
|
unless ( defined($pkginfo) ) |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
1
|
|
|
|
|
9
|
$pkginfo = IPC::Cmd::can_run('pkginfo'); |
|
45
|
1
|
|
50
|
|
|
1505
|
$pkginfo ||= ''; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
7
|
unless ( defined($pkgchk) ) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
1
|
|
|
|
|
6
|
$pkgchk = IPC::Cmd::can_run('pkgchk'); |
|
51
|
1
|
|
50
|
|
|
447
|
$pkgchk ||= ''; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
33
|
|
|
11
|
return $pkginfo && $pkgchk; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 list_packages |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns the list of installed packages. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub list_packages |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
|
66
|
0
|
|
|
|
|
|
my @packages; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = |
|
69
|
|
|
|
|
|
|
$self->_run_ipc_cmd( command => [ $pkginfo, '-x' ], |
|
70
|
|
|
|
|
|
|
verbose => 0, ); |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if ($success) |
|
73
|
|
|
|
|
|
|
{ |
|
74
|
0
|
|
|
|
|
|
while ( $stdout_buf->[0] =~ m/(\w+)\s+([^\s].*)\s+(\(\w+\))\s(\d[\d.]+,REV=[^\s]+)/gx ) |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
0
|
|
|
|
|
|
push( |
|
77
|
|
|
|
|
|
|
@packages, |
|
78
|
|
|
|
|
|
|
{ |
|
79
|
|
|
|
|
|
|
Package => $1, |
|
80
|
|
|
|
|
|
|
Version => $4, |
|
81
|
|
|
|
|
|
|
Summary => $2, |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return @packages; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 list_fileowners |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns the packages which have a registered dependency on specified files. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub list_fileowners |
|
97
|
|
|
|
|
|
|
{ |
|
98
|
0
|
|
|
0
|
1
|
|
my ( $self, @files ) = @_; |
|
99
|
0
|
|
|
|
|
|
my %file_owners; |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $tmpfile = |
|
102
|
|
|
|
|
|
|
File::Spec->catfile( File::Spec->tmpdir(), join( "_", qw(alias pkg list fileowner), $$ ) ); |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
foreach my $file (@files) |
|
105
|
|
|
|
|
|
|
{ |
|
106
|
0
|
|
|
|
|
|
my $fh; |
|
107
|
0
|
0
|
|
|
|
|
open( $fh, ">", $tmpfile ) or die "Can't open $tmpfile: $!"; |
|
108
|
0
|
|
|
|
|
|
print $fh "$file\n"; |
|
109
|
0
|
0
|
|
|
|
|
close($fh) or die "Can't close $tmpfile: $!"; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# that seems to fail on OpenSolaris - Solaris 10u8 on sparc64 succeeds |
|
112
|
0
|
|
|
|
|
|
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = |
|
113
|
|
|
|
|
|
|
$self->_run_ipc_cmd( command => [ $pkgchk, '-i', $tmpfile, '-l' ], |
|
114
|
|
|
|
|
|
|
verbose => 0, ); |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
|
if ($success) |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
0
|
|
|
|
|
|
while ( $stdout_buf->[0] =~ |
|
119
|
|
|
|
|
|
|
m/Pathname:\s*(.*?)\n.*Referenced\sby\sthe\sfollowing\spackages:\s+([A-Za-z0-9]+)/xsg |
|
120
|
|
|
|
|
|
|
) |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
0
|
|
|
|
|
|
push( @{ $file_owners{$1} }, { Package => $2 } ); |
|
|
0
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
unlink $tmpfile; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return %file_owners; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Jens Rehsack, C<< >> |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Copyright 2010 Jens Rehsack. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
141
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
142
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |