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.
- checksums.yaml +4 -4
- data/Rakefile +12 -1
- data/lib/chef/api_client.rb +130 -26
- data/lib/chef/application.rb +0 -1
- data/lib/chef/application/client.rb +8 -19
- data/lib/chef/audit/audit_reporter.rb +12 -7
- data/lib/chef/audit/logger.rb +36 -0
- data/lib/chef/audit/runner.rb +4 -2
- data/lib/chef/chef_class.rb +62 -11
- data/lib/chef/client.rb +587 -207
- data/lib/chef/config.rb +0 -1
- data/lib/chef/dsl/recipe.rb +45 -56
- data/lib/chef/dsl/resources.rb +3 -2
- data/lib/chef/event_dispatch/base.rb +7 -2
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_content_management/deploy/mv_windows.rb +16 -6
- data/lib/chef/formatters/doc.rb +15 -7
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +10 -7
- data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -0
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +4 -1
- data/lib/chef/http/authenticator.rb +7 -2
- data/lib/chef/knife.rb +16 -4
- data/lib/chef/knife/client_create.rb +55 -31
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/osc_user_create.rb +97 -0
- data/lib/chef/knife/osc_user_delete.rb +51 -0
- data/lib/chef/knife/osc_user_edit.rb +58 -0
- data/lib/chef/knife/osc_user_list.rb +47 -0
- data/lib/chef/knife/osc_user_reregister.rb +64 -0
- data/lib/chef/knife/osc_user_show.rb +54 -0
- data/lib/chef/knife/user_create.rb +95 -36
- data/lib/chef/knife/user_delete.rb +52 -2
- data/lib/chef/knife/user_edit.rb +37 -7
- data/lib/chef/knife/user_list.rb +3 -0
- data/lib/chef/knife/user_reregister.rb +39 -8
- data/lib/chef/knife/user_show.rb +30 -1
- data/lib/chef/mixin/api_version_request_handling.rb +66 -0
- data/lib/chef/mixin/convert_to_class_name.rb +10 -4
- data/lib/chef/mixin/deprecation.rb +24 -0
- data/lib/chef/mixin/powershell_out.rb +98 -0
- data/lib/chef/mixin/provides.rb +5 -18
- data/lib/chef/mixin/uris.rb +11 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +5 -2
- data/lib/chef/mixin/windows_env_helper.rb +11 -2
- data/lib/chef/node_map.rb +130 -75
- data/lib/chef/osc_user.rb +194 -0
- data/lib/chef/platform/provider_mapping.rb +2 -269
- data/lib/chef/platform/provider_priority_map.rb +6 -69
- data/lib/chef/platform/query_helpers.rb +5 -0
- data/lib/chef/platform/resource_priority_map.rb +12 -15
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/provider.rb +19 -0
- data/lib/chef/provider/directory.rb +3 -0
- data/lib/chef/provider/dsc_resource.rb +8 -1
- data/lib/chef/provider/file.rb +1 -0
- data/lib/chef/provider/group/aix.rb +1 -0
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/group/gpasswd.rb +1 -0
- data/lib/chef/provider/group/groupmod.rb +1 -1
- data/lib/chef/provider/group/pw.rb +1 -0
- data/lib/chef/provider/group/suse.rb +2 -0
- data/lib/chef/provider/group/usermod.rb +2 -1
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -0
- data/lib/chef/provider/ifconfig/aix.rb +1 -0
- data/lib/chef/provider/ifconfig/debian.rb +2 -0
- data/lib/chef/provider/ifconfig/redhat.rb +1 -0
- data/lib/chef/provider/lwrp_base.rb +4 -0
- data/lib/chef/provider/mount.rb +0 -1
- data/lib/chef/provider/mount/aix.rb +1 -0
- data/lib/chef/provider/mount/mount.rb +2 -0
- data/lib/chef/provider/mount/solaris.rb +2 -0
- data/lib/chef/provider/package.rb +55 -0
- data/lib/chef/provider/package/aix.rb +7 -7
- data/lib/chef/provider/package/apt.rb +3 -3
- data/lib/chef/provider/package/dpkg.rb +4 -4
- data/lib/chef/provider/package/easy_install.rb +5 -5
- data/lib/chef/provider/package/freebsd/base.rb +2 -2
- data/lib/chef/provider/package/freebsd/pkg.rb +6 -6
- data/lib/chef/provider/package/freebsd/pkgng.rb +5 -5
- data/lib/chef/provider/package/freebsd/port.rb +4 -4
- data/lib/chef/provider/package/homebrew.rb +2 -2
- data/lib/chef/provider/package/ips.rb +4 -4
- data/lib/chef/provider/package/macports.rb +5 -6
- data/lib/chef/provider/package/openbsd.rb +4 -5
- data/lib/chef/provider/package/pacman.rb +4 -4
- data/lib/chef/provider/package/portage.rb +2 -0
- data/lib/chef/provider/package/rpm.rb +7 -8
- data/lib/chef/provider/package/rubygems.rb +5 -12
- data/lib/chef/provider/package/smartos.rb +4 -4
- data/lib/chef/provider/package/solaris.rb +7 -7
- data/lib/chef/provider/package/windows/msi.rb +1 -1
- data/lib/chef/provider/package/yum.rb +4 -6
- data/lib/chef/provider/package/zypper.rb +16 -14
- data/lib/chef/provider/powershell_script.rb +129 -47
- data/lib/chef/provider/remote_file/content.rb +4 -1
- data/lib/chef/provider/remote_file/local_file.rb +10 -4
- data/lib/chef/provider/service.rb +44 -0
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/init.rb +1 -0
- data/lib/chef/provider/service/macosx.rb +1 -1
- data/lib/chef/provider/service/windows.rb +0 -1
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/aix.rb +3 -2
- data/lib/chef/provider/user/pw.rb +1 -0
- data/lib/chef/provider/user/solaris.rb +2 -0
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/provider_resolver.rb +87 -134
- data/lib/chef/resource.rb +274 -68
- data/lib/chef/resource/apt_package.rb +0 -2
- data/lib/chef/resource/bash.rb +0 -2
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +0 -7
- data/lib/chef/resource/breakpoint.rb +3 -6
- data/lib/chef/resource/chef_gem.rb +0 -3
- data/lib/chef/resource/cookbook_file.rb +1 -3
- data/lib/chef/resource/cron.rb +2 -4
- data/lib/chef/resource/csh.rb +0 -2
- data/lib/chef/resource/deploy.rb +9 -6
- data/lib/chef/resource/deploy_revision.rb +0 -14
- data/lib/chef/resource/directory.rb +2 -4
- data/lib/chef/resource/dpkg_package.rb +0 -5
- data/lib/chef/resource/dsc_resource.rb +2 -3
- data/lib/chef/resource/dsc_script.rb +2 -3
- data/lib/chef/resource/easy_install_package.rb +0 -7
- data/lib/chef/resource/env.rb +3 -3
- data/lib/chef/resource/erl_call.rb +2 -5
- data/lib/chef/resource/execute.rb +2 -4
- data/lib/chef/resource/file.rb +2 -4
- data/lib/chef/resource/freebsd_package.rb +0 -5
- data/lib/chef/resource/gem_package.rb +0 -3
- data/lib/chef/resource/git.rb +0 -3
- data/lib/chef/resource/group.rb +2 -4
- data/lib/chef/resource/homebrew_package.rb +0 -2
- data/lib/chef/resource/http_request.rb +3 -4
- data/lib/chef/resource/ifconfig.rb +3 -4
- data/lib/chef/resource/ips_package.rb +2 -2
- data/lib/chef/resource/link.rb +3 -5
- data/lib/chef/resource/log.rb +2 -4
- data/lib/chef/resource/lwrp_base.rb +10 -61
- data/lib/chef/resource/macosx_service.rb +1 -2
- data/lib/chef/resource/macports_package.rb +0 -7
- data/lib/chef/resource/mdadm.rb +2 -5
- data/lib/chef/resource/mount.rb +2 -4
- data/lib/chef/resource/ohai.rb +2 -4
- data/lib/chef/resource/openbsd_package.rb +0 -6
- data/lib/chef/resource/package.rb +9 -6
- data/lib/chef/resource/pacman_package.rb +0 -7
- data/lib/chef/resource/paludis_package.rb +2 -3
- data/lib/chef/resource/perl.rb +0 -3
- data/lib/chef/resource/portage_package.rb +0 -3
- data/lib/chef/resource/powershell_script.rb +1 -2
- data/lib/chef/resource/python.rb +0 -3
- data/lib/chef/resource/reboot.rb +1 -3
- data/lib/chef/resource/registry_key.rb +3 -5
- data/lib/chef/resource/remote_directory.rb +3 -5
- data/lib/chef/resource/remote_file.rb +4 -5
- data/lib/chef/resource/route.rb +3 -5
- data/lib/chef/resource/rpm_package.rb +0 -2
- data/lib/chef/resource/ruby.rb +0 -4
- data/lib/chef/resource/ruby_block.rb +2 -4
- data/lib/chef/resource/scm.rb +3 -5
- data/lib/chef/resource/script.rb +0 -3
- data/lib/chef/resource/service.rb +3 -5
- data/lib/chef/resource/smartos_package.rb +0 -9
- data/lib/chef/resource/solaris_package.rb +0 -10
- data/lib/chef/resource/subversion.rb +1 -3
- data/lib/chef/resource/template.rb +0 -4
- data/lib/chef/resource/timestamped_deploy.rb +0 -4
- data/lib/chef/resource/user.rb +2 -5
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -7
- data/lib/chef/resource/windows_package.rb +3 -3
- data/lib/chef/resource/windows_script.rb +2 -2
- data/lib/chef/resource/windows_service.rb +3 -3
- data/lib/chef/resource/yum_package.rb +0 -3
- data/lib/chef/resource/zypper_package.rb +27 -0
- data/lib/chef/resource_builder.rb +7 -0
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resource_resolver.rb +108 -62
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/rest.rb +1 -0
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/user.rb +193 -42
- data/lib/chef/util/backup.rb +9 -1
- data/lib/chef/util/path_helper.rb +0 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +22 -42
- data/spec/functional/mixin/powershell_out_spec.rb +43 -0
- data/spec/functional/resource/execute_spec.rb +9 -2
- data/spec/functional/resource/file_spec.rb +25 -0
- data/spec/functional/resource/group_spec.rb +5 -0
- data/spec/functional/resource/link_spec.rb +5 -11
- data/spec/functional/resource/powershell_spec.rb +40 -5
- data/spec/functional/resource/user/useradd_spec.rb +10 -18
- data/spec/integration/recipes/lwrp_spec.rb +57 -0
- data/spec/integration/recipes/provider_choice.rb +2 -7
- data/spec/integration/recipes/recipe_dsl_spec.rb +517 -19
- data/spec/spec_helper.rb +1 -1
- data/spec/support/lib/chef/provider/openldap_includer.rb +29 -0
- data/spec/support/lib/chef/resource/cat.rb +0 -2
- data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -6
- data/spec/support/lib/chef/resource/openldap_includer.rb +27 -0
- data/spec/support/lib/chef/resource/with_state.rb +0 -9
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -6
- data/spec/support/lib/chef/resource/zen_master.rb +1 -6
- data/spec/support/shared/context/client.rb +277 -0
- data/spec/support/shared/examples/client.rb +53 -0
- data/spec/support/shared/functional/file_resource.rb +0 -4
- data/spec/support/shared/functional/securable_resource.rb +0 -24
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +4 -4
- data/spec/support/shared/functional/windows_script.rb +1 -1
- data/spec/support/shared/unit/api_versioning.rb +77 -0
- data/spec/support/shared/unit/knife_shared.rb +40 -0
- data/spec/support/shared/unit/user_and_client_shared.rb +115 -0
- data/spec/unit/api_client_spec.rb +189 -14
- data/spec/unit/application/client_spec.rb +0 -5
- data/spec/unit/audit/audit_reporter_spec.rb +58 -14
- data/spec/unit/audit/logger_spec.rb +42 -0
- data/spec/unit/audit/runner_spec.rb +2 -2
- data/spec/unit/chef_fs/file_pattern_spec.rb +3 -15
- data/spec/unit/client_spec.rb +58 -374
- data/spec/unit/cookbook_spec.rb +0 -9
- data/spec/unit/cookbook_version_spec.rb +0 -20
- data/spec/unit/deprecation_spec.rb +55 -0
- data/spec/unit/dsl/resources_spec.rb +85 -0
- data/spec/unit/exceptions_spec.rb +2 -2
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +60 -0
- data/spec/unit/formatters/doc_spec.rb +46 -0
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +12 -10
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +8 -0
- data/spec/unit/http/authenticator_spec.rb +11 -2
- data/spec/unit/knife/client_create_spec.rb +122 -51
- data/spec/unit/knife/core/subcommand_loader_spec.rb +19 -3
- data/spec/unit/knife/core/ui_spec.rb +14 -0
- data/spec/unit/knife/osc_user_create_spec.rb +93 -0
- data/spec/unit/knife/osc_user_delete_spec.rb +44 -0
- data/spec/unit/knife/osc_user_edit_spec.rb +52 -0
- data/spec/unit/knife/osc_user_list_spec.rb +37 -0
- data/spec/unit/knife/osc_user_reregister_spec.rb +58 -0
- data/spec/unit/knife/osc_user_show_spec.rb +46 -0
- data/spec/unit/knife/user_create_spec.rb +177 -51
- data/spec/unit/knife/user_delete_spec.rb +34 -8
- data/spec/unit/knife/user_edit_spec.rb +31 -12
- data/spec/unit/knife/user_list_spec.rb +7 -3
- data/spec/unit/knife/user_reregister_spec.rb +38 -17
- data/spec/unit/knife/user_show_spec.rb +35 -11
- data/spec/unit/knife_spec.rb +10 -4
- data/spec/unit/lwrp_spec.rb +228 -54
- data/spec/unit/mixin/api_version_request_handling_spec.rb +127 -0
- data/spec/unit/mixin/command_spec.rb +1 -2
- data/spec/unit/mixin/powershell_out_spec.rb +70 -0
- data/spec/unit/mixin/uris_spec.rb +23 -11
- data/spec/unit/node_map_spec.rb +4 -1
- data/spec/unit/osc_user_spec.rb +276 -0
- data/spec/unit/platform_spec.rb +0 -60
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +199 -135
- data/spec/unit/provider/ifconfig/debian_spec.rb +0 -10
- data/spec/unit/provider/package/aix_spec.rb +16 -16
- data/spec/unit/provider/package/dpkg_spec.rb +2 -2
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +13 -13
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +7 -7
- data/spec/unit/provider/package/ips_spec.rb +22 -22
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +4 -26
- data/spec/unit/provider/package/pacman_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +14 -14
- data/spec/unit/provider/package/rubygems_spec.rb +10 -44
- data/spec/unit/provider/package/smartos_spec.rb +4 -4
- data/spec/unit/provider/package/solaris_spec.rb +11 -11
- data/spec/unit/provider/package/zypper_spec.rb +125 -90
- data/spec/unit/provider/package_spec.rb +34 -0
- data/spec/unit/provider/powershell_spec.rb +53 -11
- data/spec/unit/provider/remote_directory_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +25 -6
- data/spec/unit/provider/service/freebsd_service_spec.rb +0 -12
- data/spec/unit/provider/user_spec.rb +3 -3
- data/spec/unit/provider_resolver_spec.rb +463 -327
- data/spec/unit/recipe_spec.rb +42 -15
- data/spec/unit/resource/breakpoint_spec.rb +1 -1
- data/spec/unit/resource/erl_call_spec.rb +1 -1
- data/spec/unit/resource/file_spec.rb +1 -1
- data/spec/unit/resource/ifconfig_spec.rb +10 -6
- data/spec/unit/resource/remote_file_spec.rb +5 -0
- data/spec/unit/resource/route_spec.rb +1 -1
- data/spec/unit/resource/ruby_block_spec.rb +2 -2
- data/spec/unit/resource/template_spec.rb +1 -1
- data/spec/unit/resource/timestamped_deploy_spec.rb +1 -2
- data/spec/unit/resource/windows_service_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +99 -13
- data/spec/unit/rest_spec.rb +5 -5
- data/spec/unit/run_context_spec.rb +41 -0
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/user_spec.rb +406 -93
- data/tasks/maintainers.rb +69 -0
- 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 =
|
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 =
|
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
|
-
|
37
|
+
shell_out_with_timeout!("pkg_add -r #{package_name}", :env => { "PACKAGESITE" => @new_resource.source, 'LC_ALL' => nil }).status
|
38
38
|
else
|
39
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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 =
|
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
|
-
|
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
|
-
|
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
|
-
|
38
|
+
shell_out_with_timeout!("pkg info \"#{@new_resource.package_name}\"", :env => nil, :returns => [0,70])
|
39
39
|
else
|
40
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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
|
-
|
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
|
-
|
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 =
|
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
|
-
|
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 =
|
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 =
|
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
|
-
|
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
|
-
|
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)
|
@@ -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
|
-
|
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 =
|
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
|
-
|
92
|
+
shell_out_with_timeout!( "rpm #{@new_resource.options} -i #{@new_resource.source}" )
|
94
93
|
else
|
95
94
|
if allow_downgrade
|
96
|
-
|
95
|
+
shell_out_with_timeout!( "rpm #{@new_resource.options} -U --oldpackage #{@new_resource.source}" )
|
97
96
|
else
|
98
|
-
|
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
|
-
|
106
|
+
shell_out_with_timeout!( "rpm #{@new_resource.options} -e #{name}-#{version}" )
|
108
107
|
else
|
109
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
567
|
+
shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :env=>nil)
|
575
568
|
else
|
576
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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
|
-
|
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 =
|
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 =
|
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
|
-
|
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
|
-
|
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
|
-
|
128
|
+
shell_out_with_timeout!( "pkgrm -n #{name}" )
|
129
129
|
Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
|
130
130
|
else
|
131
|
-
|
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
|