summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package/apt.rb
diff options
context:
space:
mode:
authorAndy Wagner <andy@andywagner.ca>2017-10-12 13:34:31 -0400
committerAndy Wagner <andy@andywagner.ca>2018-01-04 12:55:56 -0500
commit0085fb335b0aca604340df0e76792e58d3dffd63 (patch)
tree92af3603ebed0d74a654debff86c5243eefad0c9 /lib/chef/provider/package/apt.rb
parentc6433605bae0a9f52c843ca8cb97e64b2bcf5f0a (diff)
downloadchef-0085fb335b0aca604340df0e76792e58d3dffd63.tar.gz
Ensure package (un)locking is idempotent
Due to the nature of the comparison done, the `package_locked` methods will always return false as they presume the package name is a string, when it is in fact always coerced into an array. Additionally in situations where the package_name is set rather than being inherited from the package resource's name, it will always return false. Resolves #6361 Resolves #6493 Signed-off-by: Andy Wagner <andy@andywagner.ca>
Diffstat (limited to 'lib/chef/provider/package/apt.rb')
-rw-r--r--lib/chef/provider/package/apt.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb
index 3f32f9d380..9eb8dd736a 100644
--- a/lib/chef/provider/package/apt.rb
+++ b/lib/chef/provider/package/apt.rb
@@ -71,15 +71,11 @@ class Chef
end
def package_locked(name, version)
- islocked = false
locked = shell_out_compact_timeout!("apt-mark", "showhold")
- locked.stdout.each_line do |line|
- line_package = line.strip
- if line_package == name
- islocked = true
- end
+ locked_packages = locked.stdout.each_line.map do |line|
+ line.strip
end
- islocked
+ name.all? { |n| locked_packages.include? n }
end
def install_package(name, version)