diff options
author | Thom May <thom@chef.io> | 2015-06-06 14:58:17 +0200 |
---|---|---|
committer | Thom May <thom@chef.io> | 2015-08-12 15:30:06 +0100 |
commit | 062dad8a42669e2b90c54d0a32511dbd01842a38 (patch) | |
tree | 73f0d90adf8169fb6aba9e1b8c5a3d1b3ded490d /lib/chef/provider/package | |
parent | 2999d552880ff8fe2d056f89205114ab7c3c9979 (diff) | |
download | chef-062dad8a42669e2b90c54d0a32511dbd01842a38.tar.gz |
Use the output of dpkg-deb directly, rather than regextm/use-dpkg-deb
Thanks to @kwilczynski for the original implementation
Diffstat (limited to 'lib/chef/provider/package')
-rw-r--r-- | lib/chef/provider/package/dpkg.rb | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb index a262f1ab1a..67e9b903c6 100644 --- a/lib/chef/provider/package/dpkg.rb +++ b/lib/chef/provider/package/dpkg.rb @@ -25,8 +25,6 @@ class Chef class Provider class Package class Dpkg < Chef::Provider::Package - # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version - DPKG_INFO = /([a-z\d\-\+\.]+)\t([\w\d.~:-]+)/ DPKG_INSTALLED = /^Status: install ok installed/ DPKG_VERSION = /^Version: (.+)$/ @@ -54,26 +52,22 @@ class Chef @source_exists = true @current_resource = Chef::Resource::Package.new(@new_resource.name) @current_resource.package_name(@new_resource.package_name) - @new_resource.version(nil) if @new_resource.source @source_exists = ::File.exists?(@new_resource.source) if @source_exists # Get information from the package if supplied Chef::Log.debug("#{@new_resource} checking dpkg status") - - shell_out_with_timeout("dpkg-deb -W #{@new_resource.source}").stdout.each_line do |line| - if pkginfo = DPKG_INFO.match(line) - @current_resource.package_name(pkginfo[1]) - @new_resource.version(pkginfo[2]) - @candidate_version = pkginfo[2] - end + status = shell_out_with_timeout("dpkg-deb -W #{@new_resource.source}") + pkginfo = status.stdout.split("\t") + unless pkginfo.empty? + @current_resource.package_name(pkginfo[0]) + @candidate_version = pkginfo[1].strip end else # Source provided but not valid means we can't safely do further processing return end - end # Check to see if it is installed |