diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-11 19:47:12 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-11 19:47:12 -0700 |
commit | fc9d8d52b517041e469969e41e22bd1ec90bbc09 (patch) | |
tree | c765d658176287124046775c5bbbb1cb7eb62c65 | |
parent | f400002d1a68b8ee672dea92ddfc6ff15624d9d2 (diff) | |
download | chef-fc9d8d52b517041e469969e41e22bd1ec90bbc09.tar.gz |
Yum was failing to install packages when a source was provided
This fixes #3059
The package provider was expecting that candidate_versions be
populated, however in the case where a source was being provided,
it the version was being set to nil.
-rw-r--r-- | lib/chef/provider/package/yum.rb | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 2dbda60750..49c6f6beb5 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -718,7 +718,6 @@ class Chef one_line = true line.chomp! - if line =~ %r{\[option (.*)\] (.*)} if $1 == "installonlypkgs" @allow_multi_install = $2.split @@ -1068,6 +1067,8 @@ class Chef @current_resource = Chef::Resource::Package.new(@new_resource.name) @current_resource.package_name(@new_resource.package_name) + installed_version = [] + @candidate_version = [] if @new_resource.source unless ::File.exists?(@new_resource.source) raise Chef::Exceptions::Package, "Package #{@new_resource.name} not found: #{@new_resource.source}" @@ -1081,22 +1082,24 @@ class Chef @new_resource.version($2) end end - end - - if @new_resource.version - new_resource = "#{@new_resource.package_name}-#{@new_resource.version}#{yum_arch}" + @candidate_version << @new_resource.version + installed_version << @yum.installed_version(@current_resource.package_name, arch) else - new_resource = "#{@new_resource.package_name}#{yum_arch}" - end + if @new_resource.version + new_resource = "#{@new_resource.package_name}-#{@new_resource.version}#{yum_arch}" + else + new_resource = "#{@new_resource.package_name}#{yum_arch}" + end - Chef::Log.debug("#{@new_resource} checking yum info for #{new_resource}") + Chef::Log.debug("#{@new_resource} checking yum info for #{new_resource}") + + package_name_array.each do |pkg| + installed_version << @yum.installed_version(pkg, arch) + @candidate_version << @yum.candidate_version(pkg, arch) + end - installed_version = [] - @candidate_version = [] - package_name_array.each do |pkg| - installed_version << @yum.installed_version(pkg, arch) - @candidate_version << @yum.candidate_version(pkg, arch) end + if installed_version.size == 1 @current_resource.version(installed_version[0]) @candidate_version = @candidate_version[0] |