summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-02-02 12:56:48 -0800
committerGitHub <noreply@github.com>2021-02-02 12:56:48 -0800
commit2c203bc41cb6fbd1659dcb12fd506c5d3b31564c (patch)
tree039eccc4854b98738ff744f77bd37111ea6dfa93
parentf3d2f8c09c70eae8950a044a92ee560028b2aa7b (diff)
parent7a876de6abbd5fe7362f7544974392192845f32d (diff)
downloadchef-2c203bc41cb6fbd1659dcb12fd506c5d3b31564c.tar.gz
Merge pull request #10969 from chef/dnf
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/package.rb4
-rw-r--r--lib/chef/provider/package/dnf/dnf_helper.py2
-rw-r--r--spec/unit/provider/package/dnf/python_helper_spec.rb8
3 files changed, 10 insertions, 4 deletions
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 198286c75f..b024075f08 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -446,8 +446,8 @@ class Chef
# requested new_resource.version constraints
logger.trace("#{new_resource} has no existing installed version. Installing install #{candidate_version}")
target_version_array.push(candidate_version)
- elsif version_equals?(current_version, new_version)
- # this is a short-circuit to avoid needing to (expensively) query the candidate_version which must come later
+ elsif !use_magic_version? && version_equals?(current_version, new_version)
+ # this is a short-circuit (mostly for the rubygems provider) to avoid needing to expensively query the candidate_version which must come later
logger.trace("#{new_resource} #{package_name} #{new_version} is already installed")
target_version_array.push(nil)
elsif candidate_version.nil?
diff --git a/lib/chef/provider/package/dnf/dnf_helper.py b/lib/chef/provider/package/dnf/dnf_helper.py
index 1dc797a643..325ce14041 100644
--- a/lib/chef/provider/package/dnf/dnf_helper.py
+++ b/lib/chef/provider/package/dnf/dnf_helper.py
@@ -64,7 +64,7 @@ def version_tuple(versionstr):
tmp = versionstr[colon_index + 1:dash_index]
if tmp != '':
v = tmp
- arch_index = versionstr.find('.', dash_index)
+ arch_index = versionstr.rfind('.', dash_index)
if arch_index > 0:
r = versionstr[dash_index + 1:arch_index]
else:
diff --git a/spec/unit/provider/package/dnf/python_helper_spec.rb b/spec/unit/provider/package/dnf/python_helper_spec.rb
index 1f94147273..197af4ead6 100644
--- a/spec/unit/provider/package/dnf/python_helper_spec.rb
+++ b/spec/unit/provider/package/dnf/python_helper_spec.rb
@@ -19,11 +19,17 @@ require "spec_helper"
# NOTE: most of the tests of this functionality are baked into the func tests for the dnf package provider
-describe Chef::Provider::Package::Dnf::PythonHelper do
+# run this test only for following platforms.
+exclude_test = !(%w{rhel fedora amazon}.include?(ohai[:platform_family]) && File.exist?("/usr/bin/dnf"))
+describe Chef::Provider::Package::Dnf::PythonHelper, :requires_root, external: exclude_test do
let(:helper) { Chef::Provider::Package::Dnf::PythonHelper.instance }
it "propagates stacktraces on stderr from the forked subprocess", :rhel do
allow(helper).to receive(:dnf_command).and_return("ruby -e 'raise \"your hands in the air\"'")
expect { helper.package_query(:whatprovides, "tcpdump") }.to raise_error(/your hands in the air/)
end
+
+ it "compares EVRAs with dots in the release correctly" do
+ expect(helper.compare_versions("0:1.8.29-6.el8.x86_64", "0:1.8.29-6.el8_3.1.x86_64")).to eql(-1)
+ end
end