line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
235883
|
use 5.006; # our |
|
2
|
|
|
|
|
8
|
|
2
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
3
|
2
|
|
|
2
|
|
42
|
use warnings; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
197
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Gentoo::App::PerlInfo; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: gather systems perl info |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
1253
|
use Term::ANSIColor 2.01 qw( colored colorstrip ); |
|
2
|
|
|
|
|
12386
|
|
|
2
|
|
|
|
|
896
|
|
14
|
2
|
|
|
2
|
|
1165
|
use PortageXS v0.3.0; |
|
2
|
|
|
|
|
217255
|
|
|
2
|
|
|
|
|
76
|
|
15
|
2
|
|
|
2
|
|
19
|
use Path::Tiny qw( path ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
91
|
|
16
|
2
|
|
|
2
|
|
442
|
use Digest::SHA1 qw( sha1_hex ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Config qw( %Config ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
|
|
|
|
|
|
my ( $class, @args ) = @_; |
21
|
|
|
|
|
|
|
my $config = { ref $args[0] ? %{ $args[0] } : @args }; |
22
|
|
|
|
|
|
|
my $self = bless $config, $class; |
23
|
|
|
|
|
|
|
$self->{config_vars} = [ $self->default_config_vars ] |
24
|
|
|
|
|
|
|
unless exists $self->{config_vars}; |
25
|
|
|
|
|
|
|
$self->{_pxs} = PortageXS->new() unless exists $self->{_pxs}; |
26
|
|
|
|
|
|
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new_with_args { |
30
|
|
|
|
|
|
|
my ( $class, @args ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# TODO: Handle options here. |
33
|
|
|
|
|
|
|
return $class->new(); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub default_config_vars { |
37
|
|
|
|
|
|
|
qw(osname osvers archname uname useposix usethreads use5005threads |
38
|
|
|
|
|
|
|
useithreads usemultiplicity useperlio uselargefiles usesocks use64bitint |
39
|
|
|
|
|
|
|
use64bitall uselongdouble usemymalloc bincompat5005 cc ccflags optimize |
40
|
|
|
|
|
|
|
cppflags ccversion gccversion gccosandver intsize longsize ptrsize doublesize |
41
|
|
|
|
|
|
|
byteorder d_longlong longlongsize d_longdbl longdblsize ivtype ivsize nvtype |
42
|
|
|
|
|
|
|
nvsize Off_t lseeksize alignbytes prototype ld ldflags libpth libs perllibs |
43
|
|
|
|
|
|
|
libc so useshrplib libperl gnulibc_version dlsrc dlext d_dlsymun ccdlflags |
44
|
|
|
|
|
|
|
cccdlflags lddlflags); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub package_installed { |
48
|
|
|
|
|
|
|
my ( $self, $name ) = @_; |
49
|
|
|
|
|
|
|
my (@results) = $self->_pxs->searchInstalledPackage($name); |
50
|
|
|
|
|
|
|
if ( not @results ) { |
51
|
|
|
|
|
|
|
return 'not installed'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
return sprintf q[%s %s], $results[0], $self->use_for( $results[0] ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub use_for { |
57
|
|
|
|
|
|
|
my ( $self, $name ) = @_; |
58
|
|
|
|
|
|
|
my (@use) = $self->_pxs->getUseSettingsOfInstalledPackage($name); |
59
|
|
|
|
|
|
|
return sprintf q[USE="%s"], join q[ ], @use; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub eclass_desc { |
63
|
|
|
|
|
|
|
my ( $self, $eclassName ) = @_; |
64
|
|
|
|
|
|
|
my $eclass = path( $self->_pxs->portdir(), "eclass", "$eclassName.eclass" ); |
65
|
|
|
|
|
|
|
if ( !-e $eclass ) { |
66
|
|
|
|
|
|
|
return "does not exist"; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
my $content = $eclass->slurp(); |
69
|
|
|
|
|
|
|
my @parts; |
70
|
|
|
|
|
|
|
if ( $content =~ /\A\s*#\s*Copyright\s*\d+-(\d+)\s*Gentoo\s*Foundation/ ) { |
71
|
|
|
|
|
|
|
push @parts, sprintf q[year: %4s], $1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
unshift @parts, sprintf q[sha1: %36s], sha1_hex($content); |
74
|
|
|
|
|
|
|
return join q[ ], @parts; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _pxs { $_[0]->{_pxs} } |
78
|
|
|
|
|
|
|
sub config_vars { $_[0]->{config_vars} } |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub check_env { |
81
|
|
|
|
|
|
|
die "PORTDIR not set or incorrect! Aborting.." if !-d $_[0]->_pxs->portdir; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub run { |
85
|
|
|
|
|
|
|
$_[0]->_print_header; |
86
|
|
|
|
|
|
|
$_[0]->check_env; |
87
|
|
|
|
|
|
|
$_[0]->_print_section_label('Systeminfo'); |
88
|
|
|
|
|
|
|
$_[0]->_print_system_info; |
89
|
|
|
|
|
|
|
$_[0]->_print_section_label('Perl configuration'); |
90
|
|
|
|
|
|
|
$_[0]->_print_perl_config; |
91
|
|
|
|
|
|
|
$_[0]->_print_section_label('INC'); |
92
|
|
|
|
|
|
|
$_[0]->_print_inc; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
for my $this_category ( $_[0]->_pxs->getPortageXScategorylist('perl') ) { |
95
|
|
|
|
|
|
|
$_[0]->_print_section_label( |
96
|
|
|
|
|
|
|
"Installed packages from category " . $this_category ); |
97
|
|
|
|
|
|
|
$_[0]->_print_category_contents( $this_category, |
98
|
|
|
|
|
|
|
$_[0]->_pxs->searchInstalledPackage( $this_category . "/*" ) ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
$_[0]->_print_section_label("Installed virtuals with perl- prefix"); |
101
|
|
|
|
|
|
|
$_[0]->_print_category_contents( 'virtual', |
102
|
|
|
|
|
|
|
$_[0]->_pxs->searchInstalledPackage("virtual/perl-*") ); |
103
|
|
|
|
|
|
|
$_[0]->_print_section_label('eclasses'); |
104
|
|
|
|
|
|
|
$_[0]->_print_eclasses; |
105
|
|
|
|
|
|
|
return 0; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _print_header { |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $brand = sprintf "%s version %s -", |
111
|
|
|
|
|
|
|
colored( [ 'green', 'bold' ], 'perl-info' ), $VERSION; |
112
|
|
|
|
|
|
|
my $indent = ' ' x length( colorstrip($brand) ); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
print "\n", |
115
|
|
|
|
|
|
|
"${brand} brought to you by the Gentoo perl-herd-maintainer ;-)\n", |
116
|
|
|
|
|
|
|
"${indent} Distributed under the terms of the GPL-2\n", |
117
|
|
|
|
|
|
|
"\n"; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _print_section_label { |
121
|
|
|
|
|
|
|
my ( $self, $label ) = @_; |
122
|
|
|
|
|
|
|
$self->_pxs->colors->print_ok("$label:\n"); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _print_system_info { |
126
|
|
|
|
|
|
|
my $arch = $_[0]->_pxs->getArch(); |
127
|
|
|
|
|
|
|
my $perl = $_[0]->package_installed('dev-lang/perl'); |
128
|
|
|
|
|
|
|
printf " Arch : %s\n", $arch; |
129
|
|
|
|
|
|
|
printf " Perl : %s\n", $perl; |
130
|
|
|
|
|
|
|
print "\n"; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub _print_perl_config { |
134
|
|
|
|
|
|
|
my $indent = " "; |
135
|
|
|
|
|
|
|
my $max_width = 0; |
136
|
|
|
|
|
|
|
for my $var ( sort @{ $_[0]->config_vars } ) { |
137
|
|
|
|
|
|
|
$max_width = length $var if $max_width < length $var; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
for my $var ( sort @{ $_[0]->config_vars } ) { |
140
|
|
|
|
|
|
|
if ( exists $Config{$var} and defined $Config{$var} ) { |
141
|
|
|
|
|
|
|
printf "$indent%-*s = \"%s\"\n", $max_width, $var, $Config{$var}; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
elsif ( exists $Config{$var} ) { |
144
|
|
|
|
|
|
|
printf "$indent%-*s = undef\n", $max_width, $var; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
else { |
147
|
|
|
|
|
|
|
printf "$indent%-*s does not exist\n", $max_width, $var; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
print "\n"; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _print_category_contents { |
154
|
|
|
|
|
|
|
my $indent = " "; |
155
|
|
|
|
|
|
|
my ( $self, $category_name, @contents ) = @_; |
156
|
|
|
|
|
|
|
if ( not @contents ) { |
157
|
|
|
|
|
|
|
print "${indent}none\n\n"; |
158
|
|
|
|
|
|
|
return; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
for my $package (@contents) { |
161
|
|
|
|
|
|
|
my $label = $package; |
162
|
|
|
|
|
|
|
$label =~ s/\A\Q$category_name\E\///; |
163
|
|
|
|
|
|
|
printf "${indent}%s %s\n", $label, $self->use_for($package); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
print "\n"; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub _print_inc { |
169
|
|
|
|
|
|
|
my $indent = " "; |
170
|
|
|
|
|
|
|
for my $inc (@INC) { |
171
|
|
|
|
|
|
|
printf "$indent%s\n", $inc; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
print "\n"; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub _print_eclasses { |
177
|
|
|
|
|
|
|
my $indent = " "; |
178
|
|
|
|
|
|
|
foreach my $eclassName ( "perl-app", "perl-functions", "perl-module" ) { |
179
|
|
|
|
|
|
|
printf " %15s: %s\n", $eclassName, $_[0]->eclass_desc($eclassName); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
print "\n"; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
__END__ |