public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Search Repo:
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Add support for native Linux packages. Add Rake task for building a Debian 
package.
Hongli Lai (Phusion) (author)
Sat May 10 03:04:25 -0700 2008
commit  f51378b8b3e92a3ea4548c953de529a772578036
tree    af023a51a1c80c3c56e65fc65db2155978d42ffe
parent  d08249a5bf9f8a34032013300da369dab6b715c4
...
364
365
366
 
367
368
369
...
408
409
410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
412
413
...
364
365
366
367
368
369
370
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
0
@@ -364,6 +364,7 @@
0
     'doc/*/*/*/*',
0
     'doc/*/*/*/*/*',
0
     'doc/*/*/*/*/*/*',
0
+ 'debian/*',
0
     'ext/apache2/*.{cpp,h,c,TXT}',
0
     'ext/boost/*.{hpp,TXT}',
0
     'ext/boost/**/*.{hpp,cpp,pl,inl}',
0
@@ -408,6 +409,56 @@
0
 Rake::Task['package:gem'].prerequisites.unshift(:doc)
0
 Rake::Task['package:force'].prerequisites.unshift(:doc)
0
 task :clobber => :'package:clean'
0
+
0
+
0
+##### Misc
0
+
0
+desc "Create a fakeroot, useful for building native packages"
0
+task :fakeroot => [:apache2, :native_support, :doc] do
0
+ require 'rbconfig'
0
+ fakeroot = "pkg/fakeroot"
0
+ libdir = "#{fakeroot}#{Config::CONFIG['rubylibdir']}"
0
+ extdir = "#{fakeroot}#{Config::CONFIG['archdir']}"
0
+ moduledir = fakeroot + `#{APXS2} -q LIBEXECDIR`.strip
0
+ bindir = "#{fakeroot}#{Config::CONFIG['bindir']}"
0
+ docdir = "#{fakeroot}/usr/share/doc/passenger"
0
+
0
+ sh "rm -rf #{fakeroot}"
0
+ sh "mkdir -p #{fakeroot}"
0
+
0
+ sh "mkdir -p #{libdir}"
0
+ sh "cp -R lib/passenger #{libdir}/"
0
+ sh "echo -n '#{PACKAGE_VERSION}' > #{libdir}/passenger/VERSION.TXT"
0
+
0
+ sh "mkdir -p #{extdir}/passenger"
0
+ sh "cp -R ext/passenger/*.#{LIBEXT} #{extdir}/passenger/"
0
+
0
+ sh "mkdir -p #{moduledir}"
0
+ sh "cp ext/apache2/mod_passenger.so #{moduledir}/"
0
+
0
+ sh "mkdir -p #{bindir}"
0
+ sh "cp bin/* #{bindir}/"
0
+
0
+ sh "mkdir -p #{docdir}"
0
+ sh "cp -R doc/* #{docdir}/"
0
+ sh "rm -f #{docdir}/{definitions.h,Doxyfile}"
0
+end
0
+
0
+desc "Create a Debian package"
0
+task 'package:debian' => :fakeroot do
0
+ fakeroot = "pkg/fakeroot"
0
+ arch = `uname -m`.strip
0
+ if arch =~ /^i.86$/
0
+ arch = "i386"
0
+ end
0
+
0
+ sh "sed -i 's/Version: .*/Version: #{PACKAGE_VERSION}/' debian/control"
0
+ sh "cp -R debian #{fakeroot}/DEBIAN"
0
+ sh "sed -i 's/: any/: #{arch}/' #{fakeroot}/DEBIAN/control"
0
+ sh "sudo chown -R root:root #{fakeroot}"
0
+ sh "sudo dpkg -b #{fakeroot} pkg/passenger_#{PACKAGE_VERSION}-#{arch}.deb"
0
+ sh "sudo chown -R `whoami` #{fakeroot}"
0
+end
0
 
0
 
0
 ##### Misc
...
34
35
36
37
38
39
40
41
42
...
51
52
53
 
 
 
 
 
 
54
55
56
57
...
177
178
179
 
 
 
 
 
180
181
 
182
183
184
...
242
243
244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
246
247
...
34
35
36
 
 
 
37
38
39
...
48
49
50
51
52
53
54
55
56
57
58
59
60
...
180
181
182
183
184
185
186
187
188
 
189
190
191
192
...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
0
@@ -34,9 +34,6 @@
0
   
0
   PASSENGER_WEBSITE = "http://www.modrails.com/"
0
   PHUSION_WEBSITE = "www.phusion.nl"
0
- USERS_GUIDE = "#{PASSENGER_ROOT}/doc/Users guide.html"
0
- File.read("#{PASSENGER_ROOT}/Rakefile") =~ /^PACKAGE_VERSION = "(.*)"$/
0
- PASSENGER_VERSION = $1
0
   
0
   REQUIRED_DEPENDENCIES = [
0
     Dependencies::GCC,
0
@@ -51,6 +48,12 @@
0
   ]
0
   
0
   def start
0
+ if natively_packaged?
0
+ show_apache2_config_snippets
0
+ show_deployment_example
0
+ exit
0
+ end
0
+
0
     Dir.chdir(PASSENGER_ROOT)
0
     show_welcome_screen
0
     check_dependencies || exit(1)
0
0
@@ -177,8 +180,13 @@
0
   def show_apache2_config_snippets
0
     puts
0
     line
0
+ if natively_packaged?
0
+ module_location = `#{APXS2} -q LIBEXECDIR`.strip + "/mod_passenger.so"
0
+ else
0
+ module_location = "#{PASSENGER_ROOT}/ext/apache2/mod_passenger.so"
0
+ end
0
     render_template 'apache2_config_snippets',
0
- :module_location => "#{PASSENGER_ROOT}/ext/apache2/mod_passenger.so",
0
+ :module_location => module_location,
0
       :spawn_server_location => "#{PASSENGER_ROOT}/bin/passenger-spawn-server",
0
       :ruby => RUBY
0
     wait
0
@@ -242,6 +250,35 @@
0
       color_puts " Search Google."
0
     end
0
   end
0
+
0
+ def natively_packaged?
0
+ return self.class.natively_packaged?
0
+ end
0
+
0
+ def self.natively_packaged?
0
+ return File.expand_path(File.dirname(__FILE__)) == "/usr/bin"
0
+ end
0
+
0
+ def self.determine_version
0
+ if natively_packaged?
0
+ require 'rbconfig'
0
+ return File.read(Config::CONFIG['rubylibdir'] + "/passenger/VERSION.TXT")
0
+ else
0
+ File.read("#{PASSENGER_ROOT}/Rakefile") =~ /^PACKAGE_VERSION = "(.*)"$/
0
+ return $1
0
+ end
0
+ end
0
+
0
+ def self.determine_users_guide
0
+ if natively_packaged?
0
+ return "/usr/share/doc/passenger/Users guide.html"
0
+ else
0
+ return "#{PASSENGER_ROOT}/doc/Users guide.html"
0
+ end
0
+ end
0
+
0
+ PASSENGER_VERSION = determine_version
0
+ USERS_GUIDE = determine_users_guide
0
 end
0
 
0
 Installer.new.start
...
35
36
37
 
 
 
 
 
38
39
 
40
41
42
...
56
57
58
59
 
 
 
 
 
 
60
61
62
...
35
36
37
38
39
40
41
42
43
 
44
45
46
47
...
61
62
63
 
64
65
66
67
68
69
70
71
72
0
@@ -35,8 +35,13 @@
0
 
0
 
0
 
0
+
0
+def natively_packaged?
0
+ return File.expand_path(File.dirname(__FILE__)) == "/usr/bin"
0
+end
0
+
0
 trap("INT") { exit 1 }
0
-if File.exist?("#{PASSENGER_ROOT}/enterprisey.txt")enterprisey.txt")
0
+if File.exist?("#{PASSENGER_ROOT}/enterprisey.txt") || File.exist?("/etc/passenger_enterprisey.txt")
0
   puts "Congratulations, your Passenger Enterprise License has already been activated!"
0
 else
0
   puts %{
0
@@ -56,7 +61,12 @@
0
       STDERR.puts "Invalid key given. Please try again:"
0
     end
0
   end
0
- if system("touch", "#{PASSENGER_ROOT}/enterprisey.txt")
0
+ if natively_packaged?
0
+ enterprise_file = "/etc/passenger_enterprisey.txt"
0
+ else
0
+ enterprise_file = "#{PASSENGER_ROOT}/enterprisey.txt"
0
+ end
0
+ if system("touch", enterprise_file)
0
     puts "Congratulations! Your Passenger Enterprise License has been activated!"
0
     puts "Please restart Apache to take full advantage of your Enterprise License."
0
   else
...
 
...
1
0
@@ -1 +1,2 @@
0
+5
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -1 +1,18 @@
0
+Package: passenger
0
+Version: 1.0.5
0
+Section: net
0
+Priority: optional
0
+Architecture: any
0
+Essential: no
0
+Depends: ruby1.8 (>= 1.8.6), apache2 (>= 2.0.0)
0
+Pre-Depends:
0
+Recommends:
0
+Suggests:
0
+Maintainer: Hongli Lai <hongli@phusion.nl>
0
+Conflicts:
0
+Replaces:
0
+Provides:
0
+Installed-Size: 1741
0
+Description: Phusion Passenger, Ruby on Rails deployment module for Apache.
0
+ Phusion Passenger makes deploying Ruby on Rails applications on Apache a breeze.
...
 
 
...
1
2
0
@@ -1 +1,3 @@
0
+#!/bin/sh
0
+exit 0
...
 
...
1
0
@@ -1 +1,2 @@
0
+#!/bin/sh
...
102
103
104
105
106
107
108
109
110
111
112
113
114
...
328
329
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
332
333
...
102
103
104
 
 
 
 
 
 
 
105
106
107
...
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
0
@@ -102,13 +102,6 @@
0
   NINJA_PATCHING_LOCK = Mutex.new
0
   @@ninja_patched_action_controller = false
0
   
0
- File.read("#{File.dirname(__FILE__)}/../../Rakefile") =~ /^PACKAGE_VERSION = "(.*)"$/
0
- PASSENGER_VERSION = $1
0
- PASSENGER_HEADER = "Phusion Passenger (mod_rails) #{PASSENGER_VERSION}"
0
- if File.exist?("#{File.dirname(__FILE__)}/../../enterprisey.txt")
0
- PASSENGER_HEADER << ", Enterprise Edition"
0
- end
0
-
0
   # The name of the socket on which the request handler accepts
0
   # new connections. This is either a Unix socket filename, or
0
   # the name for an abstract namespace Unix socket.
0
@@ -328,6 +321,29 @@
0
     end
0
     return data
0
   end
0
+
0
+ def self.determine_passenger_version
0
+ rakefile = "#{File.dirname(__FILE__)}/../../Rakefile"
0
+ if File.exist?(rakefile)
0
+ File.read(rakefile) =~ /^PACKAGE_VERSION = "(.*)"$/
0
+ return $1
0
+ else
0
+ return File.read("#{File.dirname(__FILE__)}/VERSION.TXT")
0
+ end
0
+ end
0
+
0
+ def self.determine_passenger_header
0
+ header = "Phusion Passenger (mod_rails) #{PASSENGER_VERSION}"
0
+ if File.exist?("#{File.dirname(__FILE__)}/../../enterprisey.txt") ||
0
+ File.exist?("/etc/passenger_enterprisey.txt")
0
+ header << ", Enterprise Edition"
0
+ end
0
+ return header
0
+ end
0
+
0
+public
0
+ PASSENGER_VERSION = determine_passenger_version
0
+ PASSENGER_HEADER = determine_passenger_header
0
 end
0
 
0
 end # module Passenger
...
247
248
249
250
 
 
251
252
253
...
247
248
249
 
250
251
252
253
254
0
@@ -247,7 +247,8 @@
0
   end
0
   
0
   def send_error_page(channel, template_name, options = {})
0
- options["enterprisey"] = File.exist?("#{File.dirname(__FILE__)}/../../enterprisey.txt")
0
+ options["enterprisey"] = File.exist?("#{File.dirname(__FILE__)}/../../enterprisey.txt") ||
0
+ File.exist?("/etc/passenger_enterprisey.txt")
0
     data = HTMLTemplate.new(template_name, options).result
0
     channel.write('error_page')
0
     channel.write_scalar(data)
...
20
21
22
23
 
 
 
 
 
24
25
26
...
20
21
22
 
23
24
25
26
27
28
29
30
0
@@ -20,7 +20,11 @@
0
 require 'thread'
0
 require 'fastthread'
0
 require 'timeout'
0
-require File.expand_path("#{File.dirname(__FILE__)}/../../ext/passenger/native_support.so")
0
+begin
0
+ require 'passenger/native_support'
0
+rescue LoadError
0
+ require File.expand_path("#{File.dirname(__FILE__)}/../../ext/passenger/native_support.so")
0
+end
0
 
0
 module Passenger
0
 

Comments

    No one has commented yet.