[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
test branch
puppet-dev at googlegroups.com
Wed Jul 14 10:33:00 UTC 2010
The following commit has been merged in the upstream branch:
commit eafde5cacaac79da79d9d1415618801fcc37edcc
Author: Roy Nielsen <rsn at lanl.gov>
Date: Fri Mar 26 13:25:21 2010 -0600
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 at lanl.gov>
diff --git a/lib/puppet/provider/package/pkgdmg.rb b/lib/puppet/provider/package/pkgdmg.rb
index 8a916d5..25edc91 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
diff --git a/spec/unit/provider/package/pkgdmg.rb b/spec/unit/provider/package/pkgdmg.rb
index d437574..3f007e0 100755
--- a/spec/unit/provider/package/pkgdmg.rb
+++ b/spec/unit/provider/package/pkgdmg.rb
@@ -9,8 +9,9 @@ describe provider do
@resource = stub 'resource', :[] => "dummypkgdmg"
@provider = provider.new(@resource)
- @fakemountpoint = "/tmp/dmg.foo"
- @fakehdiutilinfo = {"system-entities" => [{"mount-point" => @fakemountpoint}] }
+ @fakemountpoint = "/tmp/dmg.foo"
+ @fakepkgfile = "/tmp/test.pkg"
+ @fakehdiutilinfo = {"system-entities" => [{"mount-point" => @fakemountpoint}] }
@fakehdiutilplist = Plist::Emit.dump(@fakehdiutilinfo)
@hdiutilmountargs = ["mount", "-plist", "-nobrowse", "-readonly",
@@ -36,8 +37,8 @@ describe provider do
lambda { @provider.install }.should raise_error(Puppet::Error)
end
- it "the source does not end in .dmg" do
- @resource.stubs(:[]).with(:source).returns "notendingindotdmg"
+ it "the source does not end in .dmg or .pkg" do
+ @resource.stubs(:[]).with(:source).returns "notendingindotdmgorpkg"
lambda { @provider.install }.should raise_error(Puppet::Error)
end
@@ -48,7 +49,7 @@ describe provider do
end
# These tests shouldn't be this messy. The pkgdmg provider needs work...
- describe "when installing" do
+ describe "when installing a pkgdmg" do
before do
fh = mock 'filehandle'
fh.stubs(:path).yields "/tmp/foo"
@@ -70,4 +71,14 @@ describe provider do
@provider.install
end
end
+
+ describe "when installing flat pkg file" do
+ it "should call installpkg if a flat pkg file is found instead of a .dmg image" do
+ @resource.stubs(:[]).with(:source).returns "/tmp/test.pkg"
+ @resource.stubs(:[]).with(:name).returns "testpkg"
+ @provider.class.expects(:installpkgdmg).with("#{@fakepkgfile}", "testpkg").returns ""
+ @provider.install
+ end
+ end
+
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list