27
27
require 'phusion_passenger/platform_info'
28
28
require 'phusion_passenger/platform_info/operating_system'
29
29
require 'phusion_passenger/utils/ansi_colors'
31
33
# IMPORTANT: do not directly or indirectly require native_support; we can't compile
32
34
# it yet until we have a compiler, and installers usually check whether a compiler
74
rescue SignalException, SystemExit
72
76
rescue PlatformInfo::RuntimeError => e
74
78
puts "<red>An error occurred</red>"
83
show_support_options_for_installer_bug(e)
148
163
puts " #{dep.install_instructions}"
151
if respond_to?(:users_guide)
152
puts "If the aforementioned instructions didn't solve your problem, then please take"
153
puts "a look at the Users Guide:"
155
puts " <yellow>#{users_guide}</yellow>"
166
puts "If the aforementioned instructions didn't solve your problem, then please take"
167
puts "a look at the Users Guide:"
169
puts " <yellow>#{users_guide_path}</yellow>"
170
puts " <yellow>#{users_guide_url}</yellow>"
161
175
def check_whether_os_is_broken
162
if PlatformInfo.os_name == "freebsd9" && `uname -r` =~ /^9\.1-/
164
render_template 'installer_common/freebsd9_broken_cxx_runtime'
176
# No known broken OSes at the moment.
179
def check_gem_install_permission_problems
180
return true if PhusionPassenger.natively_packaged?
187
if Process.uid != 0 &&
188
PhusionPassenger.source_root =~ /^#{Regexp.escape home_dir}\// &&
189
PhusionPassenger.source_root =~ /^#{Regexp.escape Gem.dir}\// &&
190
File.stat(PhusionPassenger.source_root).uid == 0
192
render_template 'installer_common/gem_install_permission_problems'
199
def check_directory_accessible_by_web_server
200
return true if PhusionPassenger.natively_packaged?
201
inaccessible_directories = []
202
list_parent_directories(PhusionPassenger.source_root).each do |path|
203
if !world_executable?(path)
204
inaccessible_directories << path
207
if !inaccessible_directories.empty?
209
render_template 'installer_common/world_inaccessible_directories',
210
:directories => inaccessible_directories
189
235
:current => ram_mb + swap_mb,
191
237
:swap => swap_mb,
238
:doc_path => users_guide_path,
239
:doc_url => users_guide_url
244
def show_support_options_for_installer_bug(e)
245
# We do not use template rendering here. Since we've determined that there's
246
# a bug, *anything* may be broken, so we use the safest codepath to ensure that
247
# the user sees the proper messages.
250
@stderr.puts "*** EXCEPTION: #{e} (#{e.class})\n " +
251
e.backtrace.join("\n ")
253
puts '<red>Oops, something went wrong :-(</red>'
255
puts "We're sorry, but it looks like this installer ran into an unexpected problem.\n" +
256
"Please visit the following website for support. We'll do our best to help you.\n\n" +
257
" <b>#{SUPPORT_URL}</b>\n\n" +
258
"When submitting a support inquiry, please copy and paste the entire installler\n" +
260
rescue Exception => e2
261
# Raise original exception so that it doesn't get lost.
199
268
old_stdout = @stdout
204
273
@stdout = old_stdout
341
414
sh!("#{PlatformInfo.rake_command} #{args.join(' ')}")
344
def download(url, output)
417
def download(url, output, options = {})
418
if options[:use_cache] && cache_dir = PhusionPassenger.download_cache_dir
419
basename = url.sub(/.*\//, '')
420
if File.exist?("#{cache_dir}/#{basename}")
421
puts "Copying #{basename} from #{cache_dir}..."
422
FileUtils.cp("#{cache_dir}/#{basename}", output)
345
428
if PlatformInfo.find_command("wget")
346
return sh("wget", "-O", output, url)
430
args << "--ca-certificate=#{options[:cacert]}"
432
return sh("wget", "--tries=3", "-O", output, url, *args)
348
return sh("curl", url, "-f", "-L", "-o", output)
436
args << options[:cacert]
438
return sh("curl", url, "-f", "-L", "-o", output, *args)
442
def list_parent_directories(dir)
444
components = File.expand_path(dir).split(File::SEPARATOR)
445
components.shift # Remove leading /
446
components.size.times do |i|
447
dirs << File::SEPARATOR + components[0 .. i].join(File::SEPARATOR)
452
def world_executable?(dir)
454
stat = File.stat(dir)
455
rescue Errno::EACCESS
458
return stat.mode & 0000001 != 0