def candidate_version
return @candidate_version if @candidate_version
status = popen4("pkginfo -l -d #{@new_resource.source} #{new_resource.package_name}") do |pid, stdin, stdout, stderr|
stdout.each_line do |line|
case line
when /VERSION:\s+(.+)/
@candidate_version = $1
@new_resource.version($1)
Chef::Log.debug("candidate_version: setting install candidate version to #{@candidate_version}")
end
end
end
unless status.exitstatus == 0
raise Chef::Exceptions::Package, "pkginfo -l -d #{@new_resource.source} - #{status.inspect}!"
end
@candidate_version
end