From 4dc72337aca3a4bf81b37bcea8557ef46636aadc Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 19 Mar 2007 05:21:44 +0000 Subject: Fixing #487. I know use "apt-cache policy", instead of apt-cache showpkg, because it clearly shows which version will be installed. This is basically impossible to test well, so I just added a test that verifies we always get a value back, although I cannot really test that it is the "right" value. Also, I modified the logging of packages so if there is a latest version, you will get the new version number, along with the old, in the log. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2310 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/provider/package/apt.rb | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'lib/puppet/provider') diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index 79a9e5f8e..cf69b4468 100755 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -76,32 +76,13 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg do # What's the latest package version available? def latest - output = aptcache :showpkg, @model[:name] + output = aptcache :policy, @model[:name] - if output =~ /Versions:\s*\n((\n|.)+)^$/ - versions = $1 - available_versions = versions.split(/\n/).collect { |version| - if version =~ /^([^\(]+)\(/ - $1 - else - self.warning "Could not match version '%s'" % version - nil - end - }.reject { |vers| vers.nil? }.sort { |a,b| - versioncmp(a,b) - } - - if available_versions.length == 0 - self.debug "No latest version" - if Puppet[:debug] - print output - end - end - - # Get the latest and greatest version number - return available_versions.pop + if output =~ /\*\*\*\s+(\S+)\s/ + return $1 else - self.err "Could not match string" + self.err "Could not find latest version" + return nil end end -- cgit