lib/phusion_passenger/dependencies.rb in passenger-3.0.21 vs lib/phusion_passenger/dependencies.rb in passenger-3.9.1.beta

- old
+ new

@@ -20,11 +20,10 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. require 'rbconfig' -require 'tmpdir' require 'phusion_passenger' require 'phusion_passenger/packaging' require 'phusion_passenger/platform_info' require 'phusion_passenger/platform_info/apache' require 'phusion_passenger/platform_info/ruby' @@ -112,20 +111,14 @@ # Returns whether Mizuho is required in order to be able to package all files # in the packaging list. def self.mizuho_required? return Packaging::ASCII_DOCS.any? do |fn| - !File.exist?("#{SOURCE_ROOT}/#{fn}") + !File.exist?("#{PhusionPassenger.doc_dir}/#{fn}") end end - def self.create_temp_files(name1, name2, dir = PlatformInfo.tmpexedir) - Dir.mktmpdir("passenger.", dir) do |subdir| - yield "#{subdir}/#{name1}", "#{subdir}/#{name2}" - end - end - GCC = Dependency.new do |dep| dep.name = "GNU C++ compiler" dep.define_checker do |result| gxx = PlatformInfo.find_command('g++') if gxx.nil? @@ -461,11 +454,13 @@ end Curl_Dev = Dependency.new do |dep| dep.name = "Curl development headers with SSL support" dep.define_checker do |result| - Dependencies.create_temp_files("check.c", "check") do |source_file, output_file| + source_file = "#{PlatformInfo.tmpexedir}/passenger-curl-check.c" + output_file = "#{PlatformInfo.tmpexedir}/passenger-curl-check" + begin found = true File.open(source_file, 'w') do |f| f.puts("#include <curl/curl.h>") f.puts("int main() {") f.puts(" curl_global_init(CURL_GLOBAL_ALL);") @@ -485,10 +480,13 @@ if found && !PlatformInfo.curl_supports_ssl? dep.install_comments = "Curl was found, but it doesn't support SSL." found = false end result.found(found) + ensure + File.unlink(source_file) rescue nil + File.unlink(output_file) rescue nil end end dep.install_instructions = "Please download Curl from <b>http://curl.haxx.se/libcurl</b> " + "and make sure you install it <b>with SSL support</b>." if RUBY_PLATFORM =~ /linux/ @@ -514,21 +512,26 @@ end OpenSSL_Dev = Dependency.new do |dep| dep.name = "OpenSSL development headers" dep.define_checker do |result| - Dependencies.create_temp_files("check.c", "check.o") do |source_file, output_file| + source_file = "#{PlatformInfo.tmpexedir}/passenger-openssl-check.c" + object_file = "#{PlatformInfo.tmpexedir}/passenger-openssl-check.o" + begin File.open(source_file, 'w') do |f| f.write("#include <openssl/ssl.h>") end Dir.chdir(File.dirname(source_file)) do - if system("(gcc #{ENV['CFLAGS']} -c '#{source_file}' -o '#{output_file}') >/dev/null 2>/dev/null") + if system("(gcc #{ENV['CFLAGS']} -c '#{source_file}') >/dev/null 2>/dev/null") result.found else result.not_found end end + ensure + File.unlink(source_file) rescue nil + File.unlink(object_file) rescue nil end end if RUBY_PLATFORM =~ /linux/ tags = PlatformInfo.linux_distro_tags if tags.include?(:debian) @@ -541,21 +544,26 @@ end Zlib_Dev = Dependency.new do |dep| dep.name = "Zlib development headers" dep.define_checker do |result| - Dependencies.create_temp_files("check.c", "check.o") do |source_file, output_file| + source_file = "#{PlatformInfo.tmpexedir}/zlib-check.c" + object_file = "#{PlatformInfo.tmpexedir}/zlib-check.o" + begin File.open(source_file, 'w') do |f| f.write("#include <zlib.h>") end Dir.chdir(File.dirname(source_file)) do - if system("(g++ -c '#{source_file}' -o '#{output_file}') >/dev/null 2>/dev/null") + if system("(g++ -c zlib-check.c) >/dev/null 2>/dev/null") result.found else result.not_found end end + ensure + File.unlink(source_file) rescue nil + File.unlink(object_file) rescue nil end end if RUBY_PLATFORM =~ /linux/ tags = PlatformInfo.linux_distro_tags if tags.include?(:debian) @@ -565,9 +573,39 @@ elsif tags.include?(:redhat) dep.install_command = "yum install zlib-devel" end end dep.website = "http://www.zlib.net/" + end + + PCRE_Dev = Dependency.new do |dep| + dep.name = "PCRE development headers" + dep.define_checker do |result| + source_file = "#{PlatformInfo.tmpexedir}/pcre-check.c" + object_file = "#{PlatformInfo.tmpexedir}/pcre-check.o" + begin + File.open(source_file, 'w') do |f| + f.write("#include <pcre.h>") + end + Dir.chdir(File.dirname(source_file)) do + if system("(g++ -c pcre-check.c) >/dev/null 2>/dev/null") + result.found + else + result.not_found + end + end + ensure + File.unlink(source_file) rescue nil + File.unlink(object_file) rescue nil + end + end + if RUBY_PLATFORM =~ /linux/ + tags = PlatformInfo.linux_distro_tags + if tags.include?(:debian) + dep.install_command = "apt-get install libpcre3-dev" + end + end + dep.website = "http://www.pcre.org/" end Daemon_Controller = Dependency.new do |dep| dep.name = "daemon_controller >= 1.0.0" dep.install_instructions = "Please install RubyGems first, then run " <<