File Coverage

lib/Rex/Pkg/SunOS/pkg.pm
Criterion Covered Total %
statement 17 38 44.7
branch 0 6 0.0
condition 0 3 0.0
subroutine 6 8 75.0
pod 0 2 0.0
total 23 57 40.3


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Pkg::SunOS::pkg;
6              
7 1     1   14 use v5.12.5;
  1         4  
8 1     1   5 use warnings;
  1         2  
  1         80  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 1     1   9 use Rex::Helper::Run;
  1         2  
  1         74  
13 1     1   7 use Rex::Commands::File;
  1         2  
  1         7  
14 1     1   10 use Rex::Pkg::SunOS;
  1         4  
  1         6  
15              
16 1     1   43 use base qw(Rex::Pkg::SunOS);
  1         2  
  1         347  
17              
18             sub new {
19 0     0 0   my $that = shift;
20 0   0       my $proto = ref($that) || $that;
21 0           my $self = $proto->SUPER::new(@_);
22              
23 0           bless( $self, $proto );
24              
25             $self->{commands} = {
26 0           install => 'pkg install -q --accept %s',
27             install_version => 'pkg install -q --accept %s',
28             remove => 'pkg uninstall -r -q %s',
29             update_package_db => 'pkg refresh',
30             };
31              
32 0           return $self;
33             }
34              
35             sub get_installed {
36 0     0 0   my ($self) = @_;
37              
38 0           my @lines = i_run "pkg info -l";
39              
40 0           my @pkg;
41              
42 0           my ( $version, $name );
43 0           for my $line (@lines) {
44 0 0         if ( $line =~ m/^$/ ) {
45 0           push(
46             @pkg,
47             {
48             name => $name,
49             version => $version,
50             }
51             );
52 0           next;
53             }
54              
55 0 0         if ( $line =~ m/Name: .*\/(.*?)$/ ) {
56 0           $name = $1;
57 0           next;
58             }
59              
60 0 0         if ( $line =~ m/Version: (.*)$/ ) {
61 0           $version = $1;
62 0           next;
63             }
64             }
65              
66 0           return @pkg;
67             }
68              
69             1;