diff options
author | Lamont Granquist <454857+lamont-granquist@users.noreply.github.com> | 2022-03-01 20:57:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-01 20:57:08 -0800 |
commit | 8efc7212cb8bd3e3b7cc968053fd0dda999aeaea (patch) | |
tree | 4e53637eb99c7541f8f3fdf7eb78b0c0dcc33ee9 | |
parent | 17ae919254f1d26340a4f6847d3849499bc9e9d9 (diff) | |
parent | fa543345c9b53760653417ae220a60112a2dbab0 (diff) | |
download | chef-8efc7212cb8bd3e3b7cc968053fd0dda999aeaea.tar.gz |
Merge pull request #12657 from chef/lcg/yum-fixing
-rw-r--r-- | lib/chef/provider/package/yum/python_helper.rb | 15 | ||||
-rw-r--r-- | spec/functional/resource/dnf_package_spec.rb | 15 | ||||
-rw-r--r-- | spec/functional/resource/yum_package_spec.rb | 15 |
3 files changed, 44 insertions, 1 deletions
diff --git a/lib/chef/provider/package/yum/python_helper.rb b/lib/chef/provider/package/yum/python_helper.rb index bdf22b4ebd..c37daa4dbf 100644 --- a/lib/chef/provider/package/yum/python_helper.rb +++ b/lib/chef/provider/package/yum/python_helper.rb @@ -178,7 +178,20 @@ class Chef # # @api private def combine_args(provides, version, arch) - provides = provides.dup + provides = provides.to_s.strip + version = if !version.nil? && !version.empty? + version.to_s.strip + end + arch = if !arch.nil? && !arch.empty? + arch.to_s.strip + end + if version =~ /^[><=]/ + if arch + return { "provides" => "#{provides}.#{arch} #{version}" } + else + return { "provides" => "#{provides} #{version}" } + end + end maybe_arch = provides.rpartition(".").last if is_arch?(maybe_arch) arch = maybe_arch diff --git a/spec/functional/resource/dnf_package_spec.rb b/spec/functional/resource/dnf_package_spec.rb index 655ae41a85..f3cb35bf93 100644 --- a/spec/functional/resource/dnf_package_spec.rb +++ b/spec/functional/resource/dnf_package_spec.rb @@ -709,6 +709,21 @@ describe Chef::Resource::DnfPackage, :requires_root, external: exclude_test do action :install end.should_not_be_updated end + + it "works with constraints in the version property" do + flush_cache + dnf_package "chef_rpm" do + version ">= 1.10" + options default_options + action :install + end.should_be_updated + expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$") + dnf_package "chef_rpm" do + version ">= 1.10" + options default_options + action :install + end.should_not_be_updated + end end context "with source arguments" do diff --git a/spec/functional/resource/yum_package_spec.rb b/spec/functional/resource/yum_package_spec.rb index 78684b6da3..27912f6d35 100644 --- a/spec/functional/resource/yum_package_spec.rb +++ b/spec/functional/resource/yum_package_spec.rb @@ -754,6 +754,21 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do action :install end.should_not_be_updated end + + it "works with constraints in the version property" do + flush_cache + yum_package "chef_rpm" do + version ">= 1.10" + options default_options + action :install + end.should_be_updated + expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$") + yum_package "chef_rpm" do + version ">= 1.10" + options default_options + action :install + end.should_not_be_updated + end end context "with source arguments" do |