diff options
author | Tim Smith <tsmith@chef.io> | 2021-01-30 16:22:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-30 16:22:31 -0800 |
commit | c192613dc7b797a109c51be447eb7edebd37b547 (patch) | |
tree | 9d81c0dd61581de4fda74d46587c82c182d51295 | |
parent | 5e67fe2c344c4aa19c4533d336289e62749d379d (diff) | |
parent | 4c80fed7a04a29036723691859b08d2751fd62bb (diff) | |
download | chef-c192613dc7b797a109c51be447eb7edebd37b547.tar.gz |
Merge pull request #10951 from chef/lcg/dnf-fix-tweak
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/provider/package.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/package/dnf/dnf_helper.py | 2 | ||||
-rw-r--r-- | spec/unit/provider/package/dnf/python_helper_spec.rb | 8 |
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 |