Sha256: 9ce7d1b2b1b9f1426e271b9addd884da53fff7ceb35622c2e4f89b5157e24b01

Contents?: true

Size: 1.35 KB

Versions: 120

Compression:

Stored size: 1.35 KB

Contents

require_relative '../../../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 = @resource[:source]
    unless source
      self.fail _("Mac OS X packages must specify a package source")
    end

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

Version data entries

120 entries across 120 versions & 1 rubygems

Version Path
puppet-7.34.0 lib/puppet/provider/package/apple.rb
puppet-7.34.0-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.34.0-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.34.0-universal-darwin lib/puppet/provider/package/apple.rb
puppet-7.33.0 lib/puppet/provider/package/apple.rb
puppet-7.33.0-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.33.0-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.33.0-universal-darwin lib/puppet/provider/package/apple.rb
puppet-7.32.1 lib/puppet/provider/package/apple.rb
puppet-7.32.1-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.32.1-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.32.1-universal-darwin lib/puppet/provider/package/apple.rb
puppet-7.31.0 lib/puppet/provider/package/apple.rb
puppet-7.31.0-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.31.0-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.31.0-universal-darwin lib/puppet/provider/package/apple.rb
puppet-7.30.0 lib/puppet/provider/package/apple.rb
puppet-7.30.0-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.30.0-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-7.30.0-universal-darwin lib/puppet/provider/package/apple.rb