# File lib/puppet/provider/package/appdmg.rb, line 51
51:   def self.installpkgdmg(source, name)
52:     unless source =~ /\.dmg$/i
53:       self.fail "Mac OS X PKG DMG's must specificy a source string ending in .dmg"
54:     end
55:     require 'open-uri'
56:     require 'facter/util/plist'
57:     cached_source = source
58:     if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
59:       cached_source = "/tmp/#{name}"
60:       begin
61:         curl "-o", cached_source, "-C", "-", "-k", "-s", "--url", source
62:         Puppet.debug "Success: curl transfered [#{name}]"
63:       rescue Puppet::ExecutionFailure
64:         Puppet.debug "curl did not transfer [#{name}].  Falling back to slower open-uri transfer methods."
65:         cached_source = source
66:       end
67:     end
68: 
69:     begin
70:       open(cached_source) do |dmg|
71:         xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-mountrandom", "/tmp", dmg.path
72:           ptable = Plist::parse_xml xml_str
73:           # JJM Filter out all mount-paths into a single array, discard the rest.
74:           mounts = ptable['system-entities'].collect { |entity|
75:             entity['mount-point']
76:           }.select { |mountloc|; mountloc }
77:           begin
78:             mounts.each do |fspath|
79:               Dir.entries(fspath).select { |f|
80:                 f =~ /\.app$/i
81:               }.each do |pkg|
82:                 installapp("#{fspath}/#{pkg}", name, source)
83:               end
84:             end
85:           ensure
86:             hdiutil "eject", mounts[0]
87:           end
88:       end
89:     ensure
90:       # JJM Remove the file if open-uri didn't already do so.
91:       File.unlink(cached_source) if File.exist?(cached_source)
92:     end
93:   end