chef 12.18.31-universal-mingw32 → 12.19.33-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +5 -4
- data/README.md +12 -13
- data/VERSION +1 -1
- data/acceptance/Gemfile +4 -4
- data/acceptance/Gemfile.lock +70 -69
- data/chef-universal-mingw32.gemspec +2 -3
- data/chef.gemspec +6 -6
- data/lib/chef/api_client.rb +8 -10
- data/lib/chef/api_client_v1.rb +9 -11
- data/lib/chef/application/apply.rb +8 -10
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/exit_code.rb +3 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/windows_service.rb +29 -30
- data/lib/chef/application/windows_service_manager.rb +1 -1
- data/lib/chef/audit/audit_event_proxy.rb +2 -2
- data/lib/chef/audit/control_group_data.rb +1 -1
- data/lib/chef/chef_class.rb +1 -0
- data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
- data/lib/chef/chef_fs/command_line.rb +15 -16
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
- data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
- data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
- data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
- data/lib/chef/chef_fs/parallelizer.rb +9 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
- data/lib/chef/cookbook/metadata.rb +26 -26
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +3 -3
- data/lib/chef/data_collector.rb +3 -4
- data/lib/chef/decorator.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/audit.rb +2 -2
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +29 -31
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/dsl/resources.rb +6 -8
- data/lib/chef/encrypted_data_bag_item.rb +2 -2
- data/lib/chef/environment.rb +9 -11
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_access_control/unix.rb +14 -14
- data/lib/chef/file_access_control/windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
- data/lib/chef/formatters/error_mapper.rb +6 -6
- data/lib/chef/http/api_versions.rb +50 -0
- data/lib/chef/http/validate_content_length.rb +2 -2
- data/lib/chef/json_compat.rb +6 -10
- data/lib/chef/key.rb +5 -5
- data/lib/chef/knife.rb +4 -4
- data/lib/chef/knife/cookbook_site_install.rb +2 -2
- data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/ui.rb +19 -25
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/deps.rb +32 -34
- data/lib/chef/knife/help.rb +1 -1
- data/lib/chef/knife/list.rb +1 -1
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +37 -27
- data/lib/chef/knife/ssl_check.rb +1 -1
- data/lib/chef/knife/user_delete.rb +1 -1
- data/lib/chef/mash.rb +1 -1
- data/lib/chef/mixin/command.rb +2 -2
- data/lib/chef/mixin/create_path.rb +3 -5
- data/lib/chef/mixin/from_file.rb +2 -2
- data/lib/chef/mixin/get_source_from_package.rb +2 -2
- data/lib/chef/mixin/notifying_block.rb +7 -9
- data/lib/chef/mixin/params_validate.rb +3 -3
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +23 -3
- data/lib/chef/mixin/unformatter.rb +2 -2
- data/lib/chef/mixin/uris.rb +4 -6
- data/lib/chef/mixin/versioned_api.rb +69 -0
- data/lib/chef/mixin/which.rb +25 -8
- data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
- data/lib/chef/mixin/xml_escape.rb +3 -5
- data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
- data/lib/chef/node.rb +8 -8
- data/lib/chef/node/attribute.rb +4 -4
- data/lib/chef/node/common_api.rb +5 -7
- data/lib/chef/org.rb +10 -12
- data/lib/chef/platform/provider_mapping.rb +7 -7
- data/lib/chef/platform/query_helpers.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +31 -0
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/breakpoint.rb +1 -1
- data/lib/chef/provider/cookbook_file.rb +3 -3
- data/lib/chef/provider/cron.rb +38 -38
- data/lib/chef/provider/deploy.rb +81 -81
- data/lib/chef/provider/deploy/revision.rb +3 -5
- data/lib/chef/provider/directory.rb +32 -32
- data/lib/chef/provider/dsc_resource.rb +22 -6
- data/lib/chef/provider/env.rb +28 -28
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/erl_call.rb +13 -13
- data/lib/chef/provider/execute.rb +5 -2
- data/lib/chef/provider/file.rb +49 -51
- data/lib/chef/provider/git.rb +55 -55
- data/lib/chef/provider/http_request.rb +36 -36
- data/lib/chef/provider/launchd.rb +2 -2
- data/lib/chef/provider/link.rb +50 -50
- data/lib/chef/provider/log.rb +2 -2
- data/lib/chef/provider/mdadm.rb +25 -25
- data/lib/chef/provider/mount/aix.rb +2 -2
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/ohai.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +23 -23
- data/lib/chef/provider/package.rb +74 -56
- data/lib/chef/provider/package/aix.rb +55 -52
- data/lib/chef/provider/package/apt.rb +15 -13
- data/lib/chef/provider/package/cab.rb +49 -20
- data/lib/chef/provider/package/chocolatey.rb +9 -10
- data/lib/chef/provider/package/dnf.rb +20 -18
- data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
- data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
- data/lib/chef/provider/package/dnf/version.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +8 -9
- data/lib/chef/provider/package/easy_install.rb +22 -22
- data/lib/chef/provider/package/freebsd/base.rb +10 -10
- data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
- data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
- data/lib/chef/provider/package/freebsd/port.rb +7 -7
- data/lib/chef/provider/package/homebrew.rb +11 -10
- data/lib/chef/provider/package/ips.rb +18 -23
- data/lib/chef/provider/package/macports.rb +23 -23
- data/lib/chef/provider/package/msu.rb +11 -11
- data/lib/chef/provider/package/openbsd.rb +25 -22
- data/lib/chef/provider/package/pacman.rb +16 -16
- data/lib/chef/provider/package/paludis.rb +26 -27
- data/lib/chef/provider/package/portage.rb +22 -22
- data/lib/chef/provider/package/powershell.rb +17 -17
- data/lib/chef/provider/package/rpm.rb +25 -25
- data/lib/chef/provider/package/rubygems.rb +60 -60
- data/lib/chef/provider/package/smartos.rb +16 -16
- data/lib/chef/provider/package/solaris.rb +44 -44
- data/lib/chef/provider/package/windows.rb +3 -3
- data/lib/chef/provider/package/windows/exe.rb +6 -6
- data/lib/chef/provider/package/windows/msi.rb +6 -6
- data/lib/chef/provider/package/yum.rb +318 -268
- data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
- data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
- data/lib/chef/provider/package/zypper.rb +11 -11
- data/lib/chef/provider/powershell_script.rb +15 -7
- data/lib/chef/provider/reboot.rb +10 -10
- data/lib/chef/provider/registry_key.rb +39 -39
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file.rb +3 -3
- data/lib/chef/provider/route.rb +1 -1
- data/lib/chef/provider/ruby_block.rb +3 -3
- data/lib/chef/provider/script.rb +42 -6
- data/lib/chef/provider/service.rb +49 -49
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +39 -39
- data/lib/chef/provider/systemd_unit.rb +2 -0
- data/lib/chef/provider/template.rb +3 -3
- data/lib/chef/provider/user.rb +42 -42
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
- data/lib/chef/resource.rb +27 -16
- data/lib/chef/resource/apt_repository.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +6 -3
- data/lib/chef/resource/dsc_resource.rb +9 -1
- data/lib/chef/resource/execute.rb +70 -6
- data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +1 -1
- data/lib/chef/resource/launchd.rb +13 -1
- data/lib/chef/resource/package.rb +2 -2
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/yum_package.rb +12 -3
- data/lib/chef/resource/yum_repository.rb +0 -1
- data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
- data/lib/chef/resource_collection/resource_set.rb +2 -2
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/run_list/run_list_item.rb +1 -1
- data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/server_api_versions.rb +40 -0
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/user.rb +9 -11
- data/lib/chef/user_v1.rb +9 -11
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/net_group.rb +18 -30
- data/lib/chef/util/windows/net_use.rb +7 -11
- data/lib/chef/util/windows/net_user.rb +11 -17
- data/lib/chef/util/windows/volume.rb +9 -15
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +1 -1
- data/lib/chef/win32/api.rb +4 -6
- data/lib/chef/win32/api/file.rb +25 -31
- data/lib/chef/win32/api/installer.rb +2 -2
- data/lib/chef/win32/file.rb +4 -6
- data/lib/chef/win32/registry.rb +9 -9
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/acl.rb +2 -2
- data/lib/chef/win32/unicode.rb +2 -2
- data/lib/chef/win32/version.rb +1 -1
- data/spec/data/prefer_metadata_json/metadata.json +51 -0
- data/spec/data/prefer_metadata_json/metadata.rb +6 -0
- data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/resource/batch_spec.rb +5 -1
- data/spec/functional/resource/dsc_script_spec.rb +2 -4
- data/spec/functional/resource/execute_spec.rb +17 -0
- data/spec/functional/resource/user/dscl_spec.rb +2 -4
- data/spec/integration/client/client_spec.rb +33 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
- data/spec/spec_helper.rb +4 -0
- data/spec/support/chef_helpers.rb +5 -7
- data/spec/support/platform_helpers.rb +6 -0
- data/spec/support/platforms/prof/gc.rb +4 -6
- data/spec/support/shared/context/client.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +150 -0
- data/spec/support/shared/functional/windows_script.rb +74 -4
- data/spec/support/shared/unit/execute_resource.rb +37 -0
- data/spec/support/shared/unit/provider/file.rb +10 -0
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
- data/spec/unit/http/api_versions_spec.rb +69 -0
- data/spec/unit/knife/ssh_spec.rb +34 -36
- data/spec/unit/mixin/versioned_api_spec.rb +107 -0
- data/spec/unit/mixin/which.rb +160 -0
- data/spec/unit/platform_spec.rb +28 -1
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +10 -0
- data/spec/unit/provider/dsc_resource_spec.rb +175 -0
- data/spec/unit/provider/execute_spec.rb +0 -1
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/package/aix_spec.rb +22 -22
- data/spec/unit/provider/package/apt_spec.rb +27 -27
- data/spec/unit/provider/package/cab_spec.rb +59 -5
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
- data/spec/unit/provider/package/dpkg_spec.rb +16 -16
- data/spec/unit/provider/package/easy_install_spec.rb +18 -18
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
- data/spec/unit/provider/package/homebrew_spec.rb +9 -9
- data/spec/unit/provider/package/ips_spec.rb +37 -31
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +10 -10
- data/spec/unit/provider/package/pacman_spec.rb +6 -6
- data/spec/unit/provider/package/paludis_spec.rb +7 -7
- data/spec/unit/provider/package/portage_spec.rb +6 -7
- data/spec/unit/provider/package/rpm_spec.rb +23 -23
- data/spec/unit/provider/package/rubygems_spec.rb +38 -38
- data/spec/unit/provider/package/solaris_spec.rb +15 -15
- data/spec/unit/provider/package/windows_spec.rb +2 -1
- data/spec/unit/provider/package/yum_spec.rb +51 -43
- data/spec/unit/provider/package/zypper_spec.rb +34 -34
- data/spec/unit/provider/package_spec.rb +8 -0
- data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
- data/spec/unit/provider/route_spec.rb +7 -1
- data/spec/unit/provider/script_spec.rb +49 -6
- data/spec/unit/resource/dsc_resource_spec.rb +6 -0
- data/spec/unit/resource/execute_spec.rb +214 -0
- data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
- data/spec/unit/resource/freebsd_package_spec.rb +2 -2
- data/spec/unit/resource/package_spec.rb +5 -0
- data/spec/unit/resource/yum_package_spec.rb +42 -1
- data/spec/unit/resource_reporter_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +18 -0
- data/spec/unit/server_api_versions_spec.rb +44 -0
- data/spec/unit/util/selinux_spec.rb +3 -14
- data/spec/unit/win32/error_spec.rb +67 -0
- data/spec/unit/win32/security_spec.rb +66 -0
- data/tasks/changelog.rb +1 -1
- data/tasks/dependencies.rb +20 -4
- metadata +39 -18
- data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
@@ -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",
|
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",
|
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",
|
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 =
|
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
|
-
|
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
|
-
|
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 =
|
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 =
|
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 =
|
39
|
-
if output.downcase.include?
|
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 =
|
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 =
|
58
|
+
path = new_resource.python_binary
|
59
59
|
path ? path : "python"
|
60
60
|
end
|
61
61
|
|
62
62
|
def module_name
|
63
|
-
m =
|
64
|
-
m ? m :
|
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(
|
69
|
-
|
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 =
|
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 =
|
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?(
|
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 ==
|
95
|
-
Chef::Log.debug("#{
|
96
|
-
|
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("#{
|
99
|
-
|
98
|
+
Chef::Log.debug("#{new_resource} at version #{package_version}")
|
99
|
+
current_resource.version(package_version)
|
100
100
|
end
|
101
101
|
|
102
|
-
|
102
|
+
current_resource
|
103
103
|
end
|
104
104
|
|
105
105
|
def candidate_version
|
106
106
|
return @candidate_version if @candidate_version
|
107
107
|
|
108
|
-
|
109
|
-
result =
|
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
|
-
|
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
|
-
|
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 =
|
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 ? { :
|
60
|
-
make_v =
|
61
|
-
make_v.exitstatus == 0 ? make_v.stdout.strip.split(
|
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(
|
70
|
+
@current_resource = Chef::Resource::Package.new(new_resource.name)
|
71
71
|
end
|
72
72
|
|
73
73
|
def load_current_resource
|
74
|
-
|
74
|
+
current_resource.package_name(new_resource.package_name)
|
75
75
|
|
76
|
-
|
77
|
-
Chef::Log.debug("#{
|
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("#{
|
80
|
+
Chef::Log.debug("#{new_resource} candidate version is #{@candidate_version}") if @candidate_version
|
81
81
|
|
82
|
-
|
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
|
34
|
-
case
|
33
|
+
unless current_resource.version
|
34
|
+
case new_resource.source
|
35
35
|
when /^http/, /^ftp/
|
36
|
-
if
|
37
|
-
|
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
|
-
|
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("#{
|
41
|
+
Chef::Log.debug("#{new_resource} installed from: #{new_resource.source}")
|
42
42
|
|
43
43
|
when /^\//
|
44
|
-
|
45
|
-
Chef::Log.debug("#{
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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
|
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("#{
|
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
|
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
|
29
|
-
case
|
28
|
+
unless current_resource.version
|
29
|
+
case new_resource.source
|
30
30
|
when /^(http|ftp|\/)/
|
31
|
-
|
32
|
-
Chef::Log.debug("#{
|
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
|
-
|
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
|
-
|
42
|
-
|
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 =
|
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
|
-
|
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
|
-
|
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
|
63
|
-
options = $1
|
60
|
+
if options && options.join(" ").match(repo_regex)
|
61
|
+
options = $1.split(" ")
|
64
62
|
end
|
65
63
|
|
66
|
-
pkg_query =
|
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
|
-
|
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
|
-
|
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
|
38
|
-
|
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
|
-
|
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(
|
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(
|
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::
|
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",
|
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",
|
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",
|
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
|
-
|
72
|
-
|
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
|
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 =
|
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
|
|