diff options
author | Dominic Cleal <dcleal@redhat.com> | 2011-02-20 11:36:19 +0000 |
---|---|---|
committer | Dominic Cleal <dcleal@redhat.com> | 2011-02-20 11:36:19 +0000 |
commit | 8462acd0e8021d7ea11215bee1838d4b4beddbb5 (patch) | |
tree | 18004dfce22c6bf6d82380f4397474953f263b35 | |
parent | c87ec2598700c4e5236452a016f0497ec848cb90 (diff) | |
download | puppet-8462acd0e8021d7ea11215bee1838d4b4beddbb5.tar.gz puppet-8462acd0e8021d7ea11215bee1838d4b4beddbb5.tar.xz puppet-8462acd0e8021d7ea11215bee1838d4b4beddbb5.zip |
* Fix exception on parse failure of pkgutil output
* Fix exception when querying latest version for unknown package
-rwxr-xr-x | lib/puppet/provider/package/pkgutil.rb | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index dacd70a01..f0900dc22 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -37,7 +37,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d if hash[:justme] # The --single option speeds up the execution, because it queries # the package managament system for one package only. - command << ["--single"] + command << "--single" command << hash[:justme] end @@ -51,21 +51,15 @@ 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 = pkgsplit(line) - - # When finding one package, ensure we picked up the package line - # itself, not any pkgutil noise. - next if hash[:justme] and parsed[:name] != hash[:justme] - - parsed + pkgsplit(line) 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] } return list[-1] else - list.reject! { |h| - h[:ensure] == :absent - } + list.reject! { |h| h[:ensure] == :absent } return list end @@ -104,7 +98,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d # Retrieve the version from the current package file. def latest hash = self.class.pkglist(:justme => @resource[:name]) - hash[:avail] + hash[:avail] if hash end def query @@ -115,7 +109,6 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end end - # Remove the old package, and install the new one def update pkguti "-y", "-i", @resource[:name] end |