We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Begin working on a better installer.
Hongli Lai (Phusion) (author)
Wed Mar 12 18:50:15 -0700 2008
commit  9db19d149399b5770ca4c8abff5025c5a6cb7d2b
tree    ec907ad9dcd79a9703b3cc4b0042d53b7bbf76d3
parent  3ea77682cd5b8b0b104845c7423ac14bc1a70a75
...
1
2
3
4
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
...
1
2
 
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
0
@@ -1,9 +1,115 @@
0
 #!/usr/bin/env ruby
0
 PASSENGER_ROOT = File.expand_path(File.dirname(__FILE__) << "/..")
0
-PASSENGER_WEBSITE = "http://passenger.phusion.nl/"
0
-PHUSION_WEBSITE = "www.phusion.nl"
0
 $LOAD_PATH.unshift("#{PASSENGER_ROOT}/lib")
0
 require 'passenger/platform_info'
0
+require 'passenger/dependencies'
0
+require 'passenger/console_text_template'
0
+include Passenger
0
+include PlatformInfo
0
+
0
+class Installer
0
+ REQUIRED_DEPENDENCIES = [
0
+ Dependencies::Ruby_DevHeaders,
0
+ Dependencies::RubyGems,
0
+ Dependencies::Rake,
0
+ Dependencies::Apache2,
0
+ Dependencies::Apache2_DevHeaders,
0
+ Dependencies::APR_DevHeaders
0
+ ]
0
+
0
+ def start
0
+ check_dependencies
0
+ ensure
0
+ reset_terminal_colors
0
+ end
0
+
0
+ def init_terminal_colors
0
+ STDOUT.write("\e[0m\e[37m\e[40m")
0
+ STDOUT.flush
0
+ end
0
+
0
+ def reset_terminal_colors
0
+ STDOUT.write("\e[0m")
0
+ STDOUT.flush
0
+ end
0
+
0
+ def check_dependencies
0
+ missing_dependencies = []
0
+ color_puts "<banner>Checking for required software...</banner>"
0
+ puts
0
+ REQUIRED_DEPENDENCIES.each do |dep|
0
+ color_print " * #{dep.name}... "
0
+ result = dep.check
0
+ if result.found?
0
+ if result.found_at
0
+ color_puts "<green>found at #{result.found_at}</green>"
0
+ else
0
+ color_puts "<green>found</green>"
0
+ end
0
+ else
0
+ color_puts "<red>not found</red>"
0
+ missing_dependencies << dep
0
+ end
0
+ end
0
+
0
+ missing_dependencies = REQUIRED_DEPENDENCIES
0
+ if !missing_dependencies.empty?
0
+ puts
0
+ color_puts "<red>Some required software is not installed.</red>"
0
+ color_puts "But don't worry, this installer will tell you how to install them.\n"
0
+ color_puts "<b>Press Enter to continue, or Ctrl-C to abort.</b>"
0
+ wait
0
+
0
+ line
0
+ color_puts "<banner>Installation instructions for required software</banner>"
0
+ puts
0
+ missing_dependencies.each do |dep|
0
+ color_puts " * To install <yellow>#{dep.name}</yellow>:"
0
+ if !dep.install_command.nil?
0
+ color_puts " Please run <b>#{dep.install_command}</b> as root."
0
+ elsif !dep.install_instructions.nil?
0
+ color_puts " " << dep.install_instructions
0
+ elsif !dep.website.nil?
0
+ color_puts " Please download it from <b>#{dep.website}</b>"
0
+ else
0
+ color_puts " Search Google."
0
+ end
0
+ puts
0
+ end
0
+ end
0
+ end
0
+
0
+private
0
+ def color_print(text)
0
+ STDOUT.write(ConsoleTextTemplate.new(:text => text).result)
0
+ STDOUT.flush
0
+ end
0
+
0
+ def color_puts(text)
0
+ color_print("#{text}\n")
0
+ end
0
+
0
+ def line
0
+ puts "--------------------------------------------"
0
+ end
0
+
0
+ def wait
0
+ begin
0
+ STDIN.readline
0
+ rescue Interrupt
0
+ exit 2
0
+ end
0
+ end
0
+end
0
+
0
+Installer.new.start
0
+exit
0
+
0
+
0
+PASSENGER_WEBSITE = "http://passenger.phusion.nl/"
0
+PHUSION_WEBSITE = "www.phusion.nl"
0
+
0
+
0
 Dir.chdir(PASSENGER_ROOT)
0
 include PlatformInfo
0
 
...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
80
81
82
 
 
 
 
 
 
83
84
85
...
134
135
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
138
 
 
 
 
 
 
 
 
 
 
 
139
140
141
...
159
160
161
 
 
162
...
18
19
20
 
 
 
 
 
 
 
 
 
 
 
21
22
23
...
69
70
71
72
73
74
75
76
77
78
79
80
...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
...
199
200
201
202
203
204
0
@@ -18,17 +18,6 @@ private
0
   def self.env_defined?(name)
0
     return !ENV[name].nil? && !ENV[name]
0
   end
0
-
0
- def self.find_command(name)
0
- # system('which') is not compatible across Linux and BSD
0
- ENV['PATH'].split(File::PATH_SEPARATOR).detect do |directory|
0
- path = File.join(directory, name.to_s)
0
- if File.executable?(path)
0
- return path
0
- end
0
- end
0
- return nil
0
- end
0
 
0
   def self.find_apxs2
0
     if env_defined?("APXS2")
0
@@ -80,6 +69,12 @@ private
0
   
0
   def self.find_httpd
0
     if APXS2.nil?
0
+ ["apache2", "httpd2", "apache", "httpd"].each do |name|
0
+ command = find_command(name)
0
+ if !command.nil?
0
+ return command
0
+ end
0
+ end
0
       return nil
0
     else
0
       return find_apache2_executable(`#{APXS2} -q TARGET`.strip)
0
@@ -134,8 +129,53 @@ private
0
       return "so"
0
     end
0
   end
0
+
0
+ def self.read_file(filename)
0
+ return File.read(filename)
0
+ rescue
0
+ return ""
0
+ end
0
+
0
+ def self.determine_linux_distro
0
+ if RUBY_PLATFORM !~ /linux/
0
+ return nil
0
+ end
0
+ lsb_release = read_file("/etc/lsb-release")
0
+ if lsb_release =~ /Ubuntu/
0
+ return :ubuntu
0
+ elsif File.exist?("/etc/debian_version")
0
+ return :debian
0
+ elsif File.exist?("/etc/redhat-release")
0
+ redhat_release = read_file("/etc/redhat-release")
0
+ if redhat_release =~ /CentOS/
0
+ return :centos
0
+ elsif redhat_release =~ /Fedora/ # is this correct?
0
+ return :fedora
0
+ else
0
+ return :rhel
0
+ end
0
+ elsif File.exist?("/etc/suse-release")
0
+ return :suse
0
+ elsif File.exist?("/etc/gentoo-release")
0
+ return :gentoo
0
+ else
0
+ return :unknown
0
+ end
0
+ # TODO: Slackware, Mandrake/Mandriva
0
+ end
0
 
0
 public
0
+ def self.find_command(name)
0
+ # system('which') is not compatible across Linux and BSD
0
+ ENV['PATH'].split(File::PATH_SEPARATOR).detect do |directory|
0
+ path = File.join(directory, name.to_s)
0
+ if File.executable?(path)
0
+ return path
0
+ end
0
+ end
0
+ return nil
0
+ end
0
+
0
   # The absolute path to the current Ruby interpreter.
0
   RUBY = Config::CONFIG['bindir'] + '/' + Config::CONFIG['RUBY_INSTALL_NAME']
0
   
0
@@ -159,4 +199,6 @@ public
0
   MULTI_ARCH_FLAGS = determine_multi_arch_flags
0
   # The current platform's shared library extension ('so' on most Unices).
0
   LIBEXT = determine_library_extension
0
+ # An identifier for the current Linux distribution. nil if the operating system is not Linux.
0
+ LINUX_DISTRO = determine_linux_distro
0
 end

Comments

    No one has commented yet.