chef 12.4.0.rc.0-universal-mingw32 → 12.4.0.rc.2-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (298) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +12 -1
  3. data/lib/chef/api_client.rb +130 -26
  4. data/lib/chef/application.rb +0 -1
  5. data/lib/chef/application/client.rb +8 -19
  6. data/lib/chef/audit/audit_reporter.rb +12 -7
  7. data/lib/chef/audit/logger.rb +36 -0
  8. data/lib/chef/audit/runner.rb +4 -2
  9. data/lib/chef/chef_class.rb +62 -11
  10. data/lib/chef/client.rb +587 -207
  11. data/lib/chef/config.rb +0 -1
  12. data/lib/chef/dsl/recipe.rb +45 -56
  13. data/lib/chef/dsl/resources.rb +3 -2
  14. data/lib/chef/event_dispatch/base.rb +7 -2
  15. data/lib/chef/exceptions.rb +4 -1
  16. data/lib/chef/file_content_management/deploy/mv_windows.rb +16 -6
  17. data/lib/chef/formatters/doc.rb +15 -7
  18. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +10 -7
  19. data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -0
  20. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +4 -1
  21. data/lib/chef/http/authenticator.rb +7 -2
  22. data/lib/chef/knife.rb +16 -4
  23. data/lib/chef/knife/client_create.rb +55 -31
  24. data/lib/chef/knife/core/generic_presenter.rb +1 -1
  25. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  26. data/lib/chef/knife/osc_user_create.rb +97 -0
  27. data/lib/chef/knife/osc_user_delete.rb +51 -0
  28. data/lib/chef/knife/osc_user_edit.rb +58 -0
  29. data/lib/chef/knife/osc_user_list.rb +47 -0
  30. data/lib/chef/knife/osc_user_reregister.rb +64 -0
  31. data/lib/chef/knife/osc_user_show.rb +54 -0
  32. data/lib/chef/knife/user_create.rb +95 -36
  33. data/lib/chef/knife/user_delete.rb +52 -2
  34. data/lib/chef/knife/user_edit.rb +37 -7
  35. data/lib/chef/knife/user_list.rb +3 -0
  36. data/lib/chef/knife/user_reregister.rb +39 -8
  37. data/lib/chef/knife/user_show.rb +30 -1
  38. data/lib/chef/mixin/api_version_request_handling.rb +66 -0
  39. data/lib/chef/mixin/convert_to_class_name.rb +10 -4
  40. data/lib/chef/mixin/deprecation.rb +24 -0
  41. data/lib/chef/mixin/powershell_out.rb +98 -0
  42. data/lib/chef/mixin/provides.rb +5 -18
  43. data/lib/chef/mixin/uris.rb +11 -0
  44. data/lib/chef/mixin/windows_architecture_helper.rb +5 -2
  45. data/lib/chef/mixin/windows_env_helper.rb +11 -2
  46. data/lib/chef/node_map.rb +130 -75
  47. data/lib/chef/osc_user.rb +194 -0
  48. data/lib/chef/platform/provider_mapping.rb +2 -269
  49. data/lib/chef/platform/provider_priority_map.rb +6 -69
  50. data/lib/chef/platform/query_helpers.rb +5 -0
  51. data/lib/chef/platform/resource_priority_map.rb +12 -15
  52. data/lib/chef/policy_builder/policyfile.rb +1 -0
  53. data/lib/chef/provider.rb +19 -0
  54. data/lib/chef/provider/directory.rb +3 -0
  55. data/lib/chef/provider/dsc_resource.rb +8 -1
  56. data/lib/chef/provider/file.rb +1 -0
  57. data/lib/chef/provider/group/aix.rb +1 -0
  58. data/lib/chef/provider/group/dscl.rb +1 -1
  59. data/lib/chef/provider/group/gpasswd.rb +1 -0
  60. data/lib/chef/provider/group/groupmod.rb +1 -1
  61. data/lib/chef/provider/group/pw.rb +1 -0
  62. data/lib/chef/provider/group/suse.rb +2 -0
  63. data/lib/chef/provider/group/usermod.rb +2 -1
  64. data/lib/chef/provider/group/windows.rb +1 -1
  65. data/lib/chef/provider/ifconfig.rb +2 -0
  66. data/lib/chef/provider/ifconfig/aix.rb +1 -0
  67. data/lib/chef/provider/ifconfig/debian.rb +2 -0
  68. data/lib/chef/provider/ifconfig/redhat.rb +1 -0
  69. data/lib/chef/provider/lwrp_base.rb +4 -0
  70. data/lib/chef/provider/mount.rb +0 -1
  71. data/lib/chef/provider/mount/aix.rb +1 -0
  72. data/lib/chef/provider/mount/mount.rb +2 -0
  73. data/lib/chef/provider/mount/solaris.rb +2 -0
  74. data/lib/chef/provider/package.rb +55 -0
  75. data/lib/chef/provider/package/aix.rb +7 -7
  76. data/lib/chef/provider/package/apt.rb +3 -3
  77. data/lib/chef/provider/package/dpkg.rb +4 -4
  78. data/lib/chef/provider/package/easy_install.rb +5 -5
  79. data/lib/chef/provider/package/freebsd/base.rb +2 -2
  80. data/lib/chef/provider/package/freebsd/pkg.rb +6 -6
  81. data/lib/chef/provider/package/freebsd/pkgng.rb +5 -5
  82. data/lib/chef/provider/package/freebsd/port.rb +4 -4
  83. data/lib/chef/provider/package/homebrew.rb +2 -2
  84. data/lib/chef/provider/package/ips.rb +4 -4
  85. data/lib/chef/provider/package/macports.rb +5 -6
  86. data/lib/chef/provider/package/openbsd.rb +4 -5
  87. data/lib/chef/provider/package/pacman.rb +4 -4
  88. data/lib/chef/provider/package/portage.rb +2 -0
  89. data/lib/chef/provider/package/rpm.rb +7 -8
  90. data/lib/chef/provider/package/rubygems.rb +5 -12
  91. data/lib/chef/provider/package/smartos.rb +4 -4
  92. data/lib/chef/provider/package/solaris.rb +7 -7
  93. data/lib/chef/provider/package/windows/msi.rb +1 -1
  94. data/lib/chef/provider/package/yum.rb +4 -6
  95. data/lib/chef/provider/package/zypper.rb +16 -14
  96. data/lib/chef/provider/powershell_script.rb +129 -47
  97. data/lib/chef/provider/remote_file/content.rb +4 -1
  98. data/lib/chef/provider/remote_file/local_file.rb +10 -4
  99. data/lib/chef/provider/service.rb +44 -0
  100. data/lib/chef/provider/service/freebsd.rb +1 -1
  101. data/lib/chef/provider/service/init.rb +1 -0
  102. data/lib/chef/provider/service/macosx.rb +1 -1
  103. data/lib/chef/provider/service/windows.rb +0 -1
  104. data/lib/chef/provider/user.rb +1 -1
  105. data/lib/chef/provider/user/aix.rb +3 -2
  106. data/lib/chef/provider/user/pw.rb +1 -0
  107. data/lib/chef/provider/user/solaris.rb +2 -0
  108. data/lib/chef/provider/user/useradd.rb +1 -0
  109. data/lib/chef/provider_resolver.rb +87 -134
  110. data/lib/chef/resource.rb +274 -68
  111. data/lib/chef/resource/apt_package.rb +0 -2
  112. data/lib/chef/resource/bash.rb +0 -2
  113. data/lib/chef/resource/batch.rb +1 -1
  114. data/lib/chef/resource/bff_package.rb +0 -7
  115. data/lib/chef/resource/breakpoint.rb +3 -6
  116. data/lib/chef/resource/chef_gem.rb +0 -3
  117. data/lib/chef/resource/cookbook_file.rb +1 -3
  118. data/lib/chef/resource/cron.rb +2 -4
  119. data/lib/chef/resource/csh.rb +0 -2
  120. data/lib/chef/resource/deploy.rb +9 -6
  121. data/lib/chef/resource/deploy_revision.rb +0 -14
  122. data/lib/chef/resource/directory.rb +2 -4
  123. data/lib/chef/resource/dpkg_package.rb +0 -5
  124. data/lib/chef/resource/dsc_resource.rb +2 -3
  125. data/lib/chef/resource/dsc_script.rb +2 -3
  126. data/lib/chef/resource/easy_install_package.rb +0 -7
  127. data/lib/chef/resource/env.rb +3 -3
  128. data/lib/chef/resource/erl_call.rb +2 -5
  129. data/lib/chef/resource/execute.rb +2 -4
  130. data/lib/chef/resource/file.rb +2 -4
  131. data/lib/chef/resource/freebsd_package.rb +0 -5
  132. data/lib/chef/resource/gem_package.rb +0 -3
  133. data/lib/chef/resource/git.rb +0 -3
  134. data/lib/chef/resource/group.rb +2 -4
  135. data/lib/chef/resource/homebrew_package.rb +0 -2
  136. data/lib/chef/resource/http_request.rb +3 -4
  137. data/lib/chef/resource/ifconfig.rb +3 -4
  138. data/lib/chef/resource/ips_package.rb +2 -2
  139. data/lib/chef/resource/link.rb +3 -5
  140. data/lib/chef/resource/log.rb +2 -4
  141. data/lib/chef/resource/lwrp_base.rb +10 -61
  142. data/lib/chef/resource/macosx_service.rb +1 -2
  143. data/lib/chef/resource/macports_package.rb +0 -7
  144. data/lib/chef/resource/mdadm.rb +2 -5
  145. data/lib/chef/resource/mount.rb +2 -4
  146. data/lib/chef/resource/ohai.rb +2 -4
  147. data/lib/chef/resource/openbsd_package.rb +0 -6
  148. data/lib/chef/resource/package.rb +9 -6
  149. data/lib/chef/resource/pacman_package.rb +0 -7
  150. data/lib/chef/resource/paludis_package.rb +2 -3
  151. data/lib/chef/resource/perl.rb +0 -3
  152. data/lib/chef/resource/portage_package.rb +0 -3
  153. data/lib/chef/resource/powershell_script.rb +1 -2
  154. data/lib/chef/resource/python.rb +0 -3
  155. data/lib/chef/resource/reboot.rb +1 -3
  156. data/lib/chef/resource/registry_key.rb +3 -5
  157. data/lib/chef/resource/remote_directory.rb +3 -5
  158. data/lib/chef/resource/remote_file.rb +4 -5
  159. data/lib/chef/resource/route.rb +3 -5
  160. data/lib/chef/resource/rpm_package.rb +0 -2
  161. data/lib/chef/resource/ruby.rb +0 -4
  162. data/lib/chef/resource/ruby_block.rb +2 -4
  163. data/lib/chef/resource/scm.rb +3 -5
  164. data/lib/chef/resource/script.rb +0 -3
  165. data/lib/chef/resource/service.rb +3 -5
  166. data/lib/chef/resource/smartos_package.rb +0 -9
  167. data/lib/chef/resource/solaris_package.rb +0 -10
  168. data/lib/chef/resource/subversion.rb +1 -3
  169. data/lib/chef/resource/template.rb +0 -4
  170. data/lib/chef/resource/timestamped_deploy.rb +0 -4
  171. data/lib/chef/resource/user.rb +2 -5
  172. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -7
  173. data/lib/chef/resource/windows_package.rb +3 -3
  174. data/lib/chef/resource/windows_script.rb +2 -2
  175. data/lib/chef/resource/windows_service.rb +3 -3
  176. data/lib/chef/resource/yum_package.rb +0 -3
  177. data/lib/chef/resource/zypper_package.rb +27 -0
  178. data/lib/chef/resource_builder.rb +7 -0
  179. data/lib/chef/resource_reporter.rb +1 -1
  180. data/lib/chef/resource_resolver.rb +108 -62
  181. data/lib/chef/resources.rb +1 -0
  182. data/lib/chef/rest.rb +1 -0
  183. data/lib/chef/server_api.rb +2 -0
  184. data/lib/chef/user.rb +193 -42
  185. data/lib/chef/util/backup.rb +9 -1
  186. data/lib/chef/util/path_helper.rb +0 -1
  187. data/lib/chef/version.rb +1 -1
  188. data/spec/functional/audit/runner_spec.rb +22 -42
  189. data/spec/functional/mixin/powershell_out_spec.rb +43 -0
  190. data/spec/functional/resource/execute_spec.rb +9 -2
  191. data/spec/functional/resource/file_spec.rb +25 -0
  192. data/spec/functional/resource/group_spec.rb +5 -0
  193. data/spec/functional/resource/link_spec.rb +5 -11
  194. data/spec/functional/resource/powershell_spec.rb +40 -5
  195. data/spec/functional/resource/user/useradd_spec.rb +10 -18
  196. data/spec/integration/recipes/lwrp_spec.rb +57 -0
  197. data/spec/integration/recipes/provider_choice.rb +2 -7
  198. data/spec/integration/recipes/recipe_dsl_spec.rb +517 -19
  199. data/spec/spec_helper.rb +1 -1
  200. data/spec/support/lib/chef/provider/openldap_includer.rb +29 -0
  201. data/spec/support/lib/chef/resource/cat.rb +0 -2
  202. data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -6
  203. data/spec/support/lib/chef/resource/openldap_includer.rb +27 -0
  204. data/spec/support/lib/chef/resource/with_state.rb +0 -9
  205. data/spec/support/lib/chef/resource/zen_follower.rb +0 -6
  206. data/spec/support/lib/chef/resource/zen_master.rb +1 -6
  207. data/spec/support/shared/context/client.rb +277 -0
  208. data/spec/support/shared/examples/client.rb +53 -0
  209. data/spec/support/shared/functional/file_resource.rb +0 -4
  210. data/spec/support/shared/functional/securable_resource.rb +0 -24
  211. data/spec/support/shared/functional/securable_resource_with_reporting.rb +4 -4
  212. data/spec/support/shared/functional/windows_script.rb +1 -1
  213. data/spec/support/shared/unit/api_versioning.rb +77 -0
  214. data/spec/support/shared/unit/knife_shared.rb +40 -0
  215. data/spec/support/shared/unit/user_and_client_shared.rb +115 -0
  216. data/spec/unit/api_client_spec.rb +189 -14
  217. data/spec/unit/application/client_spec.rb +0 -5
  218. data/spec/unit/audit/audit_reporter_spec.rb +58 -14
  219. data/spec/unit/audit/logger_spec.rb +42 -0
  220. data/spec/unit/audit/runner_spec.rb +2 -2
  221. data/spec/unit/chef_fs/file_pattern_spec.rb +3 -15
  222. data/spec/unit/client_spec.rb +58 -374
  223. data/spec/unit/cookbook_spec.rb +0 -9
  224. data/spec/unit/cookbook_version_spec.rb +0 -20
  225. data/spec/unit/deprecation_spec.rb +55 -0
  226. data/spec/unit/dsl/resources_spec.rb +85 -0
  227. data/spec/unit/exceptions_spec.rb +2 -2
  228. data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +60 -0
  229. data/spec/unit/formatters/doc_spec.rb +46 -0
  230. data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +12 -10
  231. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +8 -0
  232. data/spec/unit/http/authenticator_spec.rb +11 -2
  233. data/spec/unit/knife/client_create_spec.rb +122 -51
  234. data/spec/unit/knife/core/subcommand_loader_spec.rb +19 -3
  235. data/spec/unit/knife/core/ui_spec.rb +14 -0
  236. data/spec/unit/knife/osc_user_create_spec.rb +93 -0
  237. data/spec/unit/knife/osc_user_delete_spec.rb +44 -0
  238. data/spec/unit/knife/osc_user_edit_spec.rb +52 -0
  239. data/spec/unit/knife/osc_user_list_spec.rb +37 -0
  240. data/spec/unit/knife/osc_user_reregister_spec.rb +58 -0
  241. data/spec/unit/knife/osc_user_show_spec.rb +46 -0
  242. data/spec/unit/knife/user_create_spec.rb +177 -51
  243. data/spec/unit/knife/user_delete_spec.rb +34 -8
  244. data/spec/unit/knife/user_edit_spec.rb +31 -12
  245. data/spec/unit/knife/user_list_spec.rb +7 -3
  246. data/spec/unit/knife/user_reregister_spec.rb +38 -17
  247. data/spec/unit/knife/user_show_spec.rb +35 -11
  248. data/spec/unit/knife_spec.rb +10 -4
  249. data/spec/unit/lwrp_spec.rb +228 -54
  250. data/spec/unit/mixin/api_version_request_handling_spec.rb +127 -0
  251. data/spec/unit/mixin/command_spec.rb +1 -2
  252. data/spec/unit/mixin/powershell_out_spec.rb +70 -0
  253. data/spec/unit/mixin/uris_spec.rb +23 -11
  254. data/spec/unit/node_map_spec.rb +4 -1
  255. data/spec/unit/osc_user_spec.rb +276 -0
  256. data/spec/unit/platform_spec.rb +0 -60
  257. data/spec/unit/provider/deploy_spec.rb +1 -1
  258. data/spec/unit/provider/directory_spec.rb +199 -135
  259. data/spec/unit/provider/ifconfig/debian_spec.rb +0 -10
  260. data/spec/unit/provider/package/aix_spec.rb +16 -16
  261. data/spec/unit/provider/package/dpkg_spec.rb +2 -2
  262. data/spec/unit/provider/package/freebsd/pkg_spec.rb +13 -13
  263. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
  264. data/spec/unit/provider/package/freebsd/port_spec.rb +7 -7
  265. data/spec/unit/provider/package/ips_spec.rb +22 -22
  266. data/spec/unit/provider/package/macports_spec.rb +10 -10
  267. data/spec/unit/provider/package/openbsd_spec.rb +4 -26
  268. data/spec/unit/provider/package/pacman_spec.rb +5 -5
  269. data/spec/unit/provider/package/rpm_spec.rb +14 -14
  270. data/spec/unit/provider/package/rubygems_spec.rb +10 -44
  271. data/spec/unit/provider/package/smartos_spec.rb +4 -4
  272. data/spec/unit/provider/package/solaris_spec.rb +11 -11
  273. data/spec/unit/provider/package/zypper_spec.rb +125 -90
  274. data/spec/unit/provider/package_spec.rb +34 -0
  275. data/spec/unit/provider/powershell_spec.rb +53 -11
  276. data/spec/unit/provider/remote_directory_spec.rb +2 -2
  277. data/spec/unit/provider/remote_file/local_file_spec.rb +25 -6
  278. data/spec/unit/provider/service/freebsd_service_spec.rb +0 -12
  279. data/spec/unit/provider/user_spec.rb +3 -3
  280. data/spec/unit/provider_resolver_spec.rb +463 -327
  281. data/spec/unit/recipe_spec.rb +42 -15
  282. data/spec/unit/resource/breakpoint_spec.rb +1 -1
  283. data/spec/unit/resource/erl_call_spec.rb +1 -1
  284. data/spec/unit/resource/file_spec.rb +1 -1
  285. data/spec/unit/resource/ifconfig_spec.rb +10 -6
  286. data/spec/unit/resource/remote_file_spec.rb +5 -0
  287. data/spec/unit/resource/route_spec.rb +1 -1
  288. data/spec/unit/resource/ruby_block_spec.rb +2 -2
  289. data/spec/unit/resource/template_spec.rb +1 -1
  290. data/spec/unit/resource/timestamped_deploy_spec.rb +1 -2
  291. data/spec/unit/resource/windows_service_spec.rb +1 -1
  292. data/spec/unit/resource_spec.rb +99 -13
  293. data/spec/unit/rest_spec.rb +5 -5
  294. data/spec/unit/run_context_spec.rb +41 -0
  295. data/spec/unit/runner_spec.rb +2 -2
  296. data/spec/unit/user_spec.rb +406 -93
  297. data/tasks/maintainers.rb +69 -0
  298. metadata +37 -4
@@ -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!("whereis -s #{port}", :env => nil)
50
+ whereis = shell_out_with_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
@@ -57,7 +57,7 @@ class Chef
57
57
 
58
58
  def makefile_variable_value(variable, dir = nil)
59
59
  options = dir ? { :cwd => dir } : {}
60
- make_v = shell_out!("make -V #{variable}", options.merge!(:env => nil, :returns => [0,1]))
60
+ make_v = shell_out_with_timeout!("make -V #{variable}", options.merge!(:env => nil, :returns => [0,1]))
61
61
  make_v.exitstatus.zero? ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline.
62
62
  end
63
63
  end
@@ -34,24 +34,24 @@ class Chef
34
34
  case @new_resource.source
35
35
  when /^http/, /^ftp/
36
36
  if @new_resource.source =~ /\/$/
37
- shell_out!("pkg_add -r #{package_name}", :env => { "PACKAGESITE" => @new_resource.source, 'LC_ALL' => nil }).status
37
+ shell_out_with_timeout!("pkg_add -r #{package_name}", :env => { "PACKAGESITE" => @new_resource.source, 'LC_ALL' => nil }).status
38
38
  else
39
- shell_out!("pkg_add -r #{package_name}", :env => { "PACKAGEROOT" => @new_resource.source, 'LC_ALL' => nil }).status
39
+ shell_out_with_timeout!("pkg_add -r #{package_name}", :env => { "PACKAGEROOT" => @new_resource.source, 'LC_ALL' => nil }).status
40
40
  end
41
41
  Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
42
42
 
43
43
  when /^\//
44
- shell_out!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , 'LC_ALL'=>nil}).status
44
+ shell_out_with_timeout!("pkg_add #{file_candidate_version_path}", :env => { "PKG_PATH" => @new_resource.source , 'LC_ALL'=>nil}).status
45
45
  Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
46
46
 
47
47
  else
48
- shell_out!("pkg_add -r #{latest_link_name}", :env => nil).status
48
+ shell_out_with_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!("pkg_delete #{package_name}-#{version || @current_resource.version}", :env => nil).status
54
+ shell_out_with_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.
@@ -72,7 +72,7 @@ class Chef
72
72
  end
73
73
 
74
74
  def current_installed_version
75
- pkg_info = shell_out!("pkg_info -E \"#{package_name}*\"", :env => nil, :returns => [0,1])
75
+ pkg_info = shell_out_with_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
 
@@ -28,11 +28,11 @@ class Chef
28
28
  unless @current_resource.version
29
29
  case @new_resource.source
30
30
  when /^(http|ftp|\/)/
31
- shell_out!("pkg add#{expand_options(@new_resource.options)} #{@new_resource.source}", :env => { 'LC_ALL' => nil }).status
31
+ shell_out_with_timeout!("pkg add#{expand_options(@new_resource.options)} #{@new_resource.source}", :env => { 'LC_ALL' => nil }).status
32
32
  Chef::Log.debug("#{@new_resource} installed from: #{@new_resource.source}")
33
33
 
34
34
  else
35
- shell_out!("pkg install -y#{expand_options(@new_resource.options)} #{name}", :env => { 'LC_ALL' => nil }).status
35
+ shell_out_with_timeout!("pkg install -y#{expand_options(@new_resource.options)} #{name}", :env => { 'LC_ALL' => nil }).status
36
36
  end
37
37
  end
38
38
  end
@@ -40,11 +40,11 @@ class Chef
40
40
  def remove_package(name, version)
41
41
  options = @new_resource.options && @new_resource.options.sub(repo_regex, '')
42
42
  options && !options.empty? || options = nil
43
- shell_out!("pkg delete -y#{expand_options(options)} #{name}#{version ? '-' + version : ''}", :env => nil).status
43
+ shell_out_with_timeout!("pkg delete -y#{expand_options(options)} #{name}#{version ? '-' + version : ''}", :env => nil).status
44
44
  end
45
45
 
46
46
  def current_installed_version
47
- pkg_info = shell_out!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
47
+ pkg_info = shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
48
48
  pkg_info.stdout[/^Version +: (.+)$/, 1]
49
49
  end
50
50
 
@@ -63,7 +63,7 @@ class Chef
63
63
  options = $1
64
64
  end
65
65
 
66
- pkg_query = shell_out!("pkg rquery#{expand_options(options)} '%v' #{@new_resource.package_name}", :env => nil)
66
+ pkg_query = shell_out_with_timeout!("pkg rquery#{expand_options(options)} '%v' #{@new_resource.package_name}", :env => nil)
67
67
  pkg_query.exitstatus.zero? ? pkg_query.stdout.strip.split(/\n/).last : nil
68
68
  end
69
69
 
@@ -26,18 +26,18 @@ class Chef
26
26
  include PortsHelper
27
27
 
28
28
  def install_package(name, version)
29
- shell_out!("make -DBATCH install clean", :timeout => 1800, :env => nil, :cwd => port_dir).status
29
+ shell_out_with_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!("make deinstall", :timeout => 300, :env => nil, :cwd => port_dir).status
33
+ shell_out_with_timeout!("make deinstall", :timeout => 300, :env => nil, :cwd => port_dir).status
34
34
  end
35
35
 
36
36
  def current_installed_version
37
37
  pkg_info = if @new_resource.supports_pkgng?
38
- shell_out!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
38
+ shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
39
39
  else
40
- shell_out!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0,1])
40
+ shell_out_with_timeout!("pkg_info -E \"#{@new_resource.package_name}*\"", :env => nil, :returns => [0,1])
41
41
  end
42
42
  pkg_info.stdout[/^#{Regexp.escape(@new_resource.package_name)}-(.+)/, 1]
43
43
  end
@@ -27,7 +27,6 @@ class Chef
27
27
  class Homebrew < Chef::Provider::Package
28
28
 
29
29
  provides :homebrew_package
30
- provides :package, os: "darwin"
31
30
 
32
31
  include Chef::Mixin::HomebrewUser
33
32
 
@@ -126,7 +125,8 @@ class Chef
126
125
  homebrew_user = Etc.getpwuid(homebrew_uid)
127
126
 
128
127
  Chef::Log.debug "Executing '#{command}' as user '#{homebrew_user.name}'"
129
- output = shell_out!(command, :timeout => 1800, :user => homebrew_uid, :environment => { 'HOME' => homebrew_user.dir, 'RUBYOPT' => nil })
128
+ # FIXME: this 1800 second default timeout should be deprecated
129
+ output = shell_out_with_timeout!(command, :timeout => 1800, :user => homebrew_uid, :environment => { 'HOME' => homebrew_user.dir, 'RUBYOPT' => nil })
130
130
  output.stdout.chomp
131
131
  end
132
132
 
@@ -42,14 +42,14 @@ class Chef
42
42
  end
43
43
 
44
44
  def get_current_version
45
- shell_out("pkg info #{@new_resource.package_name}").stdout.each_line do |line|
45
+ shell_out_with_timeout("pkg info #{@new_resource.package_name}").stdout.each_line do |line|
46
46
  return $1.split[0] if line =~ /^\s+Version: (.*)/
47
47
  end
48
48
  return nil
49
49
  end
50
50
 
51
51
  def get_candidate_version
52
- shell_out!("pkg info -r #{new_resource.package_name}").stdout.each_line do |line|
52
+ shell_out_with_timeout!("pkg info -r #{new_resource.package_name}").stdout.each_line do |line|
53
53
  return $1.split[0] if line =~ /Version: (.*)/
54
54
  end
55
55
  return nil
@@ -73,7 +73,7 @@ class Chef
73
73
  else
74
74
  normal_command
75
75
  end
76
- shell_out(command)
76
+ shell_out_with_timeout(command)
77
77
  end
78
78
 
79
79
  def upgrade_package(name, version)
@@ -82,7 +82,7 @@ class Chef
82
82
 
83
83
  def remove_package(name, version)
84
84
  package_name = "#{name}@#{version}"
85
- shell_out!( "pkg#{expand_options(@new_resource.options)} uninstall -q #{package_name}" )
85
+ shell_out_with_timeout!( "pkg#{expand_options(@new_resource.options)} uninstall -q #{package_name}" )
86
86
  end
87
87
  end
88
88
  end
@@ -4,7 +4,6 @@ class Chef
4
4
  class Macports < Chef::Provider::Package
5
5
 
6
6
  provides :macports_package
7
- provides :package, os: "darwin"
8
7
 
9
8
  def load_current_resource
10
9
  @current_resource = Chef::Resource::Package.new(@new_resource.name)
@@ -49,21 +48,21 @@ class Chef
49
48
  unless @current_resource.version == version
50
49
  command = "port#{expand_options(@new_resource.options)} install #{name}"
51
50
  command << " @#{version}" if version and !version.empty?
52
- shell_out!(command)
51
+ shell_out_with_timeout!(command)
53
52
  end
54
53
  end
55
54
 
56
55
  def purge_package(name, version)
57
56
  command = "port#{expand_options(@new_resource.options)} uninstall #{name}"
58
57
  command << " @#{version}" if version and !version.empty?
59
- shell_out!(command)
58
+ shell_out_with_timeout!(command)
60
59
  end
61
60
 
62
61
  def remove_package(name, version)
63
62
  command = "port#{expand_options(@new_resource.options)} deactivate #{name}"
64
63
  command << " @#{version}" if version and !version.empty?
65
64
 
66
- shell_out!(command)
65
+ shell_out_with_timeout!(command)
67
66
  end
68
67
 
69
68
  def upgrade_package(name, version)
@@ -76,14 +75,14 @@ class Chef
76
75
  # that hasn't been installed.
77
76
  install_package(name, version)
78
77
  elsif current_version != version
79
- shell_out!( "port#{expand_options(@new_resource.options)} upgrade #{name} @#{version}" )
78
+ shell_out_with_timeout!( "port#{expand_options(@new_resource.options)} upgrade #{name} @#{version}" )
80
79
  end
81
80
  end
82
81
 
83
82
  private
84
83
  def get_response_from_command(command)
85
84
  output = nil
86
- status = shell_out(command)
85
+ status = shell_out_with_timeout(command)
87
86
  begin
88
87
  output = status.stdout
89
88
  rescue Exception
@@ -22,7 +22,6 @@
22
22
 
23
23
  require 'chef/resource/package'
24
24
  require 'chef/provider/package'
25
- require 'chef/mixin/shell_out'
26
25
  require 'chef/mixin/get_source_from_package'
27
26
  require 'chef/exceptions'
28
27
 
@@ -72,7 +71,7 @@ class Chef
72
71
  if parts = name.match(/^(.+?)--(.+)/) # use double-dash for stems with flavors, see man page for pkg_add
73
72
  name = parts[1]
74
73
  end
75
- shell_out!("pkg_add -r #{name}#{version_string}", :env => {"PKG_PATH" => pkg_path}).status
74
+ shell_out_with_timeout!("pkg_add -r #{name}#{version_string}", :env => {"PKG_PATH" => pkg_path}).status
76
75
  Chef::Log.debug("#{new_resource.package_name} installed")
77
76
  end
78
77
  end
@@ -83,7 +82,7 @@ class Chef
83
82
  if parts = name.match(/^(.+?)--(.+)/)
84
83
  name = parts[1]
85
84
  end
86
- shell_out!("pkg_delete #{name}#{version_string}", :env => nil).status
85
+ shell_out_with_timeout!("pkg_delete #{name}#{version_string}", :env => nil).status
87
86
  end
88
87
 
89
88
  private
@@ -94,7 +93,7 @@ class Chef
94
93
  else
95
94
  name = new_resource.package_name
96
95
  end
97
- pkg_info = shell_out!("pkg_info -e \"#{name}->0\"", :env => nil, :returns => [0,1])
96
+ pkg_info = shell_out_with_timeout!("pkg_info -e \"#{name}->0\"", :env => nil, :returns => [0,1])
98
97
  result = pkg_info.stdout[/^inst:#{Regexp.escape(name)}-(.+?)\s/, 1]
99
98
  Chef::Log.debug("installed_version of '#{new_resource.package_name}' is '#{result}'")
100
99
  result
@@ -103,7 +102,7 @@ class Chef
103
102
  def candidate_version
104
103
  @candidate_version ||= begin
105
104
  results = []
106
- shell_out!("pkg_info -I \"#{new_resource.package_name}#{version_string}\"", :env => nil, :returns => [0,1]).stdout.each_line do |line|
105
+ shell_out_with_timeout!("pkg_info -I \"#{new_resource.package_name}#{version_string}\"", :env => nil, :returns => [0,1]).stdout.each_line do |line|
107
106
  if parts = new_resource.package_name.match(/^(.+?)--(.+)/)
108
107
  results << line[/^#{Regexp.escape(parts[1])}-(.+?)\s/, 1]
109
108
  else
@@ -34,7 +34,7 @@ class Chef
34
34
  @current_resource.version(nil)
35
35
 
36
36
  Chef::Log.debug("#{@new_resource} checking pacman for #{@new_resource.package_name}")
37
- status = shell_out("pacman -Qi #{@new_resource.package_name}")
37
+ status = shell_out_with_timeout("pacman -Qi #{@new_resource.package_name}")
38
38
  status.stdout.each_line do |line|
39
39
  case line
40
40
  when /^Version(\s?)*: (.+)$/
@@ -62,7 +62,7 @@ class Chef
62
62
 
63
63
  package_repos = repos.map {|r| Regexp.escape(r) }.join('|')
64
64
 
65
- status = shell_out("pacman -Sl")
65
+ status = shell_out_with_timeout("pacman -Sl")
66
66
  status.stdout.each_line do |line|
67
67
  case line
68
68
  when /^(#{package_repos}) #{Regexp.escape(@new_resource.package_name)} (.+)$/
@@ -85,7 +85,7 @@ class Chef
85
85
  end
86
86
 
87
87
  def install_package(name, version)
88
- shell_out!( "pacman --sync --noconfirm --noprogressbar#{expand_options(@new_resource.options)} #{name}" )
88
+ shell_out_with_timeout!( "pacman --sync --noconfirm --noprogressbar#{expand_options(@new_resource.options)} #{name}" )
89
89
  end
90
90
 
91
91
  def upgrade_package(name, version)
@@ -93,7 +93,7 @@ class Chef
93
93
  end
94
94
 
95
95
  def remove_package(name, version)
96
- shell_out!( "pacman --remove --noconfirm --noprogressbar#{expand_options(@new_resource.options)} #{name}" )
96
+ shell_out_with_timeout!( "pacman --remove --noconfirm --noprogressbar#{expand_options(@new_resource.options)} #{name}" )
97
97
  end
98
98
 
99
99
  def purge_package(name, version)
@@ -25,6 +25,8 @@ class Chef
25
25
  class Provider
26
26
  class Package
27
27
  class Portage < Chef::Provider::Package
28
+ provides :portage_package
29
+
28
30
  PACKAGE_NAME_PATTERN = %r{(?:([^/]+)/)?([^/]+)}
29
31
 
30
32
  def load_current_resource
@@ -17,7 +17,6 @@
17
17
  #
18
18
  require 'chef/provider/package'
19
19
  require 'chef/mixin/command'
20
- require 'chef/mixin/shell_out'
21
20
  require 'chef/resource/package'
22
21
  require 'chef/mixin/get_source_from_package'
23
22
 
@@ -60,7 +59,7 @@ class Chef
60
59
  end
61
60
 
62
61
  Chef::Log.debug("#{@new_resource} checking rpm status")
63
- shell_out!("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{@new_resource.source}").stdout.each_line do |line|
62
+ shell_out_with_timeout!("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{@new_resource.source}").stdout.each_line do |line|
64
63
  case line
65
64
  when /^([\w\d+_.-]+)\s([\w\d_.-]+)$/
66
65
  @current_resource.package_name($1)
@@ -76,7 +75,7 @@ class Chef
76
75
  end
77
76
 
78
77
  Chef::Log.debug("#{@new_resource} checking install state")
79
- @rpm_status = shell_out("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{@current_resource.package_name}")
78
+ @rpm_status = shell_out_with_timeout("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{@current_resource.package_name}")
80
79
  @rpm_status.stdout.each_line do |line|
81
80
  case line
82
81
  when /^([\w\d+_.-]+)\s([\w\d_.-]+)$/
@@ -90,12 +89,12 @@ class Chef
90
89
 
91
90
  def install_package(name, version)
92
91
  unless @current_resource.version
93
- shell_out!( "rpm #{@new_resource.options} -i #{@new_resource.source}" )
92
+ shell_out_with_timeout!( "rpm #{@new_resource.options} -i #{@new_resource.source}" )
94
93
  else
95
94
  if allow_downgrade
96
- shell_out!( "rpm #{@new_resource.options} -U --oldpackage #{@new_resource.source}" )
95
+ shell_out_with_timeout!( "rpm #{@new_resource.options} -U --oldpackage #{@new_resource.source}" )
97
96
  else
98
- shell_out!( "rpm #{@new_resource.options} -U #{@new_resource.source}" )
97
+ shell_out_with_timeout!( "rpm #{@new_resource.options} -U #{@new_resource.source}" )
99
98
  end
100
99
  end
101
100
  end
@@ -104,9 +103,9 @@ class Chef
104
103
 
105
104
  def remove_package(name, version)
106
105
  if version
107
- shell_out!( "rpm #{@new_resource.options} -e #{name}-#{version}" )
106
+ shell_out_with_timeout!( "rpm #{@new_resource.options} -e #{name}-#{version}" )
108
107
  else
109
- shell_out!( "rpm #{@new_resource.options} -e #{name}" )
108
+ shell_out_with_timeout!( "rpm #{@new_resource.options} -e #{name}" )
110
109
  end
111
110
  end
112
111
 
@@ -32,14 +32,7 @@ require 'rubygems/version'
32
32
  require 'rubygems/dependency'
33
33
  require 'rubygems/spec_fetcher'
34
34
  require 'rubygems/platform'
35
-
36
- # Compatibility note: Rubygems 2.0 removes rubygems/format in favor of
37
- # rubygems/package.
38
- begin
39
- require 'rubygems/format'
40
- rescue LoadError
41
- require 'rubygems/package'
42
- end
35
+ require 'rubygems/package'
43
36
  require 'rubygems/dependency_installer'
44
37
  require 'rubygems/uninstaller'
45
38
  require 'rubygems/specification'
@@ -545,9 +538,9 @@ class Chef
545
538
  src = @new_resource.source && " --source=#{@new_resource.source} --source=https://rubygems.org"
546
539
  end
547
540
  if !version.nil? && version.length > 0
548
- shell_out!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env=>nil)
541
+ shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :env=>nil)
549
542
  else
550
- shell_out!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env=>nil)
543
+ shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :env=>nil)
551
544
  end
552
545
  end
553
546
 
@@ -571,9 +564,9 @@ class Chef
571
564
 
572
565
  def uninstall_via_gem_command(name, version)
573
566
  if version
574
- shell_out!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env=>nil)
567
+ shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env=>nil)
575
568
  else
576
- shell_out!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :env=>nil)
569
+ shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :env=>nil)
577
570
  end
578
571
  end
579
572
 
@@ -43,7 +43,7 @@ class Chef
43
43
  def check_package_state(name)
44
44
  Chef::Log.debug("#{@new_resource} checking package #{name}")
45
45
  version = nil
46
- info = shell_out!("/opt/local/sbin/pkg_info", "-E", "#{name}*", :env => nil, :returns => [0,1])
46
+ info = shell_out_with_timeout!("/opt/local/sbin/pkg_info", "-E", "#{name}*", :env => nil, :returns => [0,1])
47
47
 
48
48
  if info.stdout
49
49
  version = info.stdout[/^#{@new_resource.package_name}-(.+)/, 1]
@@ -60,7 +60,7 @@ class Chef
60
60
  return @candidate_version if @candidate_version
61
61
  name = nil
62
62
  version = nil
63
- pkg = shell_out!("/opt/local/bin/pkgin", "se", new_resource.package_name, :env => nil, :returns => [0,1])
63
+ pkg = shell_out_with_timeout!("/opt/local/bin/pkgin", "se", new_resource.package_name, :env => nil, :returns => [0,1])
64
64
  pkg.stdout.each_line do |line|
65
65
  case line
66
66
  when /^#{new_resource.package_name}/
@@ -74,7 +74,7 @@ class Chef
74
74
  def install_package(name, version)
75
75
  Chef::Log.debug("#{@new_resource} installing package #{name} version #{version}")
76
76
  package = "#{name}-#{version}"
77
- out = shell_out!("/opt/local/bin/pkgin", "-y", "install", package, :env => nil)
77
+ out = shell_out_with_timeout!("/opt/local/bin/pkgin", "-y", "install", package, :env => nil)
78
78
  end
79
79
 
80
80
  def upgrade_package(name, version)
@@ -85,7 +85,7 @@ class Chef
85
85
  def remove_package(name, version)
86
86
  Chef::Log.debug("#{@new_resource} removing package #{name} version #{version}")
87
87
  package = "#{name}"
88
- out = shell_out!("/opt/local/bin/pkgin", "-y", "remove", package, :env => nil)
88
+ out = shell_out_with_timeout!("/opt/local/bin/pkgin", "-y", "remove", package, :env => nil)
89
89
  end
90
90
 
91
91
  end
@@ -55,7 +55,7 @@ class Chef
55
55
  @package_source_found = ::File.exists?(@new_resource.source)
56
56
  if @package_source_found
57
57
  Chef::Log.debug("#{@new_resource} checking pkg status")
58
- shell_out("pkginfo -l -d #{@new_resource.source} #{@new_resource.package_name}").stdout.each_line do |line|
58
+ shell_out_with_timeout("pkginfo -l -d #{@new_resource.source} #{@new_resource.package_name}").stdout.each_line do |line|
59
59
  case line
60
60
  when /VERSION:\s+(.+)/
61
61
  @new_resource.version($1)
@@ -65,7 +65,7 @@ class Chef
65
65
  end
66
66
 
67
67
  Chef::Log.debug("#{@new_resource} checking install state")
68
- status = shell_out("pkginfo -l #{@current_resource.package_name}")
68
+ status = shell_out_with_timeout("pkginfo -l #{@current_resource.package_name}")
69
69
  status.stdout.each_line do |line|
70
70
  case line
71
71
  when /VERSION:\s+(.+)/
@@ -87,7 +87,7 @@ class Chef
87
87
 
88
88
  def candidate_version
89
89
  return @candidate_version if @candidate_version
90
- status = shell_out("pkginfo -l -d #{@new_resource.source} #{new_resource.package_name}")
90
+ status = shell_out_with_timeout("pkginfo -l -d #{@new_resource.source} #{new_resource.package_name}")
91
91
  status.stdout.each_line do |line|
92
92
  case line
93
93
  when /VERSION:\s+(.+)/
@@ -110,7 +110,7 @@ class Chef
110
110
  else
111
111
  command = "pkgadd -n -d #{@new_resource.source} all"
112
112
  end
113
- shell_out!(command)
113
+ shell_out_with_timeout!(command)
114
114
  Chef::Log.debug("#{@new_resource} installed version #{@new_resource.version} from: #{@new_resource.source}")
115
115
  else
116
116
  if ::File.directory?(@new_resource.source) # CHEF-4469
@@ -118,17 +118,17 @@ class Chef
118
118
  else
119
119
  command = "pkgadd -n#{expand_options(@new_resource.options)} -d #{@new_resource.source} all"
120
120
  end
121
- shell_out!(command)
121
+ shell_out_with_timeout!(command)
122
122
  Chef::Log.debug("#{@new_resource} installed version #{@new_resource.version} from: #{@new_resource.source}")
123
123
  end
124
124
  end
125
125
 
126
126
  def remove_package(name, version)
127
127
  if @new_resource.options.nil?
128
- shell_out!( "pkgrm -n #{name}" )
128
+ shell_out_with_timeout!( "pkgrm -n #{name}" )
129
129
  Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
130
130
  else
131
- shell_out!( "pkgrm -n#{expand_options(@new_resource.options)} #{name}" )
131
+ shell_out_with_timeout!( "pkgrm -n#{expand_options(@new_resource.options)} #{name}" )
132
132
  Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
133
133
  end
134
134
  end