Sha256: 3f8b22706d8e8c853f3706ee4f19c733bd5c07634b0420f116180fc09a54f7ca

Contents?: true

Size: 1.8 KB

Versions: 313

Compression:

Stored size: 1.8 KB

Contents

Puppet::Type.type(:package).provide :aptrpm, :parent => :rpm, :source => :rpm do
  # Provide sorting functionality
  include Puppet::Util::Package

  desc "Package management via `apt-get` ported to `rpm`."

  has_feature :versionable

  commands :aptget => "apt-get"
  commands :aptcache => "apt-cache"
  commands :rpm => "rpm"

  if command('rpm')
    confine :true => begin
      rpm('-ql', 'rpm')
      rescue Puppet::ExecutionFailure
        false
      else
        true
      end
  end

  # Install a package using 'apt-get'.  This function needs to support
  # installing a specific version.
  def install
    should = @resource.should(:ensure)

    str = @resource[:name]
    case should
    when true, false, Symbol
      # pass
    else
      # Add the package version
      str += "=#{should}"
    end
    cmd = %w{-q -y}

    cmd << 'install' << str

    aptget(*cmd)
  end

  # What's the latest package version available?
  def latest
    output = aptcache :showpkg,  @resource[:name]

    if output =~ /Versions:\s*\n((\n|.)+)^$/
      versions = $1
      available_versions = versions.split(/\n/).collect { |version|
        if version =~ /^([^\(]+)\(/
          $1
        else
          self.warning "Could not match version '#{version}'"
          nil
        end
      }.reject { |vers| vers.nil? }.sort { |a,b|
        versioncmp(a,b)
      }

      if available_versions.length == 0
        self.debug "No latest version"
        print output if Puppet[:debug]
      end

      # Get the latest and greatest version number
      return available_versions.pop
    else
      self.err "Could not match string"
    end
  end

  def update
    self.install
  end

  def uninstall
    aptget "-y", "-q", 'remove', @resource[:name]
  end

  def purge
    aptget '-y', '-q', 'remove', '--purge', @resource[:name]
  end
end

Version data entries

313 entries across 313 versions & 5 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/provider/package/aptrpm.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/provider/package/aptrpm.rb
puppet-4.10.12 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.12-x86-mingw32 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.12-x64-mingw32 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.12-universal-darwin lib/puppet/provider/package/aptrpm.rb
puppet-4.10.11 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.11-x86-mingw32 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.11-x64-mingw32 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.11-universal-darwin lib/puppet/provider/package/aptrpm.rb
puppet-4.10.10 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.10-x86-mingw32 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.10-x64-mingw32 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.10-universal-darwin lib/puppet/provider/package/aptrpm.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/provider/package/aptrpm.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/provider/package/aptrpm.rb
puppet-4.10.9 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.9-x86-mingw32 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.9-x64-mingw32 lib/puppet/provider/package/aptrpm.rb
puppet-4.10.9-universal-darwin lib/puppet/provider/package/aptrpm.rb