From: Dominic Cleal <dcl...@redhat.com>
Signed-off-by: Juerg Walz <jw...@pobox.com> --- Local-branch: tickets/master/4258-dev lib/puppet/provider/package/pkgutil.rb | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 4e2c0d9..b9d0ea4 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -10,9 +10,6 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d commands :pkguti => pkguti - # This is so stupid, but then, so is blastwave. - ENV["PAGER"] = "/usr/bin/cat" - def self.extended(mod) unless command(:pkguti) != "pkgutil" raise Puppet::Error, @@ -26,14 +23,15 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end def self.instances(hash = {}) - blastlist(hash).collect do |bhash| + pkglist(hash).collect do |bhash| bhash.delete(:avail) new(bhash) end end - # Turn our blastwave listing into a bunch of hashes. - def self.blastlist(hash) + # Turn our pkgutil -c listing into a bunch of hashes. + # Supports :justme => packagename, which uses the optimised --single arg + def self.pkglist(hash) command = ["-c"] if hash[:justme] @@ -53,7 +51,7 @@ 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 - parsed = blastsplit(line) + parsed = pkgsplit(line) # When finding one package, ensure we picked up the package line # itself, not any pkgutil noise. @@ -74,7 +72,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end # Split the different lines into hashes. - def self.blastsplit(line) + def self.pkgsplit(line) if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ hash = {} hash[:name] = $1 @@ -105,12 +103,12 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d # Retrieve the version from the current package file. def latest - hash = self.class.blastlist(:justme => @resource[:name]) + hash = self.class.pkglist(:justme => @resource[:name]) hash[:avail] end def query - if hash = self.class.blastlist(:justme => @resource[:name]) + if hash = self.class.pkglist(:justme => @resource[:name]) hash else {:ensure => :absent} -- 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.