chef 12.18.31-universal-mingw32 → 12.19.33-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -4
  3. data/README.md +12 -13
  4. data/VERSION +1 -1
  5. data/acceptance/Gemfile +4 -4
  6. data/acceptance/Gemfile.lock +70 -69
  7. data/chef-universal-mingw32.gemspec +2 -3
  8. data/chef.gemspec +6 -6
  9. data/lib/chef/api_client.rb +8 -10
  10. data/lib/chef/api_client_v1.rb +9 -11
  11. data/lib/chef/application/apply.rb +8 -10
  12. data/lib/chef/application/client.rb +1 -1
  13. data/lib/chef/application/exit_code.rb +3 -5
  14. data/lib/chef/application/knife.rb +2 -2
  15. data/lib/chef/application/windows_service.rb +29 -30
  16. data/lib/chef/application/windows_service_manager.rb +1 -1
  17. data/lib/chef/audit/audit_event_proxy.rb +2 -2
  18. data/lib/chef/audit/control_group_data.rb +1 -1
  19. data/lib/chef/chef_class.rb +1 -0
  20. data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
  21. data/lib/chef/chef_fs/command_line.rb +15 -16
  22. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
  23. data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
  24. data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
  25. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  26. data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
  27. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
  28. data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
  29. data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
  30. data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
  31. data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
  32. data/lib/chef/chef_fs/file_pattern.rb +2 -2
  33. data/lib/chef/chef_fs/file_system.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
  35. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
  36. data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
  37. data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
  38. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
  39. data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
  40. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
  41. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
  42. data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
  43. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
  44. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
  45. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
  46. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
  47. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
  48. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
  49. data/lib/chef/chef_fs/parallelizer.rb +9 -11
  50. data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
  51. data/lib/chef/cookbook/metadata.rb +26 -26
  52. data/lib/chef/cookbook/syntax_check.rb +1 -1
  53. data/lib/chef/cookbook_version.rb +3 -3
  54. data/lib/chef/data_bag.rb +1 -1
  55. data/lib/chef/data_bag_item.rb +3 -3
  56. data/lib/chef/data_collector.rb +3 -4
  57. data/lib/chef/decorator.rb +1 -1
  58. data/lib/chef/deprecated.rb +30 -0
  59. data/lib/chef/dsl/audit.rb +2 -2
  60. data/lib/chef/dsl/declare_resource.rb +1 -1
  61. data/lib/chef/dsl/platform_introspection.rb +29 -31
  62. data/lib/chef/dsl/reboot_pending.rb +1 -1
  63. data/lib/chef/dsl/resources.rb +6 -8
  64. data/lib/chef/encrypted_data_bag_item.rb +2 -2
  65. data/lib/chef/environment.rb +9 -11
  66. data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
  67. data/lib/chef/exceptions.rb +4 -1
  68. data/lib/chef/file_access_control/unix.rb +14 -14
  69. data/lib/chef/file_access_control/windows.rb +1 -1
  70. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
  71. data/lib/chef/formatters/error_mapper.rb +6 -6
  72. data/lib/chef/http/api_versions.rb +50 -0
  73. data/lib/chef/http/validate_content_length.rb +2 -2
  74. data/lib/chef/json_compat.rb +6 -10
  75. data/lib/chef/key.rb +5 -5
  76. data/lib/chef/knife.rb +4 -4
  77. data/lib/chef/knife/cookbook_site_install.rb +2 -2
  78. data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
  79. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  80. data/lib/chef/knife/core/status_presenter.rb +1 -1
  81. data/lib/chef/knife/core/ui.rb +19 -25
  82. data/lib/chef/knife/data_bag_secret_options.rb +1 -1
  83. data/lib/chef/knife/deps.rb +32 -34
  84. data/lib/chef/knife/help.rb +1 -1
  85. data/lib/chef/knife/list.rb +1 -1
  86. data/lib/chef/knife/search.rb +2 -2
  87. data/lib/chef/knife/ssh.rb +37 -27
  88. data/lib/chef/knife/ssl_check.rb +1 -1
  89. data/lib/chef/knife/user_delete.rb +1 -1
  90. data/lib/chef/mash.rb +1 -1
  91. data/lib/chef/mixin/command.rb +2 -2
  92. data/lib/chef/mixin/create_path.rb +3 -5
  93. data/lib/chef/mixin/from_file.rb +2 -2
  94. data/lib/chef/mixin/get_source_from_package.rb +2 -2
  95. data/lib/chef/mixin/notifying_block.rb +7 -9
  96. data/lib/chef/mixin/params_validate.rb +3 -3
  97. data/lib/chef/mixin/securable.rb +1 -1
  98. data/lib/chef/mixin/shell_out.rb +23 -3
  99. data/lib/chef/mixin/unformatter.rb +2 -2
  100. data/lib/chef/mixin/uris.rb +4 -6
  101. data/lib/chef/mixin/versioned_api.rb +69 -0
  102. data/lib/chef/mixin/which.rb +25 -8
  103. data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
  104. data/lib/chef/mixin/xml_escape.rb +3 -5
  105. data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
  106. data/lib/chef/node.rb +8 -8
  107. data/lib/chef/node/attribute.rb +4 -4
  108. data/lib/chef/node/common_api.rb +5 -7
  109. data/lib/chef/org.rb +10 -12
  110. data/lib/chef/platform/provider_mapping.rb +7 -7
  111. data/lib/chef/platform/query_helpers.rb +1 -1
  112. data/lib/chef/policy_builder/policyfile.rb +1 -0
  113. data/lib/chef/property.rb +31 -0
  114. data/lib/chef/provider/batch.rb +1 -1
  115. data/lib/chef/provider/breakpoint.rb +1 -1
  116. data/lib/chef/provider/cookbook_file.rb +3 -3
  117. data/lib/chef/provider/cron.rb +38 -38
  118. data/lib/chef/provider/deploy.rb +81 -81
  119. data/lib/chef/provider/deploy/revision.rb +3 -5
  120. data/lib/chef/provider/directory.rb +32 -32
  121. data/lib/chef/provider/dsc_resource.rb +22 -6
  122. data/lib/chef/provider/env.rb +28 -28
  123. data/lib/chef/provider/env/windows.rb +1 -1
  124. data/lib/chef/provider/erl_call.rb +13 -13
  125. data/lib/chef/provider/execute.rb +5 -2
  126. data/lib/chef/provider/file.rb +49 -51
  127. data/lib/chef/provider/git.rb +55 -55
  128. data/lib/chef/provider/http_request.rb +36 -36
  129. data/lib/chef/provider/launchd.rb +2 -2
  130. data/lib/chef/provider/link.rb +50 -50
  131. data/lib/chef/provider/log.rb +2 -2
  132. data/lib/chef/provider/mdadm.rb +25 -25
  133. data/lib/chef/provider/mount/aix.rb +2 -2
  134. data/lib/chef/provider/mount/mount.rb +2 -2
  135. data/lib/chef/provider/ohai.rb +1 -1
  136. data/lib/chef/provider/osx_profile.rb +23 -23
  137. data/lib/chef/provider/package.rb +74 -56
  138. data/lib/chef/provider/package/aix.rb +55 -52
  139. data/lib/chef/provider/package/apt.rb +15 -13
  140. data/lib/chef/provider/package/cab.rb +49 -20
  141. data/lib/chef/provider/package/chocolatey.rb +9 -10
  142. data/lib/chef/provider/package/dnf.rb +20 -18
  143. data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
  144. data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
  145. data/lib/chef/provider/package/dnf/version.rb +1 -1
  146. data/lib/chef/provider/package/dpkg.rb +8 -9
  147. data/lib/chef/provider/package/easy_install.rb +22 -22
  148. data/lib/chef/provider/package/freebsd/base.rb +10 -10
  149. data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
  150. data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
  151. data/lib/chef/provider/package/freebsd/port.rb +7 -7
  152. data/lib/chef/provider/package/homebrew.rb +11 -10
  153. data/lib/chef/provider/package/ips.rb +18 -23
  154. data/lib/chef/provider/package/macports.rb +23 -23
  155. data/lib/chef/provider/package/msu.rb +11 -11
  156. data/lib/chef/provider/package/openbsd.rb +25 -22
  157. data/lib/chef/provider/package/pacman.rb +16 -16
  158. data/lib/chef/provider/package/paludis.rb +26 -27
  159. data/lib/chef/provider/package/portage.rb +22 -22
  160. data/lib/chef/provider/package/powershell.rb +17 -17
  161. data/lib/chef/provider/package/rpm.rb +25 -25
  162. data/lib/chef/provider/package/rubygems.rb +60 -60
  163. data/lib/chef/provider/package/smartos.rb +16 -16
  164. data/lib/chef/provider/package/solaris.rb +44 -44
  165. data/lib/chef/provider/package/windows.rb +3 -3
  166. data/lib/chef/provider/package/windows/exe.rb +6 -6
  167. data/lib/chef/provider/package/windows/msi.rb +6 -6
  168. data/lib/chef/provider/package/yum.rb +318 -268
  169. data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
  170. data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
  171. data/lib/chef/provider/package/zypper.rb +11 -11
  172. data/lib/chef/provider/powershell_script.rb +15 -7
  173. data/lib/chef/provider/reboot.rb +10 -10
  174. data/lib/chef/provider/registry_key.rb +39 -39
  175. data/lib/chef/provider/remote_directory.rb +3 -3
  176. data/lib/chef/provider/remote_file.rb +3 -3
  177. data/lib/chef/provider/route.rb +1 -1
  178. data/lib/chef/provider/ruby_block.rb +3 -3
  179. data/lib/chef/provider/script.rb +42 -6
  180. data/lib/chef/provider/service.rb +49 -49
  181. data/lib/chef/provider/service/solaris.rb +1 -1
  182. data/lib/chef/provider/service/systemd.rb +1 -1
  183. data/lib/chef/provider/subversion.rb +39 -39
  184. data/lib/chef/provider/systemd_unit.rb +2 -0
  185. data/lib/chef/provider/template.rb +3 -3
  186. data/lib/chef/provider/user.rb +42 -42
  187. data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
  188. data/lib/chef/resource.rb +27 -16
  189. data/lib/chef/resource/apt_repository.rb +0 -1
  190. data/lib/chef/resource/chef_gem.rb +1 -1
  191. data/lib/chef/resource/dnf_package.rb +6 -3
  192. data/lib/chef/resource/dsc_resource.rb +9 -1
  193. data/lib/chef/resource/execute.rb +70 -6
  194. data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
  195. data/lib/chef/resource/freebsd_package.rb +1 -1
  196. data/lib/chef/resource/gem_package.rb +1 -1
  197. data/lib/chef/resource/launchd.rb +13 -1
  198. data/lib/chef/resource/package.rb +2 -2
  199. data/lib/chef/resource/registry_key.rb +1 -1
  200. data/lib/chef/resource/yum_package.rb +12 -3
  201. data/lib/chef/resource/yum_repository.rb +0 -1
  202. data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
  203. data/lib/chef/resource_collection/resource_set.rb +2 -2
  204. data/lib/chef/resource_reporter.rb +1 -1
  205. data/lib/chef/run_context.rb +3 -3
  206. data/lib/chef/run_list/run_list_item.rb +1 -1
  207. data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
  208. data/lib/chef/server_api.rb +2 -0
  209. data/lib/chef/server_api_versions.rb +40 -0
  210. data/lib/chef/shell.rb +1 -1
  211. data/lib/chef/shell/ext.rb +3 -3
  212. data/lib/chef/shell/shell_session.rb +1 -1
  213. data/lib/chef/user.rb +9 -11
  214. data/lib/chef/user_v1.rb +9 -11
  215. data/lib/chef/util/diff.rb +1 -1
  216. data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
  217. data/lib/chef/util/selinux.rb +1 -1
  218. data/lib/chef/util/windows/net_group.rb +18 -30
  219. data/lib/chef/util/windows/net_use.rb +7 -11
  220. data/lib/chef/util/windows/net_user.rb +11 -17
  221. data/lib/chef/util/windows/volume.rb +9 -15
  222. data/lib/chef/version.rb +1 -1
  223. data/lib/chef/version_class.rb +1 -1
  224. data/lib/chef/win32/api.rb +4 -6
  225. data/lib/chef/win32/api/file.rb +25 -31
  226. data/lib/chef/win32/api/installer.rb +2 -2
  227. data/lib/chef/win32/file.rb +4 -6
  228. data/lib/chef/win32/registry.rb +9 -9
  229. data/lib/chef/win32/security.rb +2 -2
  230. data/lib/chef/win32/security/acl.rb +2 -2
  231. data/lib/chef/win32/unicode.rb +2 -2
  232. data/lib/chef/win32/version.rb +1 -1
  233. data/spec/data/prefer_metadata_json/metadata.json +51 -0
  234. data/spec/data/prefer_metadata_json/metadata.rb +6 -0
  235. data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
  236. data/spec/functional/knife/ssh_spec.rb +5 -5
  237. data/spec/functional/resource/batch_spec.rb +5 -1
  238. data/spec/functional/resource/dsc_script_spec.rb +2 -4
  239. data/spec/functional/resource/execute_spec.rb +17 -0
  240. data/spec/functional/resource/user/dscl_spec.rb +2 -4
  241. data/spec/integration/client/client_spec.rb +33 -0
  242. data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
  243. data/spec/spec_helper.rb +4 -0
  244. data/spec/support/chef_helpers.rb +5 -7
  245. data/spec/support/platform_helpers.rb +6 -0
  246. data/spec/support/platforms/prof/gc.rb +4 -6
  247. data/spec/support/shared/context/client.rb +1 -1
  248. data/spec/support/shared/functional/execute_resource.rb +150 -0
  249. data/spec/support/shared/functional/windows_script.rb +74 -4
  250. data/spec/support/shared/unit/execute_resource.rb +37 -0
  251. data/spec/support/shared/unit/provider/file.rb +10 -0
  252. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
  253. data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
  254. data/spec/unit/http/api_versions_spec.rb +69 -0
  255. data/spec/unit/knife/ssh_spec.rb +34 -36
  256. data/spec/unit/mixin/versioned_api_spec.rb +107 -0
  257. data/spec/unit/mixin/which.rb +160 -0
  258. data/spec/unit/platform_spec.rb +28 -1
  259. data/spec/unit/provider/deploy_spec.rb +1 -1
  260. data/spec/unit/provider/directory_spec.rb +10 -0
  261. data/spec/unit/provider/dsc_resource_spec.rb +175 -0
  262. data/spec/unit/provider/execute_spec.rb +0 -1
  263. data/spec/unit/provider/launchd_spec.rb +2 -2
  264. data/spec/unit/provider/package/aix_spec.rb +22 -22
  265. data/spec/unit/provider/package/apt_spec.rb +27 -27
  266. data/spec/unit/provider/package/cab_spec.rb +59 -5
  267. data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
  268. data/spec/unit/provider/package/dpkg_spec.rb +16 -16
  269. data/spec/unit/provider/package/easy_install_spec.rb +18 -18
  270. data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
  271. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
  272. data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
  273. data/spec/unit/provider/package/homebrew_spec.rb +9 -9
  274. data/spec/unit/provider/package/ips_spec.rb +37 -31
  275. data/spec/unit/provider/package/macports_spec.rb +10 -10
  276. data/spec/unit/provider/package/openbsd_spec.rb +10 -10
  277. data/spec/unit/provider/package/pacman_spec.rb +6 -6
  278. data/spec/unit/provider/package/paludis_spec.rb +7 -7
  279. data/spec/unit/provider/package/portage_spec.rb +6 -7
  280. data/spec/unit/provider/package/rpm_spec.rb +23 -23
  281. data/spec/unit/provider/package/rubygems_spec.rb +38 -38
  282. data/spec/unit/provider/package/solaris_spec.rb +15 -15
  283. data/spec/unit/provider/package/windows_spec.rb +2 -1
  284. data/spec/unit/provider/package/yum_spec.rb +51 -43
  285. data/spec/unit/provider/package/zypper_spec.rb +34 -34
  286. data/spec/unit/provider/package_spec.rb +8 -0
  287. data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
  288. data/spec/unit/provider/route_spec.rb +7 -1
  289. data/spec/unit/provider/script_spec.rb +49 -6
  290. data/spec/unit/resource/dsc_resource_spec.rb +6 -0
  291. data/spec/unit/resource/execute_spec.rb +214 -0
  292. data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
  293. data/spec/unit/resource/freebsd_package_spec.rb +2 -2
  294. data/spec/unit/resource/package_spec.rb +5 -0
  295. data/spec/unit/resource/yum_package_spec.rb +42 -1
  296. data/spec/unit/resource_reporter_spec.rb +1 -1
  297. data/spec/unit/resource_spec.rb +18 -0
  298. data/spec/unit/server_api_versions_spec.rb +44 -0
  299. data/spec/unit/util/selinux_spec.rb +3 -14
  300. data/spec/unit/win32/error_spec.rb +67 -0
  301. data/spec/unit/win32/security_spec.rb +66 -0
  302. data/tasks/changelog.rb +1 -1
  303. data/tasks/dependencies.rb +20 -4
  304. metadata +39 -18
  305. data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
@@ -48,7 +48,7 @@ class Chef
48
48
  name == other.name && version == other.version && arch == other.arch
49
49
  end
50
50
 
51
- alias_method :eql?, :==
51
+ alias eql? ==
52
52
  end
53
53
  end
54
54
  end
@@ -74,17 +74,17 @@ class Chef
74
74
  def install_package(name, version)
75
75
  sources = name.map { |n| name_sources[n] }
76
76
  Chef::Log.info("#{new_resource} installing package(s): #{name.join(' ')}")
77
- run_noninteractive("dpkg -i", new_resource.options, *sources)
77
+ run_noninteractive("dpkg", "-i", *options, *sources)
78
78
  end
79
79
 
80
80
  def remove_package(name, version)
81
81
  Chef::Log.info("#{new_resource} removing package(s): #{name.join(' ')}")
82
- run_noninteractive("dpkg -r", new_resource.options, *name)
82
+ run_noninteractive("dpkg", "-r", *options, *name)
83
83
  end
84
84
 
85
85
  def purge_package(name, version)
86
86
  Chef::Log.info("#{new_resource} purging packages(s): #{name.join(' ')}")
87
- run_noninteractive("dpkg -P", new_resource.options, *name)
87
+ run_noninteractive("dpkg", "-P", *options, *name)
88
88
  end
89
89
 
90
90
  def upgrade_package(name, version)
@@ -102,14 +102,13 @@ class Chef
102
102
  end
103
103
 
104
104
  # Override the superclass check. Multiple sources are required here.
105
- def check_resource_semantics!
106
- end
105
+ def check_resource_semantics!; end
107
106
 
108
107
  private
109
108
 
110
109
  def read_current_version_of_package(package_name)
111
110
  Chef::Log.debug("#{new_resource} checking install state of #{package_name}")
112
- status = shell_out_with_timeout!("dpkg -s #{package_name}", returns: [0, 1])
111
+ status = shell_out_compact_timeout!("dpkg", "-s", package_name, returns: [0, 1])
113
112
  package_installed = false
114
113
  status.stdout.each_line do |line|
115
114
  case line
@@ -125,7 +124,7 @@ class Chef
125
124
  end
126
125
  end
127
126
  end
128
- return nil
127
+ nil
129
128
  end
130
129
 
131
130
  def get_current_version_from(array)
@@ -137,7 +136,7 @@ class Chef
137
136
  # Runs command via shell_out_with_timeout with magic environment to disable
138
137
  # interactive prompts.
139
138
  def run_noninteractive(*command)
140
- shell_out_with_timeout!(a_to_s(*command), :env => { "DEBIAN_FRONTEND" => "noninteractive" })
139
+ shell_out_compact_timeout!(*command, env: { "DEBIAN_FRONTEND" => "noninteractive" })
141
140
  end
142
141
 
143
142
  # Returns true if all sources exist. Returns false if any do not, or if no
@@ -177,7 +176,7 @@ class Chef
177
176
  begin
178
177
  pkginfos = resolved_source_array.map do |src|
179
178
  Chef::Log.debug("#{new_resource} checking #{src} dpkg status")
180
- status = shell_out_with_timeout!("dpkg-deb -W #{src}")
179
+ status = shell_out_compact_timeout!("dpkg-deb", "-W", src)
181
180
  status.stdout
182
181
  end
183
182
  Hash[*package_name_array.zip(pkginfos).flatten]
@@ -32,11 +32,11 @@ class Chef
32
32
 
33
33
  begin
34
34
  # first check to see if we can import it
35
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{name}\"", :returns => [0, 1]).stderr
35
+ output = shell_out_compact_timeout!(python_binary_path, "-c", "import #{name}", returns: [0, 1]).stderr
36
36
  if output.include? "ImportError"
37
37
  # then check to see if its on the path
38
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns => [0, 1]).stdout
39
- if output.downcase.include? "#{name.downcase}"
38
+ output = shell_out_compact_timeout!(python_binary_path, "-c", "import sys; print sys.path", returns: [0, 1]).stdout
39
+ if output.downcase.include? name.downcase.to_s
40
40
  check = true
41
41
  end
42
42
  else
@@ -50,38 +50,38 @@ class Chef
50
50
  end
51
51
 
52
52
  def easy_install_binary_path
53
- path = @new_resource.easy_install_binary
53
+ path = new_resource.easy_install_binary
54
54
  path ? path : "easy_install"
55
55
  end
56
56
 
57
57
  def python_binary_path
58
- path = @new_resource.python_binary
58
+ path = new_resource.python_binary
59
59
  path ? path : "python"
60
60
  end
61
61
 
62
62
  def module_name
63
- m = @new_resource.module_name
64
- m ? m : @new_resource.name
63
+ m = new_resource.module_name
64
+ m ? m : new_resource.name
65
65
  end
66
66
 
67
67
  def load_current_resource
68
- @current_resource = Chef::Resource::Package.new(@new_resource.name)
69
- @current_resource.package_name(@new_resource.package_name)
68
+ @current_resource = Chef::Resource::Package.new(new_resource.name)
69
+ current_resource.package_name(new_resource.package_name)
70
70
 
71
71
  # get the currently installed version if installed
72
72
  package_version = nil
73
73
  if install_check(module_name)
74
74
  begin
75
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{module_name}; print #{module_name}.__version__\"").stdout
75
+ output = shell_out_compact_timeout!("#{python_binary_path} -c \"import #{module_name}; print #{module_name}.__version__\"").stdout
76
76
  package_version = output.strip
77
77
  rescue
78
- output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns => [0, 1]).stdout
78
+ output = shell_out_compact_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", returns: [0, 1]).stdout
79
79
 
80
80
  output_array = output.gsub(/[\[\]]/, "").split(/\s*,\s*/)
81
81
  package_path = ""
82
82
 
83
83
  output_array.each do |entry|
84
- if entry.downcase.include?(@new_resource.package_name)
84
+ if entry.downcase.include?(new_resource.package_name)
85
85
  package_path = entry
86
86
  end
87
87
  end
@@ -91,29 +91,29 @@ class Chef
91
91
  end
92
92
  end
93
93
 
94
- if package_version == @new_resource.version
95
- Chef::Log.debug("#{@new_resource} at version #{@new_resource.version}")
96
- @current_resource.version(@new_resource.version)
94
+ if package_version == new_resource.version
95
+ Chef::Log.debug("#{new_resource} at version #{new_resource.version}")
96
+ current_resource.version(new_resource.version)
97
97
  else
98
- Chef::Log.debug("#{@new_resource} at version #{package_version}")
99
- @current_resource.version(package_version)
98
+ Chef::Log.debug("#{new_resource} at version #{package_version}")
99
+ current_resource.version(package_version)
100
100
  end
101
101
 
102
- @current_resource
102
+ current_resource
103
103
  end
104
104
 
105
105
  def candidate_version
106
106
  return @candidate_version if @candidate_version
107
107
 
108
- # do a dry run to get the latest version
109
- result = shell_out_with_timeout!("#{easy_install_binary_path} -n #{@new_resource.package_name}", :returns => [0, 1])
108
+ # do a dry run to get the latest version
109
+ result = shell_out_compact_timeout!("#{easy_install_binary_path} -n #{new_resource.package_name}", returns: [0, 1])
110
110
  @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3]
111
111
  @candidate_version
112
112
  end
113
113
 
114
114
  def install_package(name, version)
115
115
  Chef.deprecated(:easy_install, "The easy_install package provider is deprecated and will be removed in Chef 13.")
116
- run_command(:command => "#{easy_install_binary_path}#{expand_options(@new_resource.options)} \"#{name}==#{version}\"")
116
+ shell_out_compact_timeout!(easy_install_binary_path, options, "#{name}==#{version}")
117
117
  end
118
118
 
119
119
  def upgrade_package(name, version)
@@ -122,7 +122,7 @@ class Chef
122
122
 
123
123
  def remove_package(name, version)
124
124
  Chef.deprecated(:easy_install, "The easy_install package provider is deprecated and will be removed in Chef 13.")
125
- run_command(:command => "#{easy_install_binary_path}#{expand_options(@new_resource.options)} -m #{name}")
125
+ shell_out_compact_timeout!(easy_install_binary_path, options, "-m", name)
126
126
  end
127
127
 
128
128
  def purge_package(name, version)
@@ -47,7 +47,7 @@ class Chef
47
47
 
48
48
  # Otherwise look up the path to the ports directory using 'whereis'
49
49
  else
50
- whereis = shell_out_with_timeout!("whereis -s #{port}", :env => nil)
50
+ whereis = shell_out_compact_timeout!("whereis", "-s", port, env: nil)
51
51
  unless path = whereis.stdout[/^#{Regexp.escape(port)}:\s+(.+)$/, 1]
52
52
  raise Chef::Exceptions::Package, "Could not find port with the name #{port}"
53
53
  end
@@ -56,9 +56,9 @@ class Chef
56
56
  end
57
57
 
58
58
  def makefile_variable_value(variable, dir = nil)
59
- options = dir ? { :cwd => dir } : {}
60
- make_v = shell_out_with_timeout!("make -V #{variable}", options.merge!(:env => nil, :returns => [0, 1]))
61
- make_v.exitstatus == 0 ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline.
59
+ options = dir ? { cwd: dir } : {}
60
+ make_v = shell_out_compact_timeout!("make", "-V", variable, options.merge!(env: nil, returns: [0, 1]))
61
+ make_v.exitstatus == 0 ? make_v.stdout.strip.split($OUTPUT_RECORD_SEPARATOR).first : nil # $\ is the line separator, i.e. newline.
62
62
  end
63
63
  end
64
64
 
@@ -67,19 +67,19 @@ class Chef
67
67
 
68
68
  def initialize(*args)
69
69
  super
70
- @current_resource = Chef::Resource::Package.new(@new_resource.name)
70
+ @current_resource = Chef::Resource::Package.new(new_resource.name)
71
71
  end
72
72
 
73
73
  def load_current_resource
74
- @current_resource.package_name(@new_resource.package_name)
74
+ current_resource.package_name(new_resource.package_name)
75
75
 
76
- @current_resource.version(current_installed_version)
77
- Chef::Log.debug("#{@new_resource} current version is #{@current_resource.version}") if @current_resource.version
76
+ current_resource.version(current_installed_version)
77
+ Chef::Log.debug("#{new_resource} current version is #{current_resource.version}") if current_resource.version
78
78
 
79
79
  @candidate_version = candidate_version
80
- Chef::Log.debug("#{@new_resource} candidate version is #{@candidate_version}") if @candidate_version
80
+ Chef::Log.debug("#{new_resource} candidate version is #{@candidate_version}") if @candidate_version
81
81
 
82
- @current_resource
82
+ current_resource
83
83
  end
84
84
  end
85
85
 
@@ -30,28 +30,28 @@ class Chef
30
30
  include PortsHelper
31
31
 
32
32
  def install_package(name, version)
33
- unless @current_resource.version
34
- case @new_resource.source
33
+ unless current_resource.version
34
+ case new_resource.source
35
35
  when /^http/, /^ftp/
36
- if @new_resource.source =~ /\/$/
37
- shell_out_with_timeout!("pkg_add -r #{package_name}", :env => { "PACKAGESITE" => @new_resource.source, "LC_ALL" => nil }).status
36
+ if new_resource.source =~ /\/$/
37
+ shell_out_compact_timeout!("pkg_add", "-r", package_name, env: { "PACKAGESITE" => new_resource.source, "LC_ALL" => nil }).status
38
38
  else
39
- shell_out_with_timeout!("pkg_add -r #{package_name}", :env => { "PACKAGEROOT" => @new_resource.source, "LC_ALL" => nil }).status
39
+ shell_out_compact_timeout!("pkg_add", "-r", package_name, env: { "PACKAGEROOT" => new_resource.source, "LC_ALL" => nil }).status
40
40
  end
41
- Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
41
+ Chef::Log.debug("#{new_resource} installed from: #{new_resource.source}")
42
42
 
43
43
  when /^\//
44
- shell_out_with_timeout!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , "LC_ALL" => nil }).status
45
- Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
44
+ shell_out_compact_timeout!("pkg_add", file_candidate_version_path, env: { "PKG_PATH" => new_resource.source, "LC_ALL" => nil }).status
45
+ Chef::Log.debug("#{new_resource} installed from: #{new_resource.source}")
46
46
 
47
47
  else
48
- shell_out_with_timeout!("pkg_add -r #{latest_link_name}", :env => nil).status
48
+ shell_out_compact_timeout!("pkg_add", "-r", latest_link_name, env: nil).status
49
49
  end
50
50
  end
51
51
  end
52
52
 
53
53
  def remove_package(name, version)
54
- shell_out_with_timeout!("pkg_delete #{package_name}-#{version || @current_resource.version}", :env => nil).status
54
+ shell_out_compact_timeout!("pkg_delete", "#{package_name}-#{version || current_resource.version}", env: nil).status
55
55
  end
56
56
 
57
57
  # The name of the package (without the version number) as understood by pkg_add and pkg_info.
@@ -63,7 +63,7 @@ class Chef
63
63
  raise Chef::Exceptions::Package, "Unexpected form for PKGNAME variable in #{port_path}/Makefile"
64
64
  end
65
65
  else
66
- @new_resource.package_name
66
+ new_resource.package_name
67
67
  end
68
68
  end
69
69
 
@@ -72,12 +72,12 @@ class Chef
72
72
  end
73
73
 
74
74
  def current_installed_version
75
- pkg_info = shell_out_with_timeout!("pkg_info -E \"#{package_name}*\"", :env => nil, :returns => [0, 1])
75
+ pkg_info = shell_out_compact_timeout!("pkg_info", "-E", "#{package_name}*", env: nil, returns: [0, 1])
76
76
  pkg_info.stdout[/^#{Regexp.escape(package_name)}-(.+)/, 1]
77
77
  end
78
78
 
79
79
  def candidate_version
80
- case @new_resource.source
80
+ case new_resource.source
81
81
  when /^http/, /^ftp/
82
82
  repo_candidate_version
83
83
  when /^\//
@@ -88,7 +88,7 @@ class Chef
88
88
  end
89
89
 
90
90
  def file_candidate_version_path
91
- Dir[Chef::Util::PathHelper.escape_glob_dir("#{@new_resource.source}/#{@current_resource.package_name}") + "*"][-1].to_s
91
+ Dir[Chef::Util::PathHelper.escape_glob_dir("#{new_resource.source}/#{current_resource.package_name}") + "*"][-1].to_s
92
92
  end
93
93
 
94
94
  def file_candidate_version
@@ -104,7 +104,7 @@ class Chef
104
104
  end
105
105
 
106
106
  def port_path
107
- port_dir @new_resource.package_name
107
+ port_dir new_resource.package_name
108
108
  end
109
109
 
110
110
  end
@@ -25,45 +25,43 @@ class Chef
25
25
  class Pkgng < Base
26
26
 
27
27
  def install_package(name, version)
28
- unless @current_resource.version
29
- case @new_resource.source
28
+ unless current_resource.version
29
+ case new_resource.source
30
30
  when /^(http|ftp|\/)/
31
- shell_out_with_timeout!("pkg add#{expand_options(@new_resource.options)} #{@new_resource.source}", :env => { "LC_ALL" => nil }).status
32
- Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
33
-
31
+ shell_out_compact_timeout!("pkg", "add", options, new_resource.source, env: { "LC_ALL" => nil }).status
32
+ Chef::Log.debug("#{new_resource} installed from: #{new_resource.source}")
34
33
  else
35
- shell_out_with_timeout!("pkg install -y#{expand_options(@new_resource.options)} #{name}", :env => { "LC_ALL" => nil }).status
34
+ shell_out_compact_timeout!("pkg", "install", "-y", options, name, env: { "LC_ALL" => nil }).status
36
35
  end
37
36
  end
38
37
  end
39
38
 
40
39
  def remove_package(name, version)
41
- options = @new_resource.options && @new_resource.options.sub(repo_regex, "")
42
- options && !options.empty? || options = nil
43
- shell_out_with_timeout!("pkg delete -y#{expand_options(options)} #{name}#{version ? '-' + version : ''}", :env => nil).status
40
+ options_dup = options && options.map { |str| str.sub(repo_regex, "") }.reject!(&:empty?)
41
+ shell_out_compact_timeout!("pkg", "delete", "-y", options_dup, "#{name}#{version ? '-' + version : ''}", env: nil).status
44
42
  end
45
43
 
46
44
  def current_installed_version
47
- pkg_info = shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0, 70])
45
+ pkg_info = shell_out_compact_timeout!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70])
48
46
  pkg_info.stdout[/^Version +: (.+)$/, 1]
49
47
  end
50
48
 
51
49
  def candidate_version
52
- @new_resource.source ? file_candidate_version : repo_candidate_version
50
+ new_resource.source ? file_candidate_version : repo_candidate_version
53
51
  end
54
52
 
55
53
  private
56
54
 
57
55
  def file_candidate_version
58
- @new_resource.source[/#{Regexp.escape(@new_resource.package_name)}-(.+)\.txz/, 1]
56
+ new_resource.source[/#{Regexp.escape(new_resource.package_name)}-(.+)\.txz/, 1]
59
57
  end
60
58
 
61
59
  def repo_candidate_version
62
- if @new_resource.options && @new_resource.options.match(repo_regex)
63
- options = $1
60
+ if options && options.join(" ").match(repo_regex)
61
+ options = $1.split(" ")
64
62
  end
65
63
 
66
- pkg_query = shell_out_with_timeout!("pkg rquery#{expand_options(options)} '%v' #{@new_resource.package_name}", :env => nil)
64
+ pkg_query = shell_out_compact_timeout!("pkg", "rquery", options, "%v", new_resource.package_name, env: nil)
67
65
  pkg_query.exitstatus == 0 ? pkg_query.stdout.strip.split(/\n/).last : nil
68
66
  end
69
67
 
@@ -26,20 +26,20 @@ class Chef
26
26
  include PortsHelper
27
27
 
28
28
  def install_package(name, version)
29
- shell_out_with_timeout!("make -DBATCH install clean", :timeout => 1800, :env => nil, :cwd => port_dir).status
29
+ shell_out_compact_timeout!("make", "-DBATCH", "install", "clean", timeout: 1800, env: nil, cwd: port_dir).status
30
30
  end
31
31
 
32
32
  def remove_package(name, version)
33
- shell_out_with_timeout!("make deinstall", :timeout => 300, :env => nil, :cwd => port_dir).status
33
+ shell_out_compact_timeout!("make", "deinstall", timeout: 300, env: nil, cwd: port_dir).status
34
34
  end
35
35
 
36
36
  def current_installed_version
37
- pkg_info = if @new_resource.supports_pkgng?
38
- shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0, 70])
37
+ pkg_info = if new_resource.supports_pkgng?
38
+ shell_out_compact_timeout!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 70])
39
39
  else
40
- shell_out_with_timeout!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0, 1])
40
+ shell_out_compact_timeout!("pkg_info", "-E", "#{new_resource.package_name}*", env: nil, returns: [0, 1])
41
41
  end
42
- pkg_info.stdout[/^#{Regexp.escape(@new_resource.package_name)}-(.+)/, 1]
42
+ pkg_info.stdout[/^#{Regexp.escape(new_resource.package_name)}-(.+)/, 1]
43
43
  end
44
44
 
45
45
  def candidate_version
@@ -51,7 +51,7 @@ class Chef
51
51
  end
52
52
 
53
53
  def port_dir
54
- super(@new_resource.package_name)
54
+ super(new_resource.package_name)
55
55
  end
56
56
  end
57
57
  end
@@ -32,7 +32,7 @@ class Chef
32
32
  include Chef::Mixin::HomebrewUser
33
33
 
34
34
  def load_current_resource
35
- self.current_resource = Chef::Resource::Package.new(new_resource.name)
35
+ self.current_resource = Chef::Resource::HomebrewPackage.new(new_resource.name)
36
36
  current_resource.package_name(new_resource.package_name)
37
37
  current_resource.version(current_installed_version)
38
38
  Chef::Log.debug("#{new_resource} current version is #{current_resource.version}") if current_resource.version
@@ -46,7 +46,7 @@ class Chef
46
46
 
47
47
  def install_package(name, version)
48
48
  unless current_resource.version == version
49
- brew("install", new_resource.options, name)
49
+ brew("install", options, name)
50
50
  end
51
51
  end
52
52
 
@@ -56,24 +56,25 @@ class Chef
56
56
  if current_version.nil? || current_version.empty?
57
57
  install_package(name, version)
58
58
  elsif current_version != version
59
- brew("upgrade", new_resource.options, name)
59
+ brew("upgrade", options, name)
60
60
  end
61
61
  end
62
62
 
63
63
  def remove_package(name, version)
64
64
  if current_resource.version
65
- brew("uninstall", new_resource.options, name)
65
+ brew("uninstall", options, name)
66
66
  end
67
67
  end
68
68
 
69
69
  # Homebrew doesn't really have a notion of purging, do a "force remove"
70
70
  def purge_package(name, version)
71
- new_resource.options((new_resource.options || "") << " --force").strip
72
- remove_package(name, version)
71
+ if current_resource.version
72
+ brew("uninstall", "--force", options, name)
73
+ end
73
74
  end
74
75
 
75
76
  def brew(*args)
76
- get_response_from_command("brew #{args.join(' ')}")
77
+ get_response_from_command("brew", *args)
77
78
  end
78
79
 
79
80
  # We implement a querying method that returns the JSON-as-Hash
@@ -121,13 +122,13 @@ class Chef
121
122
 
122
123
  private
123
124
 
124
- def get_response_from_command(command)
125
+ def get_response_from_command(*command)
125
126
  homebrew_uid = find_homebrew_uid(new_resource.respond_to?(:homebrew_user) && new_resource.homebrew_user)
126
127
  homebrew_user = Etc.getpwuid(homebrew_uid)
127
128
 
128
- Chef::Log.debug "Executing '#{command}' as user '#{homebrew_user.name}'"
129
+ Chef::Log.debug "Executing '#{command.join(' ')}' as user '#{homebrew_user.name}'"
129
130
  # FIXME: this 1800 second default timeout should be deprecated
130
- output = shell_out_with_timeout!(command, :timeout => 1800, :user => homebrew_uid, :environment => { "HOME" => homebrew_user.dir, "RUBYOPT" => nil, "TMPDIR" => nil })
131
+ output = shell_out_compact_timeout!(*command, timeout: 1800, user: homebrew_uid, environment: { "HOME" => homebrew_user.dir, "RUBYOPT" => nil, "TMPDIR" => nil })
131
132
  output.stdout.chomp
132
133
  end
133
134