Sha256: fa79707947245ba905f54a277384754abc4500e896c9b7f6b0aea8695fd1e1ab

Contents?: true

Size: 1.33 KB

Versions: 96

Compression:

Stored size: 1.33 KB

Contents

require 'puppet/provider/package'

# OS X Packaging sucks.  We can install packages, but that's about it.
Puppet::Type.type(:package).provide :apple, :parent => Puppet::Provider::Package do
  desc "Package management based on OS X's built-in packaging system.  This is
    essentially the simplest and least functional package system in existence --
    it only supports installation; no deletion or upgrades.  The provider will
    automatically add the `.pkg` extension, so leave that off when specifying
    the package name."

  confine :operatingsystem => :darwin
  commands :installer => "/usr/sbin/installer"

  def self.instances
    instance_by_name.collect do |name|
      self.new(
        :name     => name,
        :provider => :apple,
        :ensure   => :installed
      )
    end
  end

  def self.instance_by_name
    Dir.entries("/Library/Receipts").find_all { |f|
      f =~ /\.pkg$/
    }.collect { |f|
      name = f.sub(/\.pkg/, '')
      yield name if block_given?

      name
    }
  end

  def query
    Puppet::FileSystem.exist?("/Library/Receipts/#{@resource[:name]}.pkg") ? {:name => @resource[:name], :ensure => :present} : nil
  end

  def install
    source = nil
    unless source = @resource[:source]
      self.fail "Mac OS X packages must specify a package source"
    end

    installer "-pkg", source, "-target", "/"
  end
end

Version data entries

96 entries across 96 versions & 2 rubygems

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