summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2017-01-17 18:13:57 +0000
committerGitHub <noreply@github.com>2017-01-17 18:13:57 +0000
commit90f0386dacab482d31b7e98ed9eff56ab7fea37e (patch)
treea8e2e236e68ca8574060800daa04322b97e002e7 /lib
parent6d5af4956464a805440a2a2637fed6a6c7cfea70 (diff)
parentd80b71b2bf75cf3a966d73a339794c9dd115f4bd (diff)
downloadchef-90f0386dacab482d31b7e98ed9eff56ab7fea37e.tar.gz
Merge pull request #5313 from juliandunn/aix_candidate_version_blindly_checks_source
Don't blindly check source on candidate_version calls.
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/provider/package/aix.rb59
1 files changed, 31 insertions, 28 deletions
diff --git a/lib/chef/provider/package/aix.rb b/lib/chef/provider/package/aix.rb
index 728f181055..12bf11ad0f 100644
--- a/lib/chef/provider/package/aix.rb
+++ b/lib/chef/provider/package/aix.rb
@@ -38,7 +38,7 @@ class Chef
a.failure_message Chef::Exceptions::Package, "Source for package #{@new_resource.name} required for action install"
end
requirements.assert(:all_actions) do |a|
- a.assertion { !@new_resource.source || @package_source_found }
+ a.assertion { !@new_resource.source || package_source_found? }
a.failure_message Chef::Exceptions::Package, "Package #{@new_resource.name} not found: #{@new_resource.source}"
a.whyrun "would assume #{@new_resource.source} would be have previously been made available"
end
@@ -48,24 +48,21 @@ class Chef
@current_resource = Chef::Resource::Package.new(@new_resource.name)
@current_resource.package_name(@new_resource.package_name)
- if @new_resource.source
- @package_source_found = ::File.exists?(@new_resource.source)
- if @package_source_found
- Chef::Log.debug("#{@new_resource} checking pkg status")
- ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
- ret.stdout.each_line do |line|
- case line
- when /:#{@new_resource.package_name}:/
- fields = line.split(":")
- @new_resource.version(fields[2])
- when /^#{@new_resource.package_name}:/
- Chef::Log.warn("You are installing a bff package by product name. For idempotent installs, please install individual filesets")
- fields = line.split(":")
- @new_resource.version(fields[2])
- end
+ if package_source_found?
+ Chef::Log.debug("#{@new_resource} checking pkg status")
+ ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
+ ret.stdout.each_line do |line|
+ case line
+ when /:#{@new_resource.package_name}:/
+ fields = line.split(":")
+ @new_resource.version(fields[2])
+ when /^#{@new_resource.package_name}:/
+ Chef::Log.warn("You are installing a bff package by product name. For idempotent installs, please install individual filesets")
+ fields = line.split(":")
+ @new_resource.version(fields[2])
end
- raise Chef::Exceptions::Package, "package source #{@new_resource.source} does not provide package #{@new_resource.package_name}" unless @new_resource.version
end
+ raise Chef::Exceptions::Package, "package source #{@new_resource.source} does not provide package #{@new_resource.package_name}" unless @new_resource.version
end
Chef::Log.debug("#{@new_resource} checking install state")
@@ -88,18 +85,20 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
- ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
- ret.stdout.each_line do |line|
- case line
- when /\w:#{Regexp.escape(@new_resource.package_name)}:(.*)/
- fields = line.split(":")
- @candidate_version = fields[2]
- @new_resource.version(fields[2])
- Chef::Log.debug("#{@new_resource} setting install candidate version to #{@candidate_version}")
+ if package_source_found?
+ ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
+ ret.stdout.each_line do |line|
+ case line
+ when /\w:#{Regexp.escape(@new_resource.package_name)}:(.*)/
+ fields = line.split(":")
+ @candidate_version = fields[2]
+ @new_resource.version(fields[2])
+ Chef::Log.debug("#{@new_resource} setting install candidate version to #{@candidate_version}")
+ end
+ end
+ unless ret.exitstatus == 0
+ raise Chef::Exceptions::Package, "installp -L -d #{@new_resource.source} - #{ret.format_for_exception}!"
end
- end
- unless ret.exitstatus == 0
- raise Chef::Exceptions::Package, "installp -L -d #{@new_resource.source} - #{ret.format_for_exception}!"
end
@candidate_version
end
@@ -134,6 +133,10 @@ class Chef
end
end
+ def package_source_found?
+ @package_source_found ||= @new_resource.source && ::File.exists?(@new_resource.source)
+ end
+
end
end
end