# class Chef::Provider::Package::Zypper

### Public Instance Methods

install_package(name, version) click to toggle source

    # File lib/chef/provider/package/zypper.rb, line 90
    def install_package(name, version)
      zypper_package("install --auto-agree-with-licenses", name, version)
    end

load_current_resource() click to toggle source

    # File lib/chef/provider/package/zypper.rb, line 34
    def load_current_resource
      @current_resource = Chef::Resource::Package.new(@new_resource.name)
      @current_resource.package_name(@new_resource.package_name)

      is_installed=false
      is_out_of_date=false
      version=''
      oud_version=''
      Chef::Log.debug("#{@new_resource} checking zypper")
      status = popen4("zypper --non-interactive info #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
        stdout.each do |line|
          case line
          when /^Version: (.+)$/
            version = $1
            Chef::Log.debug("#{@new_resource} version #{$1}")
          when /^Installed: Yes$/
            is_installed=true
            Chef::Log.debug("#{@new_resource} is installed")

          when /^Installed: No$/
            is_installed=false
            Chef::Log.debug("#{@new_resource} is not installed")
          when /^Status: out-of-date \(version (.+) installed\)$/
            is_out_of_date=true
            oud_version=$1
            Chef::Log.debug("#{@new_resource} out of date version #{$1}")
          end
        end
      end

      if is_installed==false
        @candidate_version=version
        @current_resource.version(nil)
      end

      if is_installed==true
        if is_out_of_date==true
          @current_resource.version(oud_version)
          @candidate_version=version
        else
          @current_resource.version(version)
          @candidate_version=version
        end
      end

      unless status.exitstatus == 0
        raise Chef::Exceptions::Package, "zypper failed - #{status.inspect}!"
      end

      @current_resource
    end

purge_package(name, version) click to toggle source

    # File lib/chef/provider/package/zypper.rb, line 102
    def purge_package(name, version)
      zypper_package("remove --clean-deps", name, version)
    end

remove_package(name, version) click to toggle source

    # File lib/chef/provider/package/zypper.rb, line 98
    def remove_package(name, version)
      zypper_package("remove", name, version)
    end

upgrade_package(name, version) click to toggle source

    # File lib/chef/provider/package/zypper.rb, line 94
    def upgrade_package(name, version)
      install_package(name, version)
    end

zypper_version() click to toggle source

    # File lib/chef/provider/package/zypper.rb, line 86
    def zypper_version()
      %xzypper -V 2>&1`.scan(/\d+/).join(".").to_f
    end