chef 12.18.31-universal-mingw32 → 12.19.33-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -32,14 +32,14 @@ class Chef
|
|
32
32
|
PACKAGE_NAME_PATTERN = %r{(?:([^/]+)/)?([^/]+)}
|
33
33
|
|
34
34
|
def load_current_resource
|
35
|
-
@current_resource = Chef::Resource::Package.new(
|
36
|
-
|
35
|
+
@current_resource = Chef::Resource::Package.new(new_resource.name)
|
36
|
+
current_resource.package_name(new_resource.package_name)
|
37
37
|
|
38
|
-
category, pkg =
|
38
|
+
category, pkg = /^#{PACKAGE_NAME_PATTERN}$/.match(new_resource.package_name)[1, 2]
|
39
39
|
|
40
40
|
globsafe_category = category ? Chef::Util::PathHelper.escape_glob_dir(category) : nil
|
41
41
|
globsafe_pkg = Chef::Util::PathHelper.escape_glob_dir(pkg)
|
42
|
-
possibilities = Dir["/var/db/pkg/#{globsafe_category ||
|
42
|
+
possibilities = Dir["/var/db/pkg/#{globsafe_category || '*'}/#{globsafe_pkg}-*"].map { |d| d.sub(%r{/var/db/pkg/}, "") }
|
43
43
|
versions = possibilities.map do |entry|
|
44
44
|
if entry =~ %r{[^/]+/#{Regexp.escape(pkg)}\-(\d[\.\d]*[a-z]?((_(alpha|beta|pre|rc|p)\d*)*)?(-r\d+)?)}
|
45
45
|
[$&, $1]
|
@@ -47,17 +47,17 @@ class Chef
|
|
47
47
|
end.compact
|
48
48
|
|
49
49
|
if versions.size > 1
|
50
|
-
atoms = versions.map
|
50
|
+
atoms = versions.map(&:first).sort
|
51
51
|
categories = atoms.map { |v| v.split("/")[0] }.uniq
|
52
52
|
if !category && categories.size > 1
|
53
|
-
raise Chef::Exceptions::Package, "Multiple packages found for #{
|
53
|
+
raise Chef::Exceptions::Package, "Multiple packages found for #{new_resource.package_name}: #{atoms.join(' ')}. Specify a category."
|
54
54
|
end
|
55
55
|
elsif versions.size == 1
|
56
|
-
|
57
|
-
Chef::Log.debug("#{
|
56
|
+
current_resource.version(versions.first.last)
|
57
|
+
Chef::Log.debug("#{new_resource} current version #{$1}")
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
current_resource
|
61
61
|
end
|
62
62
|
|
63
63
|
def parse_emerge(package, txt)
|
@@ -67,25 +67,25 @@ class Chef
|
|
67
67
|
txt.each_line do |line|
|
68
68
|
if line =~ /\*\s+#{PACKAGE_NAME_PATTERN}/
|
69
69
|
found_package_name = $&.delete("*").strip
|
70
|
-
if package =~ /\// #the category is specified
|
70
|
+
if package =~ /\// # the category is specified
|
71
71
|
if found_package_name == package
|
72
72
|
availables[found_package_name] = nil
|
73
73
|
end
|
74
|
-
else #the category is not specified
|
74
|
+
else # the category is not specified
|
75
75
|
if found_package_name.split("/").last == package
|
76
76
|
availables[found_package_name] = nil
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
if line =~ /Latest version available: (.*)/ && availables.
|
81
|
+
if line =~ /Latest version available: (.*)/ && availables.key?(found_package_name)
|
82
82
|
availables[found_package_name] = $1.strip
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
if availables.size > 1
|
87
87
|
# shouldn't happen if a category is specified so just use `package`
|
88
|
-
raise Chef::Exceptions::Package, "Multiple emerge results found for #{package}: #{availables.keys.join(
|
88
|
+
raise Chef::Exceptions::Package, "Multiple emerge results found for #{package}: #{availables.keys.join(' ')}. Specify a category."
|
89
89
|
end
|
90
90
|
|
91
91
|
availables.values.first
|
@@ -94,8 +94,8 @@ class Chef
|
|
94
94
|
def candidate_version
|
95
95
|
return @candidate_version if @candidate_version
|
96
96
|
|
97
|
-
status =
|
98
|
-
available, installed = parse_emerge(
|
97
|
+
status = shell_out_compact("emerge", "--color", "n", "--nospinner", "--search", new_resource.package_name.split("/").last)
|
98
|
+
available, installed = parse_emerge(new_resource.package_name, status.stdout)
|
99
99
|
@candidate_version = available
|
100
100
|
|
101
101
|
unless status.exitstatus == 0
|
@@ -113,7 +113,7 @@ class Chef
|
|
113
113
|
pkg = "~#{name}-#{$1}"
|
114
114
|
end
|
115
115
|
|
116
|
-
|
116
|
+
shell_out_compact!( "emerge", "-g", "--color", "n", "--nospinner", "--quiet", options, pkg )
|
117
117
|
end
|
118
118
|
|
119
119
|
def upgrade_package(name, version)
|
@@ -121,13 +121,13 @@ class Chef
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def remove_package(name, version)
|
124
|
-
if version
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
124
|
+
pkg = if version
|
125
|
+
"=#{new_resource.package_name}-#{version}"
|
126
|
+
else
|
127
|
+
new_resource.package_name.to_s
|
128
|
+
end
|
129
129
|
|
130
|
-
|
130
|
+
shell_out_compact!( "emerge", "--unmerge", "--color", "n", "--nospinner", "--quiet", options, pkg )
|
131
131
|
end
|
132
132
|
|
133
133
|
def purge_package(name, version)
|
@@ -36,13 +36,13 @@ class Chef
|
|
36
36
|
|
37
37
|
def define_resource_requirements
|
38
38
|
super
|
39
|
-
if powershell_out("$PSVersionTable.PSVersion.Major").stdout.strip
|
39
|
+
if powershell_out("$PSVersionTable.PSVersion.Major").stdout.strip.to_i < 5
|
40
40
|
raise "Minimum installed Powershell Version required is 5"
|
41
41
|
end
|
42
42
|
requirements.assert(:install) do |a|
|
43
43
|
a.assertion { candidates_exist_for_all_uninstalled? }
|
44
|
-
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(
|
45
|
-
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(
|
44
|
+
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(', ')}")
|
45
|
+
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(', ')} would have been configured")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -53,7 +53,7 @@ class Chef
|
|
53
53
|
# Installs the package specified with the version passed else latest version will be installed
|
54
54
|
def install_package(names, versions)
|
55
55
|
names.each_with_index do |name, index|
|
56
|
-
powershell_out("Install-Package '#{name}' -Force -ForceBootstrap -RequiredVersion #{versions[index]}",
|
56
|
+
powershell_out("Install-Package '#{name}' -Force -ForceBootstrap -RequiredVersion #{versions[index]}", timeout: new_resource.timeout)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -61,12 +61,12 @@ class Chef
|
|
61
61
|
def remove_package(names, versions)
|
62
62
|
names.each_with_index do |name, index|
|
63
63
|
if versions && !versions[index].nil?
|
64
|
-
powershell_out( "Uninstall-Package '#{name}' -Force -ForceBootstrap -RequiredVersion #{versions[index]}",
|
64
|
+
powershell_out( "Uninstall-Package '#{name}' -Force -ForceBootstrap -RequiredVersion #{versions[index]}", timeout: new_resource.timeout)
|
65
65
|
else
|
66
66
|
version = "0"
|
67
67
|
until version.empty?
|
68
|
-
version = powershell_out( "(Uninstall-Package '#{name}' -Force -ForceBootstrap | select version | Format-Table -HideTableHeaders | Out-String).Trim()",
|
69
|
-
|
68
|
+
version = powershell_out( "(Uninstall-Package '#{name}' -Force -ForceBootstrap | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip
|
69
|
+
unless version.empty?
|
70
70
|
Chef::Log.info("Removed package '#{name}' with version #{version}")
|
71
71
|
end
|
72
72
|
end
|
@@ -78,11 +78,11 @@ class Chef
|
|
78
78
|
def build_candidate_versions
|
79
79
|
versions = []
|
80
80
|
new_resource.package_name.each_with_index do |name, index|
|
81
|
-
if new_resource.version && !new_resource.version[index].nil?
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
81
|
+
version = if new_resource.version && !new_resource.version[index].nil?
|
82
|
+
powershell_out("(Find-Package '#{name}' -RequiredVersion #{new_resource.version[index]} -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip
|
83
|
+
else
|
84
|
+
powershell_out("(Find-Package '#{name}' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip
|
85
|
+
end
|
86
86
|
if version.empty?
|
87
87
|
version = nil
|
88
88
|
end
|
@@ -95,11 +95,11 @@ class Chef
|
|
95
95
|
def build_current_versions
|
96
96
|
version_list = []
|
97
97
|
new_resource.package_name.each_with_index do |name, index|
|
98
|
-
if new_resource.version && !new_resource.version[index].nil?
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
98
|
+
version = if new_resource.version && !new_resource.version[index].nil?
|
99
|
+
powershell_out("(Get-Package -Name '#{name}' -RequiredVersion #{new_resource.version[index]} -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip
|
100
|
+
else
|
101
|
+
powershell_out("(Get-Package -Name '#{name}' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip
|
102
|
+
end
|
103
103
|
if version.empty?
|
104
104
|
version = nil
|
105
105
|
end
|
@@ -34,13 +34,13 @@ class Chef
|
|
34
34
|
|
35
35
|
requirements.assert(:all_actions) do |a|
|
36
36
|
a.assertion { @package_source_exists }
|
37
|
-
a.failure_message Chef::Exceptions::Package, "Package #{
|
38
|
-
a.whyrun "Assuming package #{
|
37
|
+
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.name} not found: #{new_resource.source}"
|
38
|
+
a.whyrun "Assuming package #{new_resource.name} would have been made available."
|
39
39
|
end
|
40
40
|
requirements.assert(:all_actions) do |a|
|
41
41
|
a.assertion { !@rpm_status.nil? && (@rpm_status.exitstatus == 0 || @rpm_status.exitstatus == 1) }
|
42
42
|
a.failure_message Chef::Exceptions::Package, "Unable to determine current version due to RPM failure. Detail: #{@rpm_status.inspect}"
|
43
|
-
a.whyrun "Assuming current version would have been determined for package#{
|
43
|
+
a.whyrun "Assuming current version would have been determined for package#{new_resource.name}."
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -48,63 +48,63 @@ class Chef
|
|
48
48
|
@package_source_provided = true
|
49
49
|
@package_source_exists = true
|
50
50
|
|
51
|
-
@current_resource = Chef::Resource::Package.new(
|
52
|
-
|
51
|
+
@current_resource = Chef::Resource::Package.new(new_resource.name)
|
52
|
+
current_resource.package_name(new_resource.package_name)
|
53
53
|
|
54
|
-
if
|
55
|
-
unless uri_scheme?(
|
54
|
+
if new_resource.source
|
55
|
+
unless uri_scheme?(new_resource.source) || ::File.exist?(new_resource.source)
|
56
56
|
@package_source_exists = false
|
57
57
|
return
|
58
58
|
end
|
59
59
|
|
60
|
-
Chef::Log.debug("#{
|
61
|
-
|
60
|
+
Chef::Log.debug("#{new_resource} checking rpm status")
|
61
|
+
shell_out_compact_timeout!("rpm", "-qp", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", new_resource.source).stdout.each_line do |line|
|
62
62
|
case line
|
63
63
|
when /^(\S+)\s(\S+)$/
|
64
|
-
|
65
|
-
|
64
|
+
current_resource.package_name($1)
|
65
|
+
new_resource.version($2)
|
66
66
|
@candidate_version = $2
|
67
67
|
end
|
68
68
|
end
|
69
69
|
else
|
70
|
-
if Array(
|
70
|
+
if Array(new_resource.action).include?(:install)
|
71
71
|
@package_source_exists = false
|
72
72
|
return
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
Chef::Log.debug("#{
|
77
|
-
@rpm_status =
|
76
|
+
Chef::Log.debug("#{new_resource} checking install state")
|
77
|
+
@rpm_status = shell_out_compact_timeout("rpm", "-q", "--queryformat", "%{NAME} %{VERSION}-%{RELEASE}\n", current_resource.package_name)
|
78
78
|
@rpm_status.stdout.each_line do |line|
|
79
79
|
case line
|
80
80
|
when /^(\S+)\s(\S+)$/
|
81
|
-
Chef::Log.debug("#{
|
82
|
-
|
81
|
+
Chef::Log.debug("#{new_resource} current version is #{$2}")
|
82
|
+
current_resource.version($2)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
current_resource
|
87
87
|
end
|
88
88
|
|
89
89
|
def install_package(name, version)
|
90
|
-
|
91
|
-
shell_out_with_timeout!( "rpm #{@new_resource.options} -i #{@new_resource.source}" )
|
92
|
-
else
|
90
|
+
if current_resource.version
|
93
91
|
if allow_downgrade
|
94
|
-
|
92
|
+
shell_out_compact_timeout!("rpm", options, "-U", "--oldpackage", new_resource.source)
|
95
93
|
else
|
96
|
-
|
94
|
+
shell_out_compact_timeout!("rpm", options, "-U", new_resource.source)
|
97
95
|
end
|
96
|
+
else
|
97
|
+
shell_out_compact_timeout!("rpm", options, "-i", new_resource.source)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
|
101
|
+
alias upgrade_package install_package
|
102
102
|
|
103
103
|
def remove_package(name, version)
|
104
104
|
if version
|
105
|
-
|
105
|
+
shell_out_compact_timeout!("rpm", options, "-e", "#{name}-#{version}")
|
106
106
|
else
|
107
|
-
|
107
|
+
shell_out_compact_timeout!("rpm", options, "-e", name)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
4
|
-
# Copyright:: Copyright 2008-2016, 2010-
|
4
|
+
# Copyright:: Copyright 2008-2016, 2010-2017, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -47,7 +47,7 @@ class Chef
|
|
47
47
|
# alternate value and overwrite it with the defaults.
|
48
48
|
Gem.configuration
|
49
49
|
|
50
|
-
DEFAULT_UNINSTALLER_OPTS = { :
|
50
|
+
DEFAULT_UNINSTALLER_OPTS = { ignore: true, executables: true }.freeze
|
51
51
|
|
52
52
|
##
|
53
53
|
# The paths where rubygems should search for installed gems.
|
@@ -133,11 +133,11 @@ class Chef
|
|
133
133
|
def candidate_version_from_file(gem_dependency, source)
|
134
134
|
spec = spec_from_file(source)
|
135
135
|
if spec.satisfies_requirement?(gem_dependency)
|
136
|
-
logger.debug { "
|
136
|
+
logger.debug { "found candidate gem version #{spec.version} from local gem package #{source}" }
|
137
137
|
spec.version
|
138
138
|
else
|
139
139
|
# This is probably going to end badly...
|
140
|
-
logger.warn { "
|
140
|
+
logger.warn { "gem package #{source} does not satisfy the requirements #{gem_dependency}" }
|
141
141
|
nil
|
142
142
|
end
|
143
143
|
end
|
@@ -178,11 +178,11 @@ class Chef
|
|
178
178
|
|
179
179
|
version = spec && spec.version
|
180
180
|
if version
|
181
|
-
logger.debug { "
|
181
|
+
logger.debug { "found gem #{spec.name} version #{version} for platform #{spec.platform} from #{source}" }
|
182
182
|
version
|
183
183
|
else
|
184
184
|
source_list = sources.compact.empty? ? "[#{Gem.sources.to_a.join(', ')}]" : "[#{sources.join(', ')}]"
|
185
|
-
logger.warn { "
|
185
|
+
logger.warn { "failed to find gem #{gem_dependency} from #{source_list}" }
|
186
186
|
nil
|
187
187
|
end
|
188
188
|
end
|
@@ -285,7 +285,7 @@ class Chef
|
|
285
285
|
# shellout! is a fork/exec which won't work on windows
|
286
286
|
shell_style_paths = shell_out!("#{@gem_binary_location} env gempath").stdout
|
287
287
|
# on windows, the path separator is (usually? always?) semicolon
|
288
|
-
paths = shell_style_paths.split(::File::PATH_SEPARATOR).map
|
288
|
+
paths = shell_style_paths.split(::File::PATH_SEPARATOR).map(&:strip)
|
289
289
|
self.class.gempath_cache[@gem_binary_location] = paths
|
290
290
|
end
|
291
291
|
end
|
@@ -322,11 +322,11 @@ class Chef
|
|
322
322
|
self.class.platform_cache[@gem_binary_location]
|
323
323
|
else
|
324
324
|
gem_environment = shell_out!("#{@gem_binary_location} env").stdout
|
325
|
-
if jruby = gem_environment[JRUBY_PLATFORM]
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
325
|
+
self.class.platform_cache[@gem_binary_location] = if jruby = gem_environment[JRUBY_PLATFORM]
|
326
|
+
["ruby", Gem::Platform.new(jruby)]
|
327
|
+
else
|
328
|
+
Gem.platforms
|
329
|
+
end
|
330
330
|
end
|
331
331
|
end
|
332
332
|
|
@@ -365,17 +365,17 @@ class Chef
|
|
365
365
|
super
|
366
366
|
@cleanup_gem_env = true
|
367
367
|
if new_resource.gem_binary
|
368
|
-
if new_resource.options && new_resource.options.
|
368
|
+
if new_resource.options && new_resource.options.is_a?(Hash)
|
369
369
|
msg = "options cannot be given as a hash when using an explicit gem_binary\n"
|
370
370
|
msg << "in #{new_resource} from #{new_resource.source_line}"
|
371
371
|
raise ArgumentError, msg
|
372
372
|
end
|
373
373
|
@gem_env = AlternateGemEnvironment.new(new_resource.gem_binary)
|
374
|
-
Chef::Log.debug("#{
|
375
|
-
elsif is_omnibus? && (
|
374
|
+
Chef::Log.debug("#{new_resource} using gem '#{new_resource.gem_binary}'")
|
375
|
+
elsif is_omnibus? && (!new_resource.instance_of? Chef::Resource::ChefGem)
|
376
376
|
# Opscode Omnibus - The ruby that ships inside omnibus is only used for Chef
|
377
377
|
# Default to installing somewhere more functional
|
378
|
-
if new_resource.options && new_resource.options.
|
378
|
+
if new_resource.options && new_resource.options.is_a?(Hash)
|
379
379
|
msg = [
|
380
380
|
"Gem options must be passed to gem_package as a string instead of a hash when",
|
381
381
|
"using this installation of Chef because it runs with its own packaged Ruby. A hash",
|
@@ -386,23 +386,23 @@ class Chef
|
|
386
386
|
raise ArgumentError, msg
|
387
387
|
end
|
388
388
|
gem_location = find_gem_by_path
|
389
|
-
|
389
|
+
new_resource.gem_binary gem_location
|
390
390
|
@gem_env = AlternateGemEnvironment.new(gem_location)
|
391
|
-
Chef::Log.debug("#{
|
391
|
+
Chef::Log.debug("#{new_resource} using gem '#{gem_location}'")
|
392
392
|
else
|
393
393
|
@gem_env = CurrentGemEnvironment.new
|
394
394
|
@cleanup_gem_env = false
|
395
|
-
Chef::Log.debug("#{
|
395
|
+
Chef::Log.debug("#{new_resource} using gem from running ruby environment")
|
396
396
|
end
|
397
397
|
end
|
398
398
|
|
399
399
|
def is_omnibus?
|
400
400
|
if RbConfig::CONFIG["bindir"] =~ %r{/(opscode|chef|chefdk)/embedded/bin}
|
401
|
-
Chef::Log.debug("#{
|
401
|
+
Chef::Log.debug("#{new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}")
|
402
402
|
# Omnibus installs to a static path because of linking on unix, find it.
|
403
403
|
true
|
404
404
|
elsif RbConfig::CONFIG["bindir"].sub(/^[\w]:/, "") == "/opscode/chef/embedded/bin"
|
405
|
-
Chef::Log.debug("#{
|
405
|
+
Chef::Log.debug("#{new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}")
|
406
406
|
# windows, with the drive letter removed
|
407
407
|
true
|
408
408
|
else
|
@@ -411,25 +411,25 @@ class Chef
|
|
411
411
|
end
|
412
412
|
|
413
413
|
def find_gem_by_path
|
414
|
-
Chef::Log.debug("#{
|
414
|
+
Chef::Log.debug("#{new_resource} searching for 'gem' binary in path: #{ENV['PATH']}")
|
415
415
|
separator = ::File::ALT_SEPARATOR ? ::File::ALT_SEPARATOR : ::File::SEPARATOR
|
416
|
-
path_to_first_gem = ENV["PATH"].split(::File::PATH_SEPARATOR).find { |path| ::File.
|
416
|
+
path_to_first_gem = ENV["PATH"].split(::File::PATH_SEPARATOR).find { |path| ::File.exist?(path + separator + "gem") }
|
417
417
|
raise Chef::Exceptions::FileNotFound, "Unable to find 'gem' binary in path: #{ENV['PATH']}" if path_to_first_gem.nil?
|
418
418
|
path_to_first_gem + separator + "gem"
|
419
419
|
end
|
420
420
|
|
421
421
|
def gem_dependency
|
422
|
-
Gem::Dependency.new(
|
422
|
+
Gem::Dependency.new(new_resource.package_name, new_resource.version)
|
423
423
|
end
|
424
424
|
|
425
425
|
def source_is_remote?
|
426
|
-
return true if
|
427
|
-
scheme = URI.parse(
|
426
|
+
return true if new_resource.source.nil?
|
427
|
+
scheme = URI.parse(new_resource.source).scheme
|
428
428
|
# URI.parse gets confused by MS Windows paths with forward slashes.
|
429
429
|
scheme = nil if scheme =~ /^[a-z]$/
|
430
430
|
%w{http https}.include?(scheme)
|
431
431
|
rescue URI::InvalidURIError
|
432
|
-
Chef::Log.debug("#{
|
432
|
+
Chef::Log.debug("#{new_resource} failed to parse source '#{new_resource.source}' as a URI, assuming a local path")
|
433
433
|
false
|
434
434
|
end
|
435
435
|
|
@@ -445,16 +445,16 @@ class Chef
|
|
445
445
|
# is the current version
|
446
446
|
if !matching_installed_versions.empty?
|
447
447
|
gemspec = matching_installed_versions.send(pos)
|
448
|
-
logger.debug { "#{
|
448
|
+
logger.debug { "#{new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}" }
|
449
449
|
gemspec
|
450
450
|
# If no version matching the requirements exists, the latest installed
|
451
451
|
# version is the current version.
|
452
452
|
elsif !all_installed_versions.empty?
|
453
453
|
gemspec = all_installed_versions.send(pos)
|
454
|
-
logger.debug { "#{
|
454
|
+
logger.debug { "#{new_resource} newest installed version of gem #{gemspec.name} is #{gemspec.version}" }
|
455
455
|
gemspec
|
456
456
|
else
|
457
|
-
logger.debug { "#{
|
457
|
+
logger.debug { "#{new_resource} no installed version found for #{gem_dependency}" }
|
458
458
|
nil
|
459
459
|
end
|
460
460
|
end
|
@@ -470,21 +470,21 @@ class Chef
|
|
470
470
|
end
|
471
471
|
|
472
472
|
def gem_sources
|
473
|
-
|
473
|
+
new_resource.source ? Array(new_resource.source) : nil
|
474
474
|
end
|
475
475
|
|
476
476
|
def load_current_resource
|
477
|
-
@current_resource = Chef::Resource::Package::GemPackage.new(
|
478
|
-
|
477
|
+
@current_resource = Chef::Resource::Package::GemPackage.new(new_resource.name)
|
478
|
+
current_resource.package_name(new_resource.package_name)
|
479
479
|
if current_spec = current_version
|
480
|
-
|
480
|
+
current_resource.version(current_spec.version.to_s)
|
481
481
|
end
|
482
|
-
|
482
|
+
current_resource
|
483
483
|
end
|
484
484
|
|
485
485
|
def cleanup_after_converge
|
486
486
|
if @cleanup_gem_env
|
487
|
-
logger.debug { "#{
|
487
|
+
logger.debug { "#{new_resource} resetting gem environment to default" }
|
488
488
|
Gem.clear_paths
|
489
489
|
end
|
490
490
|
end
|
@@ -494,7 +494,7 @@ class Chef
|
|
494
494
|
if source_is_remote?
|
495
495
|
@gem_env.candidate_version_from_remote(gem_dependency, *gem_sources).to_s
|
496
496
|
else
|
497
|
-
@gem_env.candidate_version_from_file(gem_dependency,
|
497
|
+
@gem_env.candidate_version_from_file(gem_dependency, new_resource.source).to_s
|
498
498
|
end
|
499
499
|
end
|
500
500
|
end
|
@@ -511,18 +511,18 @@ class Chef
|
|
511
511
|
# 2. shell out to `gem install` when a String of options is given
|
512
512
|
# 3. use gems API with options if a hash of options is given
|
513
513
|
def install_package(name, version)
|
514
|
-
if source_is_remote? &&
|
515
|
-
if
|
516
|
-
@gem_env.install(gem_dependency, :
|
517
|
-
elsif
|
518
|
-
options =
|
514
|
+
if source_is_remote? && new_resource.gem_binary.nil?
|
515
|
+
if new_resource.options.nil?
|
516
|
+
@gem_env.install(gem_dependency, sources: gem_sources)
|
517
|
+
elsif new_resource.options.is_a?(Hash)
|
518
|
+
options = new_resource.options
|
519
519
|
options[:sources] = gem_sources
|
520
520
|
@gem_env.install(gem_dependency, options)
|
521
521
|
else
|
522
522
|
install_via_gem_command(name, version)
|
523
523
|
end
|
524
|
-
elsif
|
525
|
-
@gem_env.install(
|
524
|
+
elsif new_resource.gem_binary.nil?
|
525
|
+
@gem_env.install(new_resource.source)
|
526
526
|
else
|
527
527
|
install_via_gem_command(name, version)
|
528
528
|
end
|
@@ -530,22 +530,22 @@ class Chef
|
|
530
530
|
end
|
531
531
|
|
532
532
|
def gem_binary_path
|
533
|
-
|
533
|
+
new_resource.gem_binary || "gem"
|
534
534
|
end
|
535
535
|
|
536
536
|
def install_via_gem_command(name, version)
|
537
|
-
if
|
538
|
-
name =
|
539
|
-
elsif
|
537
|
+
if new_resource.source =~ /\.gem$/i
|
538
|
+
name = new_resource.source
|
539
|
+
elsif new_resource.clear_sources
|
540
540
|
src = " --clear-sources"
|
541
|
-
src << (
|
541
|
+
src << (new_resource.source && " --source=#{new_resource.source}" || "")
|
542
542
|
else
|
543
|
-
src =
|
543
|
+
src = new_resource.source && " --source=#{new_resource.source} --source=#{Chef::Config[:rubygems_url]}"
|
544
544
|
end
|
545
|
-
if !version.nil? && version.
|
546
|
-
shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", :
|
545
|
+
if !version.nil? && !version.empty?
|
546
|
+
shell_out_with_timeout!("#{gem_binary_path} install #{name} -q --no-rdoc --no-ri -v \"#{version}\"#{src}#{opts}", env: nil)
|
547
547
|
else
|
548
|
-
shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", :
|
548
|
+
shell_out_with_timeout!("#{gem_binary_path} install \"#{name}\" -q --no-rdoc --no-ri #{src}#{opts}", env: nil)
|
549
549
|
end
|
550
550
|
end
|
551
551
|
|
@@ -554,11 +554,11 @@ class Chef
|
|
554
554
|
end
|
555
555
|
|
556
556
|
def remove_package(name, version)
|
557
|
-
if
|
558
|
-
if
|
557
|
+
if new_resource.gem_binary.nil?
|
558
|
+
if new_resource.options.nil?
|
559
559
|
@gem_env.uninstall(name, version)
|
560
|
-
elsif
|
561
|
-
@gem_env.uninstall(name, version,
|
560
|
+
elsif new_resource.options.is_a?(Hash)
|
561
|
+
@gem_env.uninstall(name, version, new_resource.options)
|
562
562
|
else
|
563
563
|
uninstall_via_gem_command(name, version)
|
564
564
|
end
|
@@ -569,9 +569,9 @@ class Chef
|
|
569
569
|
|
570
570
|
def uninstall_via_gem_command(name, version)
|
571
571
|
if version
|
572
|
-
shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", :
|
572
|
+
shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -v \"#{version}\"#{opts}", env: nil)
|
573
573
|
else
|
574
|
-
shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", :
|
574
|
+
shell_out_with_timeout!("#{gem_binary_path} uninstall #{name} -q -x -I -a#{opts}", env: nil)
|
575
575
|
end
|
576
576
|
end
|
577
577
|
|
@@ -582,7 +582,7 @@ class Chef
|
|
582
582
|
private
|
583
583
|
|
584
584
|
def opts
|
585
|
-
expand_options(
|
585
|
+
expand_options(new_resource.options)
|
586
586
|
end
|
587
587
|
|
588
588
|
end
|