| 1 | # | ||||||||||||||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | package Rex::Pkg; | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 32 | ▶ | use v5.14.4; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 32 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 32 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 32 | ▶ | use Rex::Config; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 32 | ▶ | use Rex::Commands::Gather; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 32 | ▶ | use Rex::Hardware; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 32 | ▶ | use Rex::Hardware::Host; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | 32 | ▶ | use Rex::Logger; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 32 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 32 | my %PKG_PROVIDER; | |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub register_package_provider { | ||||||||||||||||||||||||||||||
|
Subroutine
register_package_provider: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 23 | 0 | my ( $class, $service_name, $service_class ) = @_; | |||||||||||||||||||||||||||||||
| 24 | 0 | $PKG_PROVIDER{"\L$service_name"} = $service_class; | |||||||||||||||||||||||||||||||
| 25 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 0 | my %_host = %{ Rex::Hardware::Host->get() }; | |||||||||||||||||||||||||||||||
| 33 | 0 | my $host = {%_host}; | |||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $pkg_provider_for = Rex::Config->get("package_provider") || {}; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
'Rex::Config'->get('package_provider') || {}
MC/DC0%0/1
'Rex::Config'->get('package_provider') || {}
'Rex::Config'->get('package_provider')
Truth table0%0/2
A
A= 'Rex::Config'->get('package_provider')
| |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | #if(lc($host->{"operatingsystem"}) eq "centos" || lc($host->{"operatingsystem"}) eq "redhat") { | ||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ( is_redhat() ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 39 | 0 | $host->{"operatingsystem"} = "Redhat"; | |||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ( is_debian() ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 43 | 0 | $host->{"operatingsystem"} = "Debian"; | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 0 | my $class = "Rex::Pkg::" . $host->{"operatingsystem"}; | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 0 | my $provider; | |||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ( ref($pkg_provider_for) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $pkg_provider_for and exists $$pkg_provider_for{$host->{"operatingsystem"}}
MC/DC0%0/2
ref $pkg_provider_for and exists $$pkg_provider_for{$host->{"operatingsystem"}}
ref $pkg_provider_for
exists $$pkg_provider_for{$host->{"operatingsystem"}}
Truth table0%0/3
A and B
A= ref $pkg_provider_forB= exists $$pkg_provider_for{$host->{"operatingsystem"}}
| |||||||||||||||||||||||||||||||||
| 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 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ($provider) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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 | 32 | 1; | |||||||||||||||||||||||||||||||