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