# File lib/puppet/provider/package/pkgdmg.rb, line 73
 73:   def self.installpkgdmg(source, name)
 74:     unless source =~ /\.dmg$/i || source =~ /\.pkg$/i
 75:       raise Puppet::Error.new("Mac OS X PKG DMG's must specificy a source string ending in .dmg or flat .pkg file")
 76:     end
 77:     require 'open-uri'
 78:     cached_source = source
 79:     if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
 80:       cached_source = "/tmp/#{name}"
 81:       begin
 82:         curl "-o", cached_source, "-C", "-", "-k", "-s", "--url", source
 83:         Puppet.debug "Success: curl transfered [#{name}]"
 84:       rescue Puppet::ExecutionFailure
 85:         Puppet.debug "curl did not transfer [#{name}].  Falling back to slower open-uri transfer methods."
 86:         cached_source = source
 87:       end
 88:     end
 89: 
 90:     begin
 91:       if source =~ /\.dmg$/i
 92:         File.open(cached_source) do |dmg|
 93:           xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", dmg.path
 94:           hdiutil_info = Plist::parse_xml(xml_str)
 95:           raise Puppet::Error.new("No disk entities returned by mount at #{dmg.path}") unless hdiutil_info.has_key?("system-entities")
 96:           mounts = hdiutil_info["system-entities"].collect { |entity|
 97:             entity["mount-point"]
 98:           }.compact
 99:           begin
100:             mounts.each do |mountpoint|
101:               Dir.entries(mountpoint).select { |f|
102:                 f =~ /\.m{0,1}pkg$/i
103:               }.each do |pkg|
104:                 installpkg("#{mountpoint}/#{pkg}", name, source)
105:               end
106:             end
107:           ensure
108:             mounts.each do |mountpoint|
109:               hdiutil "eject", mountpoint
110:             end
111:           end
112:         end
113:       elsif source =~ /\.pkg$/i
114:         installpkg(cached_source, name, source)
115:       else
116:         raise Puppet::Error.new("Mac OS X PKG DMG's must specificy a source string ending in .dmg or flat .pkg file")
117:       end
118:     ensure
119:       # JJM Remove the file if open-uri didn't already do so.
120:       File.unlink(cached_source) if File.exist?(cached_source)
121:     end
122:   end