summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package/apt.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/provider/package/apt.rb')
-rw-r--r--lib/chef/provider/package/apt.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb
index da86016621..605bbc70eb 100644
--- a/lib/chef/provider/package/apt.rb
+++ b/lib/chef/provider/package/apt.rb
@@ -128,10 +128,15 @@ class Chef
private
def version_compare(v1, v2)
- gem_v1 = v1.gsub(/[_+]/, "+" => "-", "_" => "-") unless v1.nil?
- gem_v2 = v2.gsub(/[_+]/, "+" => "-", "_" => "-") unless v2.nil?
-
- Gem::Version.new(gem_v1) <=> Gem::Version.new(gem_v2)
+ dpkg_v1 = v1 || '0'
+ dpkg_v2 = v2 || '0'
+ if shell_out_compact_timeout("dpkg", "--compare-versions", dpkg_v1, "gt", dpkg_v2).status.success?
+ 1
+ elsif shell_out_compact_timeout("dpkg", "--compare-versions", dpkg_v1, "eq", dpkg_v2).status.success?
+ 0
+ else
+ -1
+ end
end
# Runs command via shell_out with magic environment to disable