Sha256: e786e361ba474d9b2fbb6504220f5c8122c9dbbb9154b3992c3bb2a4d14cd3a5

Contents?: true

Size: 1.34 KB

Versions: 53

Compression:

Stored size: 1.34 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

53 entries across 53 versions & 2 rubygems

Version Path
puppet-5.3.7 lib/puppet/provider/package/apple.rb
puppet-5.3.7-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-5.3.7-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-5.3.7-universal-darwin lib/puppet/provider/package/apple.rb
puppet-5.3.6 lib/puppet/provider/package/apple.rb
puppet-5.3.6-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-5.3.6-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-5.3.6-universal-darwin lib/puppet/provider/package/apple.rb
puppet-5.3.5 lib/puppet/provider/package/apple.rb
puppet-5.3.5-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-5.3.5-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-5.3.5-universal-darwin lib/puppet/provider/package/apple.rb
puppet-5.3.4 lib/puppet/provider/package/apple.rb
puppet-5.3.4-x86-mingw32 lib/puppet/provider/package/apple.rb
puppet-5.3.4-x64-mingw32 lib/puppet/provider/package/apple.rb
puppet-5.3.4-universal-darwin lib/puppet/provider/package/apple.rb
bolt-0.11.0 vendored/puppet/lib/puppet/provider/package/apple.rb
bolt-0.10.0 vendored/puppet/lib/puppet/provider/package/apple.rb
bolt-0.9.0 vendored/puppet/lib/puppet/provider/package/apple.rb
bolt-0.8.0 vendored/puppet/lib/puppet/provider/package/apple.rb