line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Pkg; |
6
|
|
|
|
|
|
|
|
7
|
32
|
|
|
32
|
|
503
|
use v5.12.5; |
|
32
|
|
|
|
|
199
|
|
8
|
32
|
|
|
32
|
|
325
|
use warnings; |
|
32
|
|
|
|
|
177
|
|
|
32
|
|
|
|
|
2032
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.14.2.3'; # TRIAL VERSION |
11
|
|
|
|
|
|
|
|
12
|
32
|
|
|
32
|
|
269
|
use Rex::Config; |
|
32
|
|
|
|
|
113
|
|
|
32
|
|
|
|
|
841
|
|
13
|
32
|
|
|
32
|
|
390
|
use Rex::Commands::Gather; |
|
32
|
|
|
|
|
243
|
|
|
32
|
|
|
|
|
421
|
|
14
|
32
|
|
|
32
|
|
527
|
use Rex::Hardware; |
|
32
|
|
|
|
|
95
|
|
|
32
|
|
|
|
|
457
|
|
15
|
32
|
|
|
32
|
|
1710
|
use Rex::Hardware::Host; |
|
32
|
|
|
|
|
151
|
|
|
32
|
|
|
|
|
398
|
|
16
|
32
|
|
|
32
|
|
1110
|
use Rex::Logger; |
|
32
|
|
|
|
|
91
|
|
|
32
|
|
|
|
|
210
|
|
17
|
|
|
|
|
|
|
|
18
|
32
|
|
|
32
|
|
882
|
use Data::Dumper; |
|
32
|
|
|
|
|
105
|
|
|
32
|
|
|
|
|
13199
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %PKG_PROVIDER; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub register_package_provider { |
23
|
0
|
|
|
0
|
0
|
|
my ( $class, $service_name, $service_class ) = @_; |
24
|
0
|
|
|
|
|
|
$PKG_PROVIDER{"\L$service_name"} = $service_class; |
25
|
0
|
|
|
|
|
|
return 1; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub get { |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my %_host = %{ Rex::Hardware::Host->get() }; |
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $host = {%_host}; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
0
|
|
|
|
my $pkg_provider_for = Rex::Config->get("package_provider") || {}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#if(lc($host->{"operatingsystem"}) eq "centos" || lc($host->{"operatingsystem"}) eq "redhat") { |
38
|
0
|
0
|
|
|
|
|
if ( is_redhat() ) { |
39
|
0
|
|
|
|
|
|
$host->{"operatingsystem"} = "Redhat"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ( is_debian() ) { |
43
|
0
|
|
|
|
|
|
$host->{"operatingsystem"} = "Debian"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $class = "Rex::Pkg::" . $host->{"operatingsystem"}; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $provider; |
49
|
0
|
0
|
0
|
|
|
|
if ( ref($pkg_provider_for) |
|
|
0
|
|
|
|
|
|
50
|
|
|
|
|
|
|
&& exists $pkg_provider_for->{ $host->{"operatingsystem"} } ) |
51
|
|
|
|
|
|
|
{ |
52
|
0
|
|
|
|
|
|
$provider = $pkg_provider_for->{ $host->{"operatingsystem"} }; |
53
|
0
|
|
|
|
|
|
$class .= "::$provider"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif ( exists $PKG_PROVIDER{$pkg_provider_for} ) { |
56
|
0
|
|
|
|
|
|
$class = $PKG_PROVIDER{$pkg_provider_for}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
Rex::Logger::debug("Using $class for package management"); |
60
|
0
|
|
|
|
|
|
eval "use $class"; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if ($@) { |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ($provider) { |
65
|
0
|
|
|
|
|
|
Rex::Logger::info( "Provider not supported (" . $provider . ")" ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else { |
68
|
|
|
|
|
|
|
Rex::Logger::info( |
69
|
0
|
|
|
|
|
|
"OS not supported (" . $host->{"operatingsystem"} . ")" ); |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
die("OS/Provider not supported"); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return $class->new; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |