# class Chef::Provider::Package::SmartOS

### Attributes

is_virtual_package[RW]

### Public Instance Methods

candidate_version() click to toggle source

    # File lib/chef/provider/package/smartos.rb, line 60
    def candidate_version
      return @candidate_version if @candidate_version
      name = nil
      version = nil
      pkg = shell_out!("/opt/local/bin/pkgin se #{new_resource.package_name}", :env => nil, :returns => [0,1])
      pkg.stdout.each_line do |line|
        case line
        when /^#{new_resource.package_name}/
          name, version = line.split[0].split(/-([^-]+)$/)
        end
      end
      @candidate_version = version
      version
    end

check_package_state(name) click to toggle source

    # File lib/chef/provider/package/smartos.rb, line 44
    def check_package_state(name)
      Chef::Log.debug("#{@new_resource} checking package #{name}")
      version = nil
      info = shell_out!("/opt/local/sbin/pkg_info -E \"#{name}*\"", :env => nil, :returns => [0,1])

      if info.stdout
        version = info.stdout[/^#{@new_resource.package_name}-(.+)/, 1]
      end

      if !version
        @current_resource.version(nil)
      else
        @current_resource.version(version)
      end
    end

install_package(name, version) click to toggle source

    # File lib/chef/provider/package/smartos.rb, line 75
    def install_package(name, version)
      Chef::Log.debug("#{@new_resource} installing package #{name} version #{version}")
      package = "#{name}-#{version}"
      out = shell_out!("/opt/local/bin/pkgin -y install #{package}", :env => nil)
    end

load_current_resource() click to toggle source

    # File lib/chef/provider/package/smartos.rb, line 35
    def load_current_resource
      Chef::Log.debug("#{@new_resource} loading current resource")
      @current_resource = Chef::Resource::Package.new(@new_resource.name)
      @current_resource.package_name(@new_resource.package_name)
      @current_resource.version(nil)
      check_package_state(@new_resource.package_name)
      @current_resource # modified by check_package_state
    end

remove_package(name, version) click to toggle source

    # File lib/chef/provider/package/smartos.rb, line 86
    def remove_package(name, version)
      Chef::Log.debug("#{@new_resource} removing package #{name} version #{version}")
      package = "#{name}"
      out = shell_out!("/opt/local/bin/pkgin -y remove #{package}", :env => nil)
    end

upgrade_package(name, version) click to toggle source

    # File lib/chef/provider/package/smartos.rb, line 81
    def upgrade_package(name, version)
      Chef::Log.debug("#{@new_resource} upgrading package #{name} version #{version}")
      install_package(name, version)
    end