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