summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-21 06:39:00 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-21 06:39:00 +0000
commitf036778df725e1b328ac6f11b784f8e72ee34261 (patch)
treeb2a9284caedec7888817c3dc6a43f7f833314e8d /lib
parenta232e5c6ef359b600cdbc618a9791f8eda8eb081 (diff)
downloadpuppet-f036778df725e1b328ac6f11b784f8e72ee34261.tar.gz
puppet-f036778df725e1b328ac6f11b784f8e72ee34261.tar.xz
puppet-f036778df725e1b328ac6f11b784f8e72ee34261.zip
Apt-cache was showing more information that I thought, so I had to redo how I was collecting the most recent package version
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@721 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/type/package.rb2
-rwxr-xr-xlib/puppet/type/package/apt.rb28
2 files changed, 21 insertions, 9 deletions
diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb
index 296e8af54..690e2d000 100644
--- a/lib/puppet/type/package.rb
+++ b/lib/puppet/type/package.rb
@@ -37,7 +37,7 @@ module Puppet
if @is == latest
return true
else
- Puppet.debug "latest is %s" % latest
+ Puppet.debug "latest %s is %s" % [@parent.name, latest]
end
when :notinstalled
if @is == :notinstalled
diff --git a/lib/puppet/type/package/apt.rb b/lib/puppet/type/package/apt.rb
index 47887ec8a..9267fbcd8 100755
--- a/lib/puppet/type/package/apt.rb
+++ b/lib/puppet/type/package/apt.rb
@@ -31,22 +31,34 @@ module Puppet
# What's the latest package version available?
def latest
- cmd = "apt-cache show %s" % self.name
+ cmd = "apt-cache showpkg %s" % self.name
output = %x{#{cmd} 2>&1}
unless $? == 0
raise Puppet::PackageError.new(output)
end
- if output =~ /Version: (.+)\n/
- return $1
- else
- Puppet.debug "No version"
- if Puppet[:debug]
- print output
+ if output =~ /Versions:\s*\n((\n|.)+)^$/
+ versions = $1
+ version = versions.split(/\n/).collect { |version|
+ if version =~ /(.+)\(/
+ $1
+ else
+ Puppet.warning "Could not match version '%s'" % version
+ nil
+ end
+ }.reject { |vers| vers.nil? }.sort[-1]
+
+ unless version
+ Puppet.debug "No latest version"
+ if Puppet[:debug]
+ print output
+ end
end
- return nil
+ return version
+ else
+ Puppet.err "Could not match string"
end
end