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
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Jason J. W. Williams (<williamsjj@digitar.com>)
|
3
3
|
# Author:: Stephen Nelson-Smith (<sns@chef.io>)
|
4
|
-
# Copyright:: Copyright 2011-
|
4
|
+
# Copyright:: Copyright 2011-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");
|
@@ -36,45 +36,40 @@ class Chef
|
|
36
36
|
super
|
37
37
|
|
38
38
|
requirements.assert(:all_actions) do |a|
|
39
|
-
a.assertion {
|
40
|
-
a.failure_message Chef::Exceptions::Package, "Package #{
|
41
|
-
a.whyrun "Assuming package #{
|
39
|
+
a.assertion { !@candidate_version.nil? }
|
40
|
+
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found"
|
41
|
+
a.whyrun "Assuming package #{new_resource.package_name} would have been made available."
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
def get_current_version
|
46
|
-
|
46
|
+
shell_out_compact_timeout("pkg", "info", new_resource.package_name).stdout.each_line do |line|
|
47
47
|
return $1.split[0] if line =~ /^\s+Version: (.*)/
|
48
48
|
end
|
49
|
-
|
49
|
+
nil
|
50
50
|
end
|
51
51
|
|
52
52
|
def get_candidate_version
|
53
|
-
|
53
|
+
shell_out_compact_timeout!("pkg", "info", "-r", new_resource.package_name).stdout.each_line do |line|
|
54
54
|
return $1.split[0] if line =~ /Version: (.*)/
|
55
55
|
end
|
56
|
-
|
56
|
+
nil
|
57
57
|
end
|
58
58
|
|
59
59
|
def load_current_resource
|
60
|
-
@current_resource = Chef::Resource::
|
61
|
-
|
62
|
-
Chef::Log.debug("Checking package status for #{
|
63
|
-
|
60
|
+
@current_resource = Chef::Resource::IpsPackage.new(new_resource.name)
|
61
|
+
current_resource.package_name(new_resource.package_name)
|
62
|
+
Chef::Log.debug("Checking package status for #{new_resource.name}")
|
63
|
+
current_resource.version(get_current_version)
|
64
64
|
@candidate_version = get_candidate_version
|
65
|
-
|
65
|
+
current_resource
|
66
66
|
end
|
67
67
|
|
68
68
|
def install_package(name, version)
|
69
|
-
|
70
|
-
|
71
|
-
command
|
72
|
-
|
73
|
-
normal_command.gsub("-q", "-q --accept")
|
74
|
-
else
|
75
|
-
normal_command
|
76
|
-
end
|
77
|
-
shell_out_with_timeout(command)
|
69
|
+
command = [ "pkg", options, "install", "-q" ]
|
70
|
+
command << "--accept" if new_resource.accept_license
|
71
|
+
command << "#{name}@#{version}"
|
72
|
+
shell_out_compact_timeout!(command)
|
78
73
|
end
|
79
74
|
|
80
75
|
def upgrade_package(name, version)
|
@@ -83,7 +78,7 @@ class Chef
|
|
83
78
|
|
84
79
|
def remove_package(name, version)
|
85
80
|
package_name = "#{name}@#{version}"
|
86
|
-
|
81
|
+
shell_out_compact_timeout!( "pkg", options, "uninstall", "-q", package_name )
|
87
82
|
end
|
88
83
|
end
|
89
84
|
end
|
@@ -7,25 +7,25 @@ class Chef
|
|
7
7
|
provides :macports_package
|
8
8
|
|
9
9
|
def load_current_resource
|
10
|
-
@current_resource = Chef::Resource::Package.new(
|
11
|
-
|
10
|
+
@current_resource = Chef::Resource::Package.new(new_resource.name)
|
11
|
+
current_resource.package_name(new_resource.package_name)
|
12
12
|
|
13
|
-
|
14
|
-
Chef::Log.debug("#{
|
13
|
+
current_resource.version(current_installed_version)
|
14
|
+
Chef::Log.debug("#{new_resource} current version is #{current_resource.version}") if current_resource.version
|
15
15
|
|
16
16
|
@candidate_version = macports_candidate_version
|
17
17
|
|
18
|
-
if
|
19
|
-
raise Chef::Exceptions::Package, "Could not get a candidate version for this package -- #{
|
18
|
+
if !new_resource.version && !@candidate_version
|
19
|
+
raise Chef::Exceptions::Package, "Could not get a candidate version for this package -- #{new_resource.name} does not seem to be a valid package!"
|
20
20
|
end
|
21
21
|
|
22
|
-
Chef::Log.debug("#{
|
22
|
+
Chef::Log.debug("#{new_resource} candidate version is #{@candidate_version}") if @candidate_version
|
23
23
|
|
24
|
-
|
24
|
+
current_resource
|
25
25
|
end
|
26
26
|
|
27
27
|
def current_installed_version
|
28
|
-
command = "port installed
|
28
|
+
command = [ "port", "installed", new_resource.package_name ]
|
29
29
|
output = get_response_from_command(command)
|
30
30
|
|
31
31
|
response = nil
|
@@ -37,7 +37,7 @@ class Chef
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def macports_candidate_version
|
40
|
-
command = "port info --version
|
40
|
+
command = [ "port", "info", "--version", new_resource.package_name ]
|
41
41
|
output = get_response_from_command(command)
|
42
42
|
|
43
43
|
match = output.match(/^version: (.+)$/)
|
@@ -46,37 +46,37 @@ class Chef
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def install_package(name, version)
|
49
|
-
unless
|
50
|
-
command = "port
|
51
|
-
command << "
|
52
|
-
|
49
|
+
unless current_resource.version == version
|
50
|
+
command = [ "port", options, "install", name ]
|
51
|
+
command << "@#{version}" if version && !version.empty?
|
52
|
+
shell_out_compact_timeout!(command)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
def purge_package(name, version)
|
57
|
-
command = "port
|
58
|
-
command << "
|
59
|
-
|
57
|
+
command = [ "port", options, "uninstall", name ]
|
58
|
+
command << "@#{version}" if version && !version.empty?
|
59
|
+
shell_out_compact_timeout!(command)
|
60
60
|
end
|
61
61
|
|
62
62
|
def remove_package(name, version)
|
63
|
-
command = "port
|
64
|
-
command << "
|
63
|
+
command = [ "port", options, "deactivate", name ]
|
64
|
+
command << "@#{version}" if version && !version.empty?
|
65
65
|
|
66
|
-
|
66
|
+
shell_out_compact_timeout!(command)
|
67
67
|
end
|
68
68
|
|
69
69
|
def upgrade_package(name, version)
|
70
70
|
# Saving this to a variable -- weird rSpec behavior
|
71
71
|
# happens otherwise...
|
72
|
-
current_version =
|
72
|
+
current_version = current_resource.version
|
73
73
|
|
74
74
|
if current_version.nil? || current_version.empty?
|
75
75
|
# Macports doesn't like when you upgrade a package
|
76
76
|
# that hasn't been installed.
|
77
77
|
install_package(name, version)
|
78
78
|
elsif current_version != version
|
79
|
-
|
79
|
+
shell_out_compact_timeout!( "port", options, "upgrade", name, "@#{version}" )
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -84,7 +84,7 @@ class Chef
|
|
84
84
|
|
85
85
|
def get_response_from_command(command)
|
86
86
|
output = nil
|
87
|
-
status =
|
87
|
+
status = shell_out_compact_timeout(command)
|
88
88
|
begin
|
89
89
|
output = status.stdout
|
90
90
|
rescue Exception
|
@@ -43,17 +43,17 @@ class Chef
|
|
43
43
|
@current_resource = Chef::Resource::MsuPackage.new(new_resource.name)
|
44
44
|
|
45
45
|
# download file if source is a url
|
46
|
-
msu_file = uri_scheme?(new_resource.source) ? download_source_file :
|
46
|
+
msu_file = uri_scheme?(new_resource.source) ? download_source_file : new_resource.source
|
47
47
|
|
48
48
|
# temp directory where the contents of msu file get extracted
|
49
49
|
@temp_directory = Dir.mktmpdir("chef")
|
50
50
|
extract_msu_contents(msu_file, @temp_directory)
|
51
51
|
@cab_files = read_cab_files_from_xml(@temp_directory)
|
52
52
|
|
53
|
-
|
54
|
-
current_resource.version(get_current_versions)
|
55
|
-
else
|
53
|
+
if @cab_files.empty?
|
56
54
|
raise Chef::Exceptions::Package, "Corrupt MSU package: MSU package XML does not contain any cab file"
|
55
|
+
else
|
56
|
+
current_resource.version(get_current_versions)
|
57
57
|
end
|
58
58
|
current_resource
|
59
59
|
end
|
@@ -77,7 +77,7 @@ class Chef
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def get_cab_package(cab_file)
|
80
|
-
cab_resource =
|
80
|
+
cab_resource = new_resource
|
81
81
|
cab_resource.source = cab_file
|
82
82
|
cab_pkg = Chef::Provider::Package::Cab.new(cab_resource, nil)
|
83
83
|
end
|
@@ -105,9 +105,9 @@ class Chef
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def install_package(name, version)
|
108
|
-
#use cab_package resource to install the extracted cab packages
|
108
|
+
# use cab_package resource to install the extracted cab packages
|
109
109
|
@cab_files.each do |cab_file|
|
110
|
-
declare_resource(:cab_package,
|
110
|
+
declare_resource(:cab_package, new_resource.name) do
|
111
111
|
source cab_file
|
112
112
|
action :install
|
113
113
|
end
|
@@ -115,9 +115,9 @@ class Chef
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def remove_package(name, version)
|
118
|
-
#use cab_package provider to remove the extracted cab packages
|
118
|
+
# use cab_package provider to remove the extracted cab packages
|
119
119
|
@cab_files.each do |cab_file|
|
120
|
-
declare_resource(:cab_package,
|
120
|
+
declare_resource(:cab_package, new_resource.name) do
|
121
121
|
source cab_file
|
122
122
|
action :remove
|
123
123
|
end
|
@@ -141,7 +141,7 @@ class Chef
|
|
141
141
|
raise Chef::Exceptions::Package, "Corrupt MSU package: MSU package doesn't contain any xml file"
|
142
142
|
else
|
143
143
|
# msu package contains only single xml file. So using xml_files.first is sufficient
|
144
|
-
doc = ::File.open(
|
144
|
+
doc = ::File.open(xml_files.first.to_s) { |f| REXML::Document.new f }
|
145
145
|
locations = doc.elements.each("unattend/servicing/package/source") { |element| puts element.attributes["location"] }
|
146
146
|
locations.each do |loc|
|
147
147
|
cab_files << msu_dir + "/" + loc.attribute("location").value.split("\\")[1]
|
@@ -154,7 +154,7 @@ class Chef
|
|
154
154
|
|
155
155
|
def cleanup_after_converge
|
156
156
|
# delete the temp directory where the contents of msu file are extracted
|
157
|
-
FileUtils.rm_rf(@temp_directory) if Dir.
|
157
|
+
FileUtils.rm_rf(@temp_directory) if Dir.exist?(@temp_directory)
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
@@ -42,9 +42,9 @@ class Chef
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def load_current_resource
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
current_resource.package_name(new_resource.package_name)
|
46
|
+
current_resource.version(installed_version)
|
47
|
+
current_resource
|
48
48
|
end
|
49
49
|
|
50
50
|
def define_resource_requirements
|
@@ -68,11 +68,11 @@ class Chef
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def install_package(name, version)
|
71
|
-
unless
|
71
|
+
unless current_resource.version
|
72
72
|
if parts = name.match(/^(.+?)--(.+)/) # use double-dash for stems with flavors, see man page for pkg_add
|
73
73
|
name = parts[1]
|
74
74
|
end
|
75
|
-
|
75
|
+
shell_out_compact_timeout!("pkg_add", "-r", package_string(name, version), env: { "PKG_PATH" => pkg_path }).status
|
76
76
|
Chef::Log.debug("#{new_resource.package_name} installed")
|
77
77
|
end
|
78
78
|
end
|
@@ -81,18 +81,18 @@ class Chef
|
|
81
81
|
if parts = name.match(/^(.+?)--(.+)/)
|
82
82
|
name = parts[1]
|
83
83
|
end
|
84
|
-
|
84
|
+
shell_out_compact_timeout!("pkg_delete", package_string(name, version), env: nil).status
|
85
85
|
end
|
86
86
|
|
87
87
|
private
|
88
88
|
|
89
89
|
def installed_version
|
90
|
-
if parts = new_resource.package_name.match(/^(.+?)--(.+)/)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
pkg_info =
|
90
|
+
name = if parts = new_resource.package_name.match(/^(.+?)--(.+)/)
|
91
|
+
parts[1]
|
92
|
+
else
|
93
|
+
new_resource.package_name
|
94
|
+
end
|
95
|
+
pkg_info = shell_out_compact_timeout!("pkg_info", "-e", "#{name}->0", env: nil, returns: [0, 1])
|
96
96
|
result = pkg_info.stdout[/^inst:#{Regexp.escape(name)}-(.+?)\s/, 1]
|
97
97
|
Chef::Log.debug("installed_version of '#{new_resource.package_name}' is '#{result}'")
|
98
98
|
result
|
@@ -101,12 +101,12 @@ class Chef
|
|
101
101
|
def candidate_version
|
102
102
|
@candidate_version ||= begin
|
103
103
|
results = []
|
104
|
-
|
105
|
-
if parts = new_resource.package_name.match(/^(.+?)--(.+)/)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
104
|
+
shell_out_compact_timeout!("pkg_info", "-I", package_string(new_resource.package_name, new_resource.version), env: nil, returns: [0, 1]).stdout.each_line do |line|
|
105
|
+
results << if parts = new_resource.package_name.match(/^(.+?)--(.+)/)
|
106
|
+
line[/^#{Regexp.escape(parts[1])}-(.+?)\s/, 1]
|
107
|
+
else
|
108
|
+
line[/^#{Regexp.escape(new_resource.package_name)}-(.+?)\s/, 1]
|
109
|
+
end
|
110
110
|
end
|
111
111
|
results = results.reject(&:nil?)
|
112
112
|
Chef::Log.debug("Candidate versions of '#{new_resource.package_name}' are '#{results}'")
|
@@ -121,13 +121,16 @@ class Chef
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
def
|
125
|
-
|
126
|
-
|
124
|
+
def package_string(name, version)
|
125
|
+
if version
|
126
|
+
"#{name}-#{version}"
|
127
|
+
else
|
128
|
+
name
|
129
|
+
end
|
127
130
|
end
|
128
131
|
|
129
132
|
def pkg_path
|
130
|
-
ENV["PKG_PATH"] || "http://ftp.OpenBSD.org/pub/#{node[
|
133
|
+
ENV["PKG_PATH"] || "http://ftp.OpenBSD.org/pub/#{node['kernel']['name']}/#{node['kernel']['release']}/packages/#{node['kernel']['machine']}/"
|
131
134
|
end
|
132
135
|
|
133
136
|
end
|
@@ -29,16 +29,16 @@ class Chef
|
|
29
29
|
provides :pacman_package, os: "linux"
|
30
30
|
|
31
31
|
def load_current_resource
|
32
|
-
@current_resource = Chef::Resource::Package.new(
|
33
|
-
|
32
|
+
@current_resource = Chef::Resource::Package.new(new_resource.name)
|
33
|
+
current_resource.package_name(new_resource.package_name)
|
34
34
|
|
35
|
-
Chef::Log.debug("#{
|
36
|
-
status =
|
35
|
+
Chef::Log.debug("#{new_resource} checking pacman for #{new_resource.package_name}")
|
36
|
+
status = shell_out_compact_timeout("pacman", "-Qi", new_resource.package_name)
|
37
37
|
status.stdout.each_line do |line|
|
38
38
|
case line
|
39
39
|
when /^Version(\s?)*: (.+)$/
|
40
|
-
Chef::Log.debug("#{
|
41
|
-
|
40
|
+
Chef::Log.debug("#{new_resource} current version is #{$2}")
|
41
|
+
current_resource.version($2)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -46,7 +46,7 @@ class Chef
|
|
46
46
|
raise Chef::Exceptions::Package, "pacman failed - #{status.inspect}!"
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
current_resource
|
50
50
|
end
|
51
51
|
|
52
52
|
def candidate_version
|
@@ -54,20 +54,20 @@ class Chef
|
|
54
54
|
|
55
55
|
repos = %w{extra core community}
|
56
56
|
|
57
|
-
if ::File.
|
57
|
+
if ::File.exist?("/etc/pacman.conf")
|
58
58
|
pacman = ::File.read("/etc/pacman.conf")
|
59
59
|
repos = pacman.scan(/\[(.+)\]/).flatten
|
60
60
|
end
|
61
61
|
|
62
62
|
package_repos = repos.map { |r| Regexp.escape(r) }.join("|")
|
63
63
|
|
64
|
-
status =
|
64
|
+
status = shell_out_compact_timeout("pacman", "-Sl")
|
65
65
|
status.stdout.each_line do |line|
|
66
66
|
case line
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
when /^(#{package_repos}) #{Regexp.escape(new_resource.package_name)} (.+)$/
|
68
|
+
# $2 contains a string like "4.4.0-1" or "3.10-4 [installed]"
|
69
|
+
# simply split by space and use first token
|
70
|
+
@candidate_version = $2.split(" ").first
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -76,14 +76,14 @@ class Chef
|
|
76
76
|
end
|
77
77
|
|
78
78
|
unless @candidate_version
|
79
|
-
raise Chef::Exceptions::Package, "pacman does not have a version of package #{
|
79
|
+
raise Chef::Exceptions::Package, "pacman does not have a version of package #{new_resource.package_name}"
|
80
80
|
end
|
81
81
|
|
82
82
|
@candidate_version
|
83
83
|
end
|
84
84
|
|
85
85
|
def install_package(name, version)
|
86
|
-
|
86
|
+
shell_out_compact_timeout!( "pacman", "--sync", "--noconfirm", "--noprogressbar", options, name)
|
87
87
|
end
|
88
88
|
|
89
89
|
def upgrade_package(name, version)
|
@@ -91,7 +91,7 @@ class Chef
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def remove_package(name, version)
|
94
|
-
|
94
|
+
shell_out_compact_timeout!( "pacman", "--remove", "--noconfirm", "--noprogressbar", options, name )
|
95
95
|
end
|
96
96
|
|
97
97
|
def purge_package(name, version)
|
@@ -28,38 +28,37 @@ class Chef
|
|
28
28
|
provides :paludis_package, os: "linux"
|
29
29
|
|
30
30
|
def load_current_resource
|
31
|
-
@current_resource = Chef::Resource::Package.new(
|
32
|
-
|
31
|
+
@current_resource = Chef::Resource::Package.new(new_resource.package_name)
|
32
|
+
current_resource.package_name(new_resource.package_name)
|
33
33
|
|
34
|
-
Chef::Log.debug("Checking package status for #{
|
34
|
+
Chef::Log.debug("Checking package status for #{new_resource.package_name}")
|
35
35
|
installed = false
|
36
36
|
re = Regexp.new("(.*)[[:blank:]](.*)[[:blank:]](.*)$")
|
37
37
|
|
38
|
-
|
38
|
+
shell_out_compact!("cave", "-L", "warning", "print-ids", "-M", "none", "-m", new_resource.package_name, "-f", "%c/%p %v %r\n").stdout.each_line do |line|
|
39
39
|
res = re.match(line)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
40
|
+
next if res.nil?
|
41
|
+
case res[3]
|
42
|
+
when "accounts", "installed-accounts"
|
43
|
+
next
|
44
|
+
when "installed"
|
45
|
+
installed = true
|
46
|
+
current_resource.version(res[2])
|
47
|
+
else
|
48
|
+
@candidate_version = res[2]
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
|
-
|
52
|
+
current_resource
|
54
53
|
end
|
55
54
|
|
56
55
|
def install_package(name, version)
|
57
|
-
if version
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
pkg = if version
|
57
|
+
"=#{name}-#{version}"
|
58
|
+
else
|
59
|
+
new_resource.package_name.to_s
|
60
|
+
end
|
61
|
+
shell_out_compact_timeout!("cave", "-L", "warning", "resolve", "-x", options, pkg)
|
63
62
|
end
|
64
63
|
|
65
64
|
def upgrade_package(name, version)
|
@@ -67,13 +66,13 @@ class Chef
|
|
67
66
|
end
|
68
67
|
|
69
68
|
def remove_package(name, version)
|
70
|
-
if version
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
pkg = if version
|
70
|
+
"=#{new_resource.package_name}-#{version}"
|
71
|
+
else
|
72
|
+
new_resource.package_name.to_s
|
73
|
+
end
|
75
74
|
|
76
|
-
|
75
|
+
shell_out_compact!("cave", "-L", "warning", "uninstall", "-x", options, pkg)
|
77
76
|
end
|
78
77
|
|
79
78
|
def purge_package(name, version)
|