summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package/aix.rb
diff options
context:
space:
mode:
authorkaustubh-d <kaustubh@clogeny.com>2014-11-18 14:56:22 +0530
committerBryan McLellan <btm@opscode.com>2015-02-17 09:16:38 -0500
commit6909f4074dbd9cee5906333f693bd282476a6ac5 (patch)
tree7deb7fcea3b0409b23986f317649f8ec18fa241e /lib/chef/provider/package/aix.rb
parentaa9b233614da81c506929cc1c36eb509a4e2c97e (diff)
downloadchef-6909f4074dbd9cee5906333f693bd282476a6ac5.tar.gz
fix aix related providers to replace popen4 with mixlib shell_out
Diffstat (limited to 'lib/chef/provider/package/aix.rb')
-rw-r--r--lib/chef/provider/package/aix.rb55
1 files changed, 25 insertions, 30 deletions
diff --git a/lib/chef/provider/package/aix.rb b/lib/chef/provider/package/aix.rb
index 88de4679ba..107f914c05 100644
--- a/lib/chef/provider/package/aix.rb
+++ b/lib/chef/provider/package/aix.rb
@@ -52,34 +52,30 @@ class Chef
@package_source_found = ::File.exists?(@new_resource.source)
if @package_source_found
Chef::Log.debug("#{@new_resource} checking pkg status")
- status = popen4("installp -L -d #{@new_resource.source}") do |pid, stdin, stdout, stderr|
- package_found = false
- stdout.each do |line|
- case line
- when /#{@new_resource.package_name}:/
- package_found = true
- fields = line.split(":")
- @new_resource.version(fields[2])
- end
+ ret = shell_out("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])
end
end
end
end
Chef::Log.debug("#{@new_resource} checking install state")
- status = popen4("lslpp -lcq #{@current_resource.package_name}") do |pid, stdin, stdout, stderr|
- stdout.each do |line|
- case line
- when /#{@current_resource.package_name}/
- fields = line.split(":")
- Chef::Log.debug("#{@new_resource} version #{fields[2]} is already installed")
- @current_resource.version(fields[2])
- end
+ ret = shell_out("lslpp -lcq #{@current_resource.package_name}")
+ ret.stdout.each_line do | line |
+ case line
+ when /#{@current_resource.package_name}/
+ fields = line.split(":")
+ Chef::Log.debug("#{@new_resource} version #{fields[2]} is already installed")
+ @current_resource.version(fields[2])
end
end
- unless status.exitstatus == 0 || status.exitstatus == 1
- raise Chef::Exceptions::Package, "lslpp failed - #{status.inspect}!"
+ unless ret.exitstatus == 0 || ret.exitstatus == 1
+ raise Chef::Exceptions::Package, "lslpp failed - #{ret.format_for_exception}!"
end
@current_resource
@@ -87,19 +83,18 @@ class Chef
def candidate_version
return @candidate_version if @candidate_version
- status = popen4("installp -L -d #{@new_resource.source}") do |pid, stdin, stdout, stderr|
- 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
+ ret = shell_out("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 status.exitstatus == 0
- raise Chef::Exceptions::Package, "installp -L -d #{@new_resource.source} - #{status.inspect}!"
+ unless ret.exitstatus == 0
+ raise Chef::Exceptions::Package, "installp -L -d #{@new_resource.source} - #{ret.format_for_exception}!"
end
@candidate_version
end