lib/phusion_passenger/standalone/runtime_installer.rb in passenger-4.0.10 vs lib/phusion_passenger/standalone/runtime_installer.rb in passenger-4.0.13
- old
+ new
@@ -25,64 +25,71 @@
require 'fileutils'
require 'phusion_passenger'
require 'phusion_passenger/abstract_installer'
require 'phusion_passenger/packaging'
require 'phusion_passenger/common_library'
+require 'phusion_passenger/platform_info'
require 'phusion_passenger/platform_info/ruby'
require 'phusion_passenger/platform_info/binary_compatibility'
require 'phusion_passenger/standalone/utils'
require 'phusion_passenger/utils/tmpio'
module PhusionPassenger
module Standalone
-# Installs the Phusion Passenger Standalone runtime by downloading and compiling
-# Nginx, compiling the Phusion Passenger support binaries, and storing the
-# results in the designated directories. This installer is entirely
-# non-interactive.
+# Installs the Phusion Passenger Standalone runtime by downloading or compiling
+# the Phusion Passenger support binaries and Nginx, and then storing them
+# in the designated directories. This installer is entirely non-interactive.
#
# The following option must be given:
# - targets: An array containing at least one of:
-# * :nginx - to indicate that you want to compile and install Nginx.
-# * :support_binaries - to indicate that you want to compile and install the
+# * :support_binaries - to indicate that you want to install the
# Phusion Passenger support binary files.
-# * :ruby - to indicate that you want to compile and install the Ruby
-# extension files.
+# * :nginx - to indicate that you want to install Nginx.
#
-# If 'targets' contains :nginx, then you must also specify these options:
+# If `targets` contains `:support_binaries`, then you must also specify this
+# options:
+# - support_dir: The support binary files will be installed here.
+#
+# If `targets` contains `:nginx`, then you must also specify these options:
# - nginx_dir: Nginx will be installed into this directory.
-# - support_dir: Path to the Phusion Passenger support binary files.
+# - lib_dir: Path to the Phusion Passenger libraries, which Nginx will link to.
+# This may be the same path as `support_dir`; Nginx will be compiled
+# after the support binary files are installed.
# - nginx_version (optional): The Nginx version to download. If not given then a
# hardcoded version number will be used.
# - nginx_tarball (optional): The location to the Nginx tarball. This tarball *must*
# contain the Nginx version as specified by +version+. If +tarball+ is given
# then Nginx will not be downloaded; it will be extracted from this tarball
# instead.
#
-# If targets contains ':support_binaries', then you must also specify this
-# options:
-# - support_dir: The support binary files will be installed here.
-#
-# If targets contains ':ruby', then you must also specify this option:
-# - ruby_dir: The support binary files will be installed here.
-#
# Other optional options:
# - download_binaries: If true then RuntimeInstaller will attempt to download
-# precompiled Nginx binaries and precompiled Phusion Passenger support binary
-# files from the network, if they exist for the current platform. The default is
-# false.
+# a precompiled Nginx binary and precompiled Phusion Passenger support binaries
+# from the network, if they exist for the current platform. The default is
+# true. Note that binary downloading only happens when Phusion Passenger is
+# installed from an official release package.
# - binaries_url_root: The URL on which to look for the aforementioned binaries.
# The default points to the Phusion website.
-#
-# Please note that RuntimeInstaller will try to avoid compiling/installing things
-# that don't need to be compiled/installed. This is done by checking whether some
-# key files exist, and concluding that something doesn't need to be
-# compiled/installed if they do. This quick check is of course not perfect; if you
-# want to force a recompilation/reinstall then you should remove +nginx_dir+
-# and +support_dir+ before starting this installer.
class RuntimeInstaller < AbstractInstaller
include Utils
+
+ def initialize(*args)
+ super(*args)
+ raise ArgumentError, "At least one target must be given" if @targets.nil? || @targets.empty?
+ if @targets.include?(:support_binaries)
+ if PhusionPassenger.natively_packaged?
+ raise ArgumentError, "You cannot specify :support_binaries as a " +
+ "target when natively packaged"
+ end
+ raise ArgumentError, ":support_dir must be given" if !@support_dir
+ end
+ if @targets.include?(:nginx)
+ raise ArgumentError, ":nginx_dir must be given" if !@nginx_dir
+ raise ArgumentError, ":lib_dir must be given" if !@lib_dir
+ end
+ end
protected
def dependencies
specs = [
'depcheck_specs/compiler_toolchain',
@@ -93,12 +100,10 @@
]
ids = [
'gcc',
'g++',
'gmake',
- 'download-tool',
- PlatformInfo.passenger_needs_ruby_dev_header? ? 'ruby-dev' : nil,
'ruby-openssl',
'rubygems',
'rake',
'rack',
'libcurl-dev',
@@ -111,139 +116,287 @@
end
def users_guide
return "#{PhusionPassenger.doc_dir}/Users guide Standalone.html"
end
-
+
def run_steps
- if @support_dir && @nginx_dir
- show_welcome_screen
- end
- check_dependencies(false) || exit(1)
+ show_welcome_screen if @nginx_dir
check_whether_os_is_broken
- check_whether_system_has_enough_ram
+ check_for_download_tool
+ download_or_compile_binaries
puts
-
- phase = 1
- total_phases = 0
-
- if binary_support_files_should_be_installed?
- check_whether_we_can_write_to(@support_dir) || exit(1)
- total_phases += 4
+ puts "<green><b>All done!</b></green>"
+ puts
+ end
+
+ def before_install
+ super
+ @plugin.call_hook(:runtime_installer_start, self) if @plugin
+ @working_dir = PhusionPassenger::Utils.mktmpdir("passenger.", PlatformInfo.tmpexedir)
+ @nginx_version ||= PREFERRED_NGINX_VERSION
+ @download_binaries = true if !defined?(@download_binaries)
+ @binaries_url_root ||= BINARIES_URL_ROOT
+ end
+
+ def after_install
+ super
+ FileUtils.remove_entry_secure(@working_dir) if @working_dir
+ @plugin.call_hook(:runtime_installer_cleanup) if @plugin
+ end
+
+private
+ def show_welcome_screen
+ render_template 'standalone/welcome',
+ :version => @nginx_version,
+ :dir => @nginx_dir
+ puts
+ end
+
+ def check_for_download_tool
+ puts "<banner>Checking for basic prerequities...</banner>"
+ puts
+
+ require 'phusion_passenger/platform_info/depcheck'
+ PlatformInfo::Depcheck.load('depcheck_specs/utilities')
+ runner = PlatformInfo::Depcheck::ConsoleRunner.new
+ runner.add('download-tool')
+
+ if !runner.check_all
+ @download_binaries = false
+ puts
+ line
+ puts
+ render_template 'standalone/download_tool_missing',
+ :runner => runner
+ wait
end
- if ruby_extension_should_be_installed?
- check_whether_we_can_write_to(@ruby_dir) || exit(1)
- total_phases += 2
+ end
+
+ def download_or_compile_binaries
+ if should_install_support_binaries?
+ support_binaries_downloaded = download_support_binaries
end
- if nginx_needs_to_be_installed?
- check_whether_we_can_write_to(@nginx_dir) || exit(1)
- total_phases += 4
+ if should_install_nginx?
+ nginx_binary_downloaded = download_nginx_binary
end
- if binary_support_files_should_be_installed? && should_download_binaries?
- download_and_extract_binary_support_files(@support_dir) do |progress, total|
- show_progress(progress, total, 1, 1, "Extracting Passenger binaries...")
+ should_compile_support_binaries = should_install_support_binaries? &&
+ !support_binaries_downloaded
+ should_compile_nginx = should_install_nginx? && !nginx_binary_downloaded
+
+ if should_compile_support_binaries || should_compile_nginx
+ if @dont_compile_runtime
+ @stderr.puts "*** ERROR: Refusing to compile the Phusion Passenger Standalone runtime " +
+ "because --no-compile-runtime is given."
+ exit(1)
end
+ check_dependencies(false) || exit(1)
puts
+ if should_compile_support_binaries
+ check_whether_we_can_write_to(@support_dir) || exit(1)
+ end
+ if should_compile_nginx
+ check_whether_we_can_write_to(@nginx_dir) || exit(1)
+ end
+ end
+
+ if should_compile_nginx
+ nginx_source_dir = download_and_extract_nginx_sources
+ end
+ if should_compile_support_binaries
+ compile_support_binaries
+ end
+ if should_compile_nginx
+ compile_nginx(nginx_source_dir)
+ end
+ end
+
+ # If this method returns true, then PhusionPassenger.originally_packaged? is also true.
+ def should_install_support_binaries?
+ return @targets.include?(:support_binaries)
+ end
+
+ def should_install_nginx?
+ return @targets.include?(:nginx)
+ end
+
+ def should_download_binaries?
+ return PhusionPassenger.installed_from_release_package? &&
+ @download_binaries &&
+ @binaries_url_root
+ end
+
+ def download_support_binaries
+ return false if !should_download_binaries?
+
+ puts "<banner>Downloading Passenger support binaries for your platform, if available...</banner>"
+ basename = "support-#{PlatformInfo.cxx_binary_compatibility_id}.tar.gz"
+ url = "#{@binaries_url_root}/#{PhusionPassenger::VERSION_STRING}/#{basename}"
+ tarball = "#{@working_dir}/#{basename}"
+ if !download(url, tarball, :cacert => PhusionPassenger.binaries_ca_cert_path, :use_cache => true)
+ puts "<b>No binaries are available for your platform. But don't worry, the " +
+ "necessary binaries will be compiled from source instead.</b>"
puts
+ return false
end
- if ruby_extension_should_be_installed? && should_download_binaries?
- download_and_extract_ruby_extension(@ruby_dir) do |progress, total|
- show_progress(progress, total, 1, 1, "Extracting Ruby extension...")
+
+ FileUtils.mkdir_p(@support_dir)
+ Dir.mkdir("#{@working_dir}/support")
+ Dir.chdir("#{@working_dir}/support") do
+ puts "Extracting tarball..."
+ return false if !extract_tarball(tarball)
+ return false if !check_support_binaries
+ end
+
+ if system("mv '#{@working_dir}/support'/* '#{@support_dir}'/")
+ return true
+ else
+ @stderr.puts "Error: could not move extracted files to the support directory"
+ return false
+ end
+ rescue Interrupt
+ exit 2
+ end
+
+ def check_support_binaries
+ ["PassengerWatchdog", "PassengerHelperAgent", "PassengerLoggingAgent"].each do |exe|
+ puts "Checking whether the downloaded #{exe} binary is usable..."
+ output = `env LD_BIND_NOW=1 DYLD_BIND_AT_LAUNCH=1 ./agents/#{exe} --test-binary 1`
+ if !$? || $?.exitstatus != 0 || output != "PASS\n"
+ @stderr.puts "Binary #{exe} is not usable."
+ return false
end
+ end
+ puts "Binaries are usable."
+ return true
+ end
+
+ def download_nginx_binary
+ return false if !should_download_binaries?
+
+ puts "<banner>Downloading Nginx binary for your platform, if available...</banner>"
+ basename = "nginx-#{@nginx_version}-#{PlatformInfo.cxx_binary_compatibility_id}.tar.gz"
+ url = "#{@binaries_url_root}/#{PhusionPassenger::VERSION_STRING}/#{basename}"
+ tarball = "#{@working_dir}/#{basename}"
+ if !download(url, tarball, :cacert => PhusionPassenger.binaries_ca_cert_path, :use_cache => true)
+ puts "<b>No binary available for your platform. But don't worry, the " +
+ "necessary binary will be compiled from source instead.</b>"
puts
- puts
+ return false
end
- if nginx_needs_to_be_installed? && should_download_binaries?
- download_and_extract_nginx_binaries(@nginx_dir) do |progress, total|
- show_progress(progress, total, 1, 1, "Extracting Nginx binaries...")
+
+ FileUtils.mkdir_p(@nginx_dir)
+ Dir.mkdir("#{@working_dir}/nginx")
+ Dir.chdir("#{@working_dir}/nginx") do
+ puts "Extracting tarball..."
+ result = extract_tarball(tarball)
+ return false if !result
+ if check_nginx_binary
+ if system("mv '#{@working_dir}/nginx'/* '#{@nginx_dir}'/")
+ return true
+ else
+ @stderr.puts "Error: could not move extracted Nginx binary to the right directory"
+ return false
+ end
+ else
+ return false
end
- puts
- puts
end
+ rescue Interrupt
+ exit 2
+ end
+
+ def check_nginx_binary
+ puts "Checking whether the downloaded binary is usable..."
+ output = `env LD_BIND_NOW=1 DYLD_BIND_AT_LAUNCH=1 ./nginx -v 2>&1`
+ if $? && $?.exitstatus == 0 && output =~ /nginx version:/
+ puts "Binary is usable."
+ return true
+ else
+ @stderr.puts "Binary is not usable."
+ return false
+ end
+ end
+
+ def download_and_extract_nginx_sources
+ begin_progress_bar
+ puts "Downloading Nginx..."
+ if @nginx_tarball
+ tarball = @nginx_tarball
+ else
+ basename = "nginx-#{@nginx_version}.tar.gz"
+ tarball = "#{@working_dir}/#{basename}"
+ if !download("http://nginx.org/download/#{basename}", tarball)
+ puts
+ show_possible_solutions_for_download_and_extraction_problems
+ exit(1)
+ end
+ end
+ nginx_sources_name = "nginx-#{@nginx_version}"
- if nginx_needs_to_be_installed?
- nginx_source_dir = download_and_extract_nginx_sources do |progress, total|
- show_progress(progress, total, phase, total_phases, "Extracting...")
+ Dir.chdir(@working_dir) do
+ begin_progress_bar
+ begin
+ result = extract_tarball(tarball) do |progress, total|
+ show_progress(progress / total * 0.1, 1.0, 1, 1, "Extracting Nginx sources...")
+ end
+ rescue Exception
+ puts
+ raise
end
- phase += 1
- if nginx_source_dir.nil?
+ if result
+ return "#{@working_dir}/#{nginx_sources_name}"
+ else
puts
show_possible_solutions_for_download_and_extraction_problems
exit(1)
end
end
- if ruby_extension_should_be_installed?
- phase += install_ruby_extension do |progress, total, subphase, status_text|
- show_progress(progress, total, phase + subphase, total_phases, status_text)
+ rescue Interrupt
+ exit 2
+ end
+
+ def compile_support_binaries
+ begin_progress_bar
+ show_progress(0, 1, 1, 1, "Preparing Phusion Passenger...")
+ Dir.chdir(PhusionPassenger.source_root) do
+ args = "nginx_without_native_support" +
+ " CACHING=false" +
+ " OUTPUT_DIR='#{@support_dir}'"
+ begin
+ run_rake_task!(args) do |progress, total|
+ show_progress(progress, total, 1, 1, "Compiling Phusion Passenger...")
+ end
+ ensure
+ puts
end
- end
- if binary_support_files_should_be_installed?
- install_binary_support_files do |progress, total, subphase, status_text|
- if subphase == 0
- show_progress(progress, total, phase, total_phases, status_text)
- else
- show_progress(progress, total, phase + 1 .. phase + 3, total_phases, status_text)
+
+ system "rm -rf '#{@support_dir}'/agents/{*.o,*.dSYM}"
+ system "rm -rf '#{@support_dir}'/common/libboost_oxt"
+ system "rm -rf '#{@support_dir}'/*/{*.lo,*.h,*.log,Makefile,libtool,stamp-h1,config.status,.deps}"
+ system "rm -rf '#{@support_dir}'/{libeio,libev}/*.o"
+
+ # Retain only the object files that are needed for linking the Phusion Passenger module into Nginx.
+ nginx_libs = COMMON_LIBRARY.
+ only(*NGINX_LIBS_SELECTOR).
+ set_output_dir("#{@support_dir}/libpassenger_common").
+ link_objects
+ Dir["#{@support_dir}/libpassenger_common/**/*"].each do |filename|
+ if !nginx_libs.include?(filename) && File.file?(filename)
+ File.unlink(filename)
end
end
- phase += 4
end
- if nginx_needs_to_be_installed?
- install_nginx_from_source(nginx_source_dir) do |progress, total, status_text|
- show_progress(progress, total, phase .. phase + 2, total_phases, status_text)
- end
- phase += 3
- end
-
- puts
- puts "<green><b>All done!</b></green>"
- puts
end
-
- def before_install
- super
- @plugin.call_hook(:runtime_installer_start, self) if @plugin
- @working_dir = PhusionPassenger::Utils.mktmpdir("passenger.", PlatformInfo.tmpexedir)
- @download_binaries = true if !defined?(@download_binaries)
- @binaries_url_root ||= STANDALONE_BINARIES_URL_ROOT
- end
- def after_install
- super
- FileUtils.remove_entry_secure(@working_dir) if @working_dir
- @plugin.call_hook(:runtime_installer_cleanup) if @plugin
+ def compile_nginx(nginx_source_dir)
+ install_nginx_from_source(nginx_source_dir) do |progress, total, status_text|
+ show_progress(0.1 + progress / total.to_f * 0.9, 1.0, 1, 1, status_text)
+ end
end
-
-private
- def nginx_needs_to_be_installed?
- return @targets.include?(:nginx) &&
- !File.exist?("#{@nginx_dir}/sbin/nginx")
- end
- def ruby_extension_should_be_installed?
- return @targets.include?(:ruby) &&
- !File.exist?("#{@ruby_dir}/#{PlatformInfo.ruby_extension_binary_compatibility_id}")
- end
-
- def binary_support_files_should_be_installed?
- return @targets.include?(:support_binaries) && (
- !File.exist?("#{@support_dir}/buildout/agents/PassengerHelperAgent") ||
- !File.exist?("#{@support_dir}/buildout/common/libpassenger_common.a")
- )
- end
-
- def should_download_binaries?
- return @download_binaries && @binaries_url_root
- end
-
- def show_welcome_screen
- render_template 'standalone/welcome',
- :version => @nginx_version,
- :dir => @nginx_dir
- puts
- end
-
def check_whether_we_can_write_to(dir)
FileUtils.mkdir_p(dir)
File.new("#{dir}/__test__.txt", "w").close
return true
rescue
@@ -270,12 +423,21 @@
text = sprintf("[%-#{progress_bar_width}s] %s",
'*' * (progress_bar_width * total_progress).to_i,
status_text)
text = text.ljust(max_width)
text = text[0 .. max_width - 1]
- STDOUT.write("#{text}\r")
- STDOUT.flush
+ if @stdout.tty?
+ @stdout.write("#{text}\r")
+ @stdout.flush
+ else
+ if @last_status_text != status_text
+ @last_status_text = status_text
+ @stdout.write("[#{status_text.sub(/\.*$/, '')}]")
+ end
+ @stdout.write(".")
+ @stdout.flush
+ end
@plugin.call_hook(:runtime_installer_progress, total_progress, status_text) if @plugin
end
def myself
return `whoami`.strip
@@ -299,20 +461,20 @@
IO.popen("tar xzf -", "wb") do |io|
buffer = ''
buffer = buffer.force_encoding('binary') if buffer.respond_to?(:force_encoding)
total_size = File.size(filename)
bytes_read = 0
- yield(bytes_read, total_size)
+ yield(bytes_read, total_size) if block_given?
begin
doing_our_io = true
while !f.eof?
f.read(1024 * 8, buffer)
io.write(buffer)
io.flush
bytes_read += buffer.size
doing_our_io = false
- yield(bytes_read, total_size)
+ yield(bytes_read, total_size) if block_given?
doing_our_io = true
end
rescue Errno::EPIPE
if doing_our_io
return false
@@ -338,13 +500,13 @@
yield("#{status_text} #{throbbers[index]}")
index = (index + 1) % throbbers.size
end
end
if $?.exitstatus != 0
- STDERR.puts
- STDERR.puts backlog
- STDERR.puts "*** ERROR: command failed: #{command}"
+ @stderr.puts
+ @stderr.puts backlog
+ @stderr.puts "*** ERROR: command failed: #{command}"
exit 1
end
end
def copy_files(files, target)
@@ -380,152 +542,24 @@
backlog << line
end
end
end
if $?.exitstatus != 0
- STDERR.puts
- STDERR.puts "*** ERROR: the following command failed:"
- STDERR.puts(backlog)
+ @stderr.puts
+ @stderr.puts "*** ERROR: the following command failed:"
+ @stderr.puts(backlog)
exit 1
end
end
- def download_and_extract_binary_support_files(target, &block)
- puts "<banner>Downloading Passenger support binaries for your platform, if available...</banner>"
- basename = "support-#{PlatformInfo.cxx_binary_compatibility_id}.tar.gz"
- url = "#{@binaries_url_root}/#{PhusionPassenger::VERSION_STRING}/#{basename}"
- tarball = "#{@working_dir}/#{basename}"
- if !download(url, tarball)
- puts "<b>Looks like it's not. But don't worry, the " +
- "necessary binaries will be compiled from source instead.</b>"
- return nil
- end
-
- FileUtils.mkdir_p(target)
- Dir.chdir(target) do
- return extract_tarball(tarball, &block)
- end
- rescue Interrupt
- exit 2
- end
-
- def download_and_extract_ruby_extension(target, &block)
- puts "<banner>Downloading Ruby extension for your Ruby and platform, if available...</banner>"
- basename = "rubyext-#{PlatformInfo.ruby_extension_binary_compatibility_id}.tar.gz"
- url = "#{@binaries_url_root}/#{PhusionPassenger::VERSION_STRING}/#{basename}"
- tarball = "#{@working_dir}/#{basename}"
- if !download(url, tarball)
- puts "<b>Looks like it's not. But don't worry, the " +
- "necessary binaries will be compiled from source instead.</b>"
- return nil
- end
-
- FileUtils.mkdir_p(target)
- Dir.chdir(target) do
- return extract_tarball(tarball, &block)
- end
- rescue Interrupt
- exit 2
- end
-
- def download_and_extract_nginx_binaries(target, &block)
- puts "<banner>Downloading Nginx binaries for your platform, if available...</banner>"
- basename = "nginx-#{@nginx_version}-#{PlatformInfo.cxx_binary_compatibility_id}.tar.gz"
- url = "#{@binaries_url_root}/#{PhusionPassenger::VERSION_STRING}/#{basename}"
- tarball = "#{@working_dir}/#{basename}"
- if !download(url, tarball)
- puts "<b>Looks like it's not. But don't worry, the " +
- "necessary binaries will be compiled from source instead.</b>"
- return nil
- end
-
- FileUtils.mkdir_p(target)
- Dir.chdir(target) do
- return extract_tarball(tarball, &block)
- end
- rescue Interrupt
- exit 2
- end
-
- def download_and_extract_nginx_sources(&block)
- if @nginx_tarball
- tarball = @nginx_tarball
- else
- puts "<banner>Downloading Nginx...</banner>"
- basename = "nginx-#{@nginx_version}.tar.gz"
- tarball = "#{@working_dir}/#{basename}"
- if !download("http://nginx.org/download/#{basename}", tarball)
- return nil
- end
- end
- nginx_sources_name = "nginx-#{@nginx_version}"
-
- Dir.chdir(@working_dir) do
- begin_progress_bar
- if extract_tarball(tarball, &block)
- return "#{@working_dir}/#{nginx_sources_name}"
- else
- return nil
- end
- end
- rescue Interrupt
- exit 2
- end
-
- def install_ruby_extension
- begin_progress_bar
- yield(0, 1, 0, "Preparing Ruby extension...")
- Dir.chdir(PhusionPassenger.source_root) do
- run_rake_task!("native_support CACHING=false ONLY_RUBY=yes RUBY_EXTENSION_OUTPUT_DIR='#{@ruby_dir}'") do |progress, total|
- yield(progress, total, 1, "Compiling Ruby extension...")
- end
- system "rm -rf '#{@ruby_dir}'/{*.log,*.o,Makefile}"
- end
- return 2
- end
-
- def install_binary_support_files
- begin_progress_bar
- yield(0, 1, 0, "Preparing Phusion Passenger...")
- Dir.chdir(PhusionPassenger.source_root) do
- args = "nginx_without_native_support" +
- " CACHING=false" +
- " OUTPUT_DIR='#{@support_dir}'"
- run_rake_task!(args) do |progress, total|
- yield(progress, total, 1, "Compiling Phusion Passenger...")
- end
-
- system "rm -rf '#{@support_dir}'/agents/{*.o,*.dSYM}"
- system "rm -rf '#{@support_dir}'/common/libboost_oxt"
- system "rm -rf '#{@support_dir}'/*/{*.lo,*.h,*.log,Makefile,libtool,stamp-h1,config.status,.deps}"
- system "rm -rf '#{@support_dir}'/{libeio,libev}/*.o"
-
- # Retain only the object files that are needed for linking the Phusion Passenger module into Nginx.
- nginx_libs = COMMON_LIBRARY.
- only(*NGINX_LIBS_SELECTOR).
- set_output_dir("#{@support_dir}/libpassenger_common").
- link_objects
- Dir["#{@support_dir}/libpassenger_common/**/*"].each do |filename|
- if !nginx_libs.include?(filename) && File.file?(filename)
- File.unlink(filename)
- end
- end
- end
- return 2
- end
-
def install_nginx_from_source(source_dir)
require 'phusion_passenger/platform_info/compiler'
Dir.chdir(source_dir) do
shell = PlatformInfo.find_command('bash') || "sh"
command = ""
if @targets.include?(:support_binaries)
- if ENV['PASSENGER_DEBUG'] && !ENV['PASSENGER_DEBUG'].empty?
- output_dir = "#{PhusionPassenger.source_root}/buildout/common/libpassenger_common"
- else
- output_dir = "#{@support_dir}/common/libpassenger_common"
- end
+ output_dir = "#{@support_dir}/common/libpassenger_common"
nginx_libs = COMMON_LIBRARY.only(*NGINX_LIBS_SELECTOR).
set_output_dir(output_dir).
link_objects_as_string
command << "env PASSENGER_INCLUDEDIR='#{PhusionPassenger.include_dir}'" <<
" PASSENGER_LIBS='#{nginx_libs} #{output_dir}/../libboost_oxt.a' "
@@ -543,11 +577,11 @@
"--without-http_fastcgi_module " <<
"--without-http_scgi_module " <<
"--without-http_uwsgi_module " <<
"--with-http_gzip_static_module " <<
"--with-http_stub_status_module " <<
- "'--add-module=#{PhusionPassenger.source_root}/ext/nginx'"
+ "'--add-module=#{PhusionPassenger.nginx_module_source_dir}'"
run_command_with_throbber(command, "Preparing Nginx...") do |status_text|
yield(0, 1, status_text)
end
backlog = ""
@@ -560,27 +594,31 @@
yield(progress, total_lines, "Compiling Nginx core...")
progress += 1
end
end
if $?.exitstatus != 0
- STDERR.puts
- STDERR.puts "*** ERROR: unable to compile Nginx."
- STDERR.puts backlog
+ @stderr.puts
+ @stderr.puts "*** ERROR: unable to compile Nginx."
+ @stderr.puts backlog
exit 1
end
yield(1, 1, 'Copying files...')
if !system("cp -pR objs/nginx '#{@nginx_dir}/'")
- STDERR.puts
- STDERR.puts "*** ERROR: unable to copy Nginx binaries."
+ @stderr.puts
+ @stderr.puts "*** ERROR: unable to copy Nginx binary."
exit 1
end
- if !system("strip '#{@nginx_dir}/nginx'")
- STDERR.puts
- STDERR.puts "*** ERROR: unable to strip debugging symbols from the Nginx binary."
+ if !strip_binary("#{@nginx_dir}/nginx")
+ @stderr.puts
+ @stderr.puts "*** ERROR: unable to strip debugging symbols from the Nginx binary."
exit 1
end
end
+ end
+
+ def strip_binary(filename)
+ return system("strip", filename)
end
end
end # module Standalone
end # module PhusionPassenger