Sha256: 486d4e7cdbe7365ee34f3e0d803b17b329951372f9e7dd2025f86e4516290d1f

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 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 builtin 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 :exists => "/Library/Receipts"
    commands :installer => "/usr/sbin/installer"

    defaultfor :operatingsystem => :darwin

    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
        if FileTest.exists?("/Library/Receipts/#{@resource[:name]}.pkg")
            return {:name => @resource[:name], :ensure => :present}
        else
            return nil
        end
    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

# $Id: apple.rb 2555 2007-06-08 17:20:00Z luke $

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-0.23.0 lib/puppet/provider/package/apple.rb
puppet-0.23.2 lib/puppet/provider/package/apple.rb
puppet-0.23.1 lib/puppet/provider/package/apple.rb