diff options
| author | Roy Nielsen <rsn@lanl.gov> | 2010-03-26 13:25:21 -0600 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | eafde5cacaac79da79d9d1415618801fcc37edcc (patch) | |
| tree | 5b16f5257095d37af8fe70e49e6e374fe455f614 /lib | |
| parent | c9e3d75951d507059d25b76720d36a8d6d33be65 (diff) | |
| download | puppet-eafde5cacaac79da79d9d1415618801fcc37edcc.tar.gz puppet-eafde5cacaac79da79d9d1415618801fcc37edcc.tar.xz puppet-eafde5cacaac79da79d9d1415618801fcc37edcc.zip | |
Added support for flat packages in the pkgdmg package provider.
Added a test in:
./spec/unit/provider/package/pkgdmg.rb
To test flat package support.
The case where a package is a .pkg bundle, curl will attempt
to download and not work. The "installer" command will then
fail, as the source will be "not found" and the resource will
fail. The puppet run will continue.
Signed-off-by: Roy Nielsen <rsn@lanl.gov>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/provider/package/pkgdmg.rb | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/lib/puppet/provider/package/pkgdmg.rb b/lib/puppet/provider/package/pkgdmg.rb index 8a916d5c4..25edc9109 100644 --- a/lib/puppet/provider/package/pkgdmg.rb +++ b/lib/puppet/provider/package/pkgdmg.rb @@ -68,8 +68,8 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag end def self.installpkgdmg(source, name) - unless source =~ /\.dmg$/i - raise Puppet::Error.new("Mac OS X PKG DMG's must specificy a source string ending in .dmg") + unless source =~ /\.dmg$/i || source =~ /\.pkg$/i + raise Puppet::Error.new("Mac OS X PKG DMG's must specificy a source string ending in .dmg or flat .pkg file") end require 'open-uri' cached_source = source @@ -85,28 +85,34 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag end begin - File.open(cached_source) do |dmg| - xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", dmg.path - hdiutil_info = Plist::parse_xml(xml_str) - unless hdiutil_info.has_key?("system-entities") - raise Puppet::Error.new("No disk entities returned by mount at %s" % dmg.path) - end - mounts = hdiutil_info["system-entities"].collect { |entity| - entity["mount-point"] - }.compact - begin - mounts.each do |mountpoint| - Dir.entries(mountpoint).select { |f| - f =~ /\.m{0,1}pkg$/i - }.each do |pkg| - installpkg("#{mountpoint}/#{pkg}", name, source) - end + if source =~ /\.dmg$/i + File.open(cached_source) do |dmg| + xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", dmg.path + hdiutil_info = Plist::parse_xml(xml_str) + unless hdiutil_info.has_key?("system-entities") + raise Puppet::Error.new("No disk entities returned by mount at %s" % dmg.path) end - ensure - mounts.each do |mountpoint| - hdiutil "eject", mountpoint + mounts = hdiutil_info["system-entities"].collect { |entity| + entity["mount-point"] + }.compact + begin + mounts.each do |mountpoint| + Dir.entries(mountpoint).select { |f| + f =~ /\.m{0,1}pkg$/i + }.each do |pkg| + installpkg("#{mountpoint}/#{pkg}", name, source) + end + end + ensure + mounts.each do |mountpoint| + hdiutil "eject", mountpoint + end end end + elsif source =~ /\.pkg$/i + installpkg(cached_source, name, source) + else + raise Puppet::Error.new("Mac OS X PKG DMG's must specificy a source string ending in .dmg or flat .pkg file") end ensure # JJM Remove the file if open-uri didn't already do so. @@ -116,6 +122,7 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag def query if FileTest.exists?("/var/db/.puppet_pkgdmg_installed_#{@resource[:name]}") + Puppet.debug "/var/db/.puppet_pkgdmg_installed_#{@resource[:name]} found" return {:name => @resource[:name], :ensure => :present} else return nil |
