| 60 | | open(source) do |dmg| |
|---|
| 61 | | cmd = "#{command(:hdiutil)} mount -plist -nobrowse -readonly -mountrandom /tmp #{dmg.path}" |
|---|
| 62 | | IO.popen(cmd) do |pipe| |
|---|
| 63 | | xml_str = pipe.read |
|---|
| 64 | | ptable = Plist::parse_xml xml_str |
|---|
| 65 | | # JJM Filter out all mount-paths into a single array, discard the rest. |
|---|
| 66 | | mounts = ptable['system-entities'].collect { |entity| |
|---|
| 67 | | entity['mount-point'] |
|---|
| 68 | | }.select { |mountloc|; mountloc } |
|---|
| 69 | | mounts.each do |fspath| |
|---|
| 70 | | Dir.entries(fspath).select { |f| |
|---|
| 71 | | f =~ /\.m{0,1}pkg$/i |
|---|
| 72 | | }.each { |pkg| |
|---|
| 73 | | installpkg("#{fspath}/#{pkg}", name, source) |
|---|
| 74 | | } |
|---|
| 75 | | end |
|---|
| 76 | | hdiutil "eject", mounts[0] |
|---|
| | 64 | cached_source = source |
|---|
| | 65 | if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source |
|---|
| | 66 | cached_source = "/tmp/#{name}" |
|---|
| | 67 | begin |
|---|
| | 68 | curl "-o", cached_source, "-C", "-", "-k", "--retry", "3", "--retry-delay", "15", "-s", "--url", source |
|---|
| | 69 | Puppet.debug "Success: curl transfered [#{name}]" |
|---|
| | 70 | rescue Puppet::ExecutionFailure |
|---|
| | 71 | Puppet.debug "curl did not transfer [#{name}]. Falling back to slower open-uri transfer methods." |
|---|
| | 72 | cached_source = source |
|---|
| 79 | | end |
|---|
| | 75 | |
|---|
| | 76 | begin |
|---|
| | 77 | open(cached_source) do |dmg| |
|---|
| | 78 | cmd = "#{command(:hdiutil)} mount -plist -nobrowse -readonly -mountrandom /tmp #{dmg.path}" |
|---|
| | 79 | IO.popen(cmd) do |pipe| |
|---|
| | 80 | xml_str = pipe.read |
|---|
| | 81 | ptable = Plist::parse_xml xml_str |
|---|
| | 82 | # JJM Filter out all mount-paths into a single array, discard the rest. |
|---|
| | 83 | mounts = ptable['system-entities'].collect { |entity| |
|---|
| | 84 | entity['mount-point'] |
|---|
| | 85 | }.select { |mountloc|; mountloc } |
|---|
| | 86 | begin |
|---|
| | 87 | mounts.each do |fspath| |
|---|
| | 88 | Dir.entries(fspath).select { |f| |
|---|
| | 89 | f =~ /\.m{0,1}pkg$/i |
|---|
| | 90 | }.each do |pkg| |
|---|
| | 91 | installpkg("#{fspath}/#{pkg}", name, source) |
|---|
| | 92 | end |
|---|
| | 93 | end # mounts.each do |
|---|
| | 94 | ensure |
|---|
| | 95 | hdiutil "eject", mounts[0] |
|---|
| | 96 | end # begin |
|---|
| | 97 | end # IO.popen() do |
|---|
| | 98 | end # open() do |
|---|
| | 99 | ensure |
|---|
| | 100 | # JJM Remove the file if open-uri didn't already do so. |
|---|
| | 101 | File.unlink(cached_source) if File.exist?(cached_source) |
|---|
| | 102 | end # begin |
|---|
| | 103 | end # def self.installpkgdmg |
|---|