diff options
author | Jon Cowie <jcowie@chef.io> | 2017-09-13 14:57:15 +0100 |
---|---|---|
committer | Jon Cowie <jcowie@chef.io> | 2017-09-22 12:15:59 +0100 |
commit | a5597127294b65df79dc1b98cefe845e4e36de2b (patch) | |
tree | b2dbbc128ec39206d8934a593f77c91d59184e4a /lib/chef/provider/package/rpm.rb | |
parent | 85957c76e2981fca06c9377a1363a79e1277199d (diff) | |
download | chef-a5597127294b65df79dc1b98cefe845e4e36de2b.tar.gz |
Fixes to package upgrade behaviour
This commit introduces fixes to the behaviour of the various providers of the "package" resource (and subtypes like dnf_package etc) when a more recent version of the package has been installed than that present in an available repository or file source and "action :upgrade" is called against the package.
Currently, a number of package providers will attempt to downgrade a package under this scenario, where the desired action should be to recognise that a more up to date version is already installed and do nothing.
I've introduced a ```version_compare``` method to the package superclass which by default uses ```Gem::Version``` comparison with spaceship-operator semantics to ensure that an upgrade is attempted only when the candidate version is not older than the current version.
Additionally, this commit introduces a method called ```version_equals?``` which is functionally identical to ```target_version_already_installed?``` (and that method now in fact calls ```version_equals?```. This has been done to clarify the purpose and functionality of that method, but since it's a public API, deprecation of the old method name will have to be done more gradually.
Signed-off-by: Jon Cowie <jcowie@chef.io>
Diffstat (limited to 'lib/chef/provider/package/rpm.rb')
-rw-r--r-- | lib/chef/provider/package/rpm.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/chef/provider/package/rpm.rb b/lib/chef/provider/package/rpm.rb index 7ec24f8c24..07617c814e 100644 --- a/lib/chef/provider/package/rpm.rb +++ b/lib/chef/provider/package/rpm.rb @@ -18,6 +18,7 @@ require "chef/provider/package" require "chef/resource/package" require "chef/mixin/get_source_from_package" +require "chef/provider/package/yum/rpm_utils" class Chef class Provider @@ -109,6 +110,10 @@ class Chef private + def version_compare(v1, v2) + Chef::Provider::Package::Yum::RPMVersion.parse(v1) <=> Chef::Provider::Package::Yum::RPMVersion.parse(v2) + end + def uri_scheme?(str) scheme = URI.split(str).first return false unless scheme |