| 1 | # | ||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Rex::Pkg::SunOS; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use v5.14.4; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | use Rex::Helper::Run; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use Rex::Commands::File; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 1 | ▶ | use Rex::Pkg::Base; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 1 | ▶ | use base qw(Rex::Pkg::Base); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 18 | 0 | my $that = shift; | |||||||||||||||||||
| 19 | 0 | ▶ | my $proto = ref($that) || $that; | ||||||||||||||||||
|
Condition0%0/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||
| 20 | 0 | my $self = $proto->SUPER::new(@_); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | bless( $self, $proto ); | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | $self->{commands} = {}; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | return $self; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | ▶ | sub update { | ||||||||||||||||||
|
Subroutine
update: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||
| 30 | 0 | my ( $self, $pkg, $option ) = @_; | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | ▶ | my $version = $option->{'version'} || ''; | ||||||||||||||||||
|
Condition0%0/2
$option->{'version'} || ''
MC/DC0%0/1
$option->{'version'} || ''
$option->{'version'}
Truth table0%0/2
A
A= $option->{'version'}
| |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | Rex::Logger::debug("Version option not supported."); | |||||||||||||||||||
| 35 | 0 | Rex::Logger::debug("Installing $pkg / $version"); | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | my $cmd = "pkgadd "; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | ▶ | if ( !exists $option->{"source"} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 0 | die("You have to specify the source."); | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | $cmd .= " -a " . $option->{"adminfile"} if ( $option->{"adminfile"} ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 0 | ▶ | $cmd .= " -r " . $option->{"responsefile"} if ( $option->{"responsefile"} ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | $cmd .= " -d " . $option->{"source"}; | |||||||||||||||||||
| 47 | 0 | $cmd .= " -n " . $pkg; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 0 | my $f = i_run( $cmd, fail_ok => 1 ); | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | unless ( $? == 0 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 0 | Rex::Logger::info( "Error installing $pkg.", "warn" ); | |||||||||||||||||||
| 53 | 0 | Rex::Logger::debug($f); | |||||||||||||||||||
| 54 | 0 | die("Error installing $pkg"); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | Rex::Logger::debug("$pkg successfully installed."); | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | return 1; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub remove { | ||||||||||||||||||
|
Subroutine
remove: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 63 | 0 | my ( $self, $pkg, $option ) = @_; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | Rex::Logger::debug("Removing $pkg"); | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | my $cmd = "pkgrm -n "; | |||||||||||||||||||
| 68 | 0 | ▶ | $cmd .= " -a " . $option->{"adminfile"} if ( $option->{"adminfile"} ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 0 | my $f = i_run( $cmd . " $pkg", fail_ok => 1 ); | |||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | unless ( $? == 0 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | 0 | Rex::Logger::info( "Error removing $pkg.", "warn" ); | |||||||||||||||||||
| 74 | 0 | Rex::Logger::debug($f); | |||||||||||||||||||
| 75 | 0 | die("Error removing $pkg"); | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 0 | Rex::Logger::debug("$pkg successfully removed."); | |||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 0 | return 1; | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 0 | ▶ | sub get_installed { | ||||||||||||||||||
|
Subroutine
get_installed: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||
| 84 | 0 | my ($self) = @_; | |||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | my @lines = i_run "pkginfo -l"; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | my ( @pkg, %current ); | |||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 0 | for my $line (@lines) { | |||||||||||||||||||
| 91 | 0 | ▶ | if ( $line =~ m/^$/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | 0 | push( @pkg, {%current} ); | |||||||||||||||||||
| 93 | 0 | next; | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 0 | ▶ | if ( $line =~ m/PKGINST:\s+([^\s]+)/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 97 | 0 | $current{"name"} = $1; | |||||||||||||||||||
| 98 | 0 | next; | |||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | 0 | ▶ | if ( $line =~ m/VERSION:\s+([^\s]+)/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 102 | 0 | my ( $version, $rev ) = split( /,/, $1 ); | |||||||||||||||||||
| 103 | 0 | $current{"version"} = $version; | |||||||||||||||||||
| 104 | 0 | ▶ | $rev =~ s/^REV=// if ($rev); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 105 | 0 | $current{"revision"} = $rev; | |||||||||||||||||||
| 106 | 0 | next; | |||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | 0 | ▶ | if ( $line =~ m/STATUS:\s+(.*?)$/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 110 | 0 | ▶ | $current{"status"} = ( $1 eq "completely installed" ? "installed" : $1 ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 111 | 0 | next; | |||||||||||||||||||
| 112 | } | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | } | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 0 | return @pkg; | |||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | 1 | 1; | |||||||||||||||||||