Several enhancements and bug-fixes for the pkgutil package provider: - handle "Not in catalog" - fix "SAME" version detection - allow short package name (w/o CSW) to match (-> no need to specify a different package name for different operating systems, ex. "ruby") - use the "-u" command line switch for updates
Signed-off-by: Juerg Walz <jw...@pobox.com> --- Local-branch: tickets/master/4258-dev lib/puppet/provider/package/pkgutil.rb | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index f0900dc..0e2056b 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -51,12 +51,12 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d next if line =~ /^=+> / # catalog fetch next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q - pkgsplit(line) + pkgsplit(line, hash[:justme]) end.reject { |h| h.nil? } if hash[:justme] # Ensure we picked up the package line, not any pkgutil noise. - list.reject! { |h| h[:name] != hash[:justme] } + list.reject! { |h| h[:name] !~ /#{hash[:justme]}$/ } return list[-1] else list.reject! { |h| h[:ensure] == :absent } @@ -66,8 +66,11 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end # Split the different lines into hashes. - def self.pkgsplit(line) - if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ + def self.pkgsplit(line, justme) + if line == "Not in catalog" + Puppet.warning "Package not in pkgutil catalog: %s" % justme + return nil + elsif line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ hash = {} hash[:name] = $1 hash[:ensure] = if $2 == "notinst" @@ -77,7 +80,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end hash[:avail] = $3 - if hash[:avail] == "SAME" + if hash[:avail] =~ /^SAME\s*$/ hash[:avail] = hash[:ensure] end @@ -110,7 +113,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end def update - pkguti "-y", "-i", @resource[:name] + pkguti "-y", "-u", @resource[:name] end def uninstall -- 1.7.3.2 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.