diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-16 18:04:35 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-17 13:58:07 -0800 |
commit | af9b718928a063baac2fc559a3d9b98c25327e01 (patch) | |
tree | e5a2ecca47904df1a4db6483bb89c48030cf72df /lib | |
parent | 4f6fa576a5a46ae9739e1e13fc9f79f1d3c489f8 (diff) | |
download | chef-af9b718928a063baac2fc559a3d9b98c25327e01.tar.gz |
convert is_virtual_package to hash
make this a hash based on name so that when we pass an array of
names to install_package we can look up the right one and do not
have to synchronize arrays.
we should probably convert the arrays in the superclass to hashes
based on name as well.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/package/apt.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb index c960806e8f..c6fb47b5d5 100644 --- a/lib/chef/provider/package/apt.rb +++ b/lib/chef/provider/package/apt.rb @@ -27,8 +27,14 @@ class Chef provides :apt_package, os: "linux" + # return [Hash] mapping of package name to Boolean value attr_accessor :is_virtual_package + def initialize(new_resource, run_context) + super + @is_virtual_package = {} + end + def load_current_resource @current_resource = Chef::Resource::Package.new(@new_resource.name) @current_resource.package_name(@new_resource.package_name) @@ -108,8 +114,11 @@ class Chef end @candidate_version = final_candidate_version @current_resource.version(final_installed_version) - @is_virtual_package = final_virtual - + + [package].flatten.each do |pkg| + @is_virtual_package[pkg] = final_virtual + end + return final_installed.is_a?(Array) ? final_installed.any? : final_installed end @@ -118,7 +127,7 @@ class Chef index = 0 package_name = name.zip(version).map do |x, y| namestr = nil - if @is_virtual_package[index] + if is_virtual_package[name] namestr = x else namestr = "#{x}=#{y}" @@ -128,7 +137,7 @@ class Chef end.join(' ') else package_name = "#{name}=#{version}" - package_name = name if @is_virtual_package + package_name = name if is_virtual_package[name] end run_noninteractive("apt-get -q -y#{expand_options(default_release_options)}#{expand_options(@new_resource.options)} install #{package_name}") end |