Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for native Linux packages. Add Rake task for building a D…

…ebian package.
  • Loading branch information...
commit f51378b8b3e92a3ea4548c953de529a772578036 1 parent d08249a
@FooBarWidget FooBarWidget authored
View
51 Rakefile
@@ -364,6 +364,7 @@ spec = Gem::Specification.new do |s|
'doc/*/*/*/*',
'doc/*/*/*/*/*',
'doc/*/*/*/*/*/*',
+ 'debian/*',
'ext/apache2/*.{cpp,h,c,TXT}',
'ext/boost/*.{hpp,TXT}',
'ext/boost/**/*.{hpp,cpp,pl,inl}',
@@ -412,6 +413,56 @@ task :clobber => :'package:clean'
##### Misc
+desc "Create a fakeroot, useful for building native packages"
+task :fakeroot => [:apache2, :native_support, :doc] do
+ require 'rbconfig'
+ fakeroot = "pkg/fakeroot"
+ libdir = "#{fakeroot}#{Config::CONFIG['rubylibdir']}"
+ extdir = "#{fakeroot}#{Config::CONFIG['archdir']}"
+ moduledir = fakeroot + `#{APXS2} -q LIBEXECDIR`.strip
+ bindir = "#{fakeroot}#{Config::CONFIG['bindir']}"
+ docdir = "#{fakeroot}/usr/share/doc/passenger"
+
+ sh "rm -rf #{fakeroot}"
+ sh "mkdir -p #{fakeroot}"
+
+ sh "mkdir -p #{libdir}"
+ sh "cp -R lib/passenger #{libdir}/"
+ sh "echo -n '#{PACKAGE_VERSION}' > #{libdir}/passenger/VERSION.TXT"
+
+ sh "mkdir -p #{extdir}/passenger"
+ sh "cp -R ext/passenger/*.#{LIBEXT} #{extdir}/passenger/"
+
+ sh "mkdir -p #{moduledir}"
+ sh "cp ext/apache2/mod_passenger.so #{moduledir}/"
+
+ sh "mkdir -p #{bindir}"
+ sh "cp bin/* #{bindir}/"
+
+ sh "mkdir -p #{docdir}"
+ sh "cp -R doc/* #{docdir}/"
+ sh "rm -f #{docdir}/{definitions.h,Doxyfile}"
+end
+
+desc "Create a Debian package"
+task 'package:debian' => :fakeroot do
+ fakeroot = "pkg/fakeroot"
+ arch = `uname -m`.strip
+ if arch =~ /^i.86$/
+ arch = "i386"
+ end
+
+ sh "sed -i 's/Version: .*/Version: #{PACKAGE_VERSION}/' debian/control"
+ sh "cp -R debian #{fakeroot}/DEBIAN"
+ sh "sed -i 's/: any/: #{arch}/' #{fakeroot}/DEBIAN/control"
+ sh "sudo chown -R root:root #{fakeroot}"
+ sh "sudo dpkg -b #{fakeroot} pkg/passenger_#{PACKAGE_VERSION}-#{arch}.deb"
+ sh "sudo chown -R `whoami` #{fakeroot}"
+end
+
+
+##### Misc
+
desc "Run 'sloccount' to see how much code Passenger has"
task :sloccount do
ENV['LC_ALL'] = 'C'
View
45 bin/passenger-install-apache2-module
@@ -34,9 +34,6 @@ class Installer
PASSENGER_WEBSITE = "http://www.modrails.com/"
PHUSION_WEBSITE = "www.phusion.nl"
- USERS_GUIDE = "#{PASSENGER_ROOT}/doc/Users guide.html"
- File.read("#{PASSENGER_ROOT}/Rakefile") =~ /^PACKAGE_VERSION = "(.*)"$/
- PASSENGER_VERSION = $1
REQUIRED_DEPENDENCIES = [
Dependencies::GCC,
@@ -51,6 +48,12 @@ class Installer
]
def start
+ if natively_packaged?
+ show_apache2_config_snippets
+ show_deployment_example
+ exit
+ end
+
Dir.chdir(PASSENGER_ROOT)
show_welcome_screen
check_dependencies || exit(1)
@@ -177,8 +180,13 @@ private
def show_apache2_config_snippets
puts
line
+ if natively_packaged?
+ module_location = `#{APXS2} -q LIBEXECDIR`.strip + "/mod_passenger.so"
+ else
+ module_location = "#{PASSENGER_ROOT}/ext/apache2/mod_passenger.so"
+ end
render_template 'apache2_config_snippets',
- :module_location => "#{PASSENGER_ROOT}/ext/apache2/mod_passenger.so",
+ :module_location => module_location,
:spawn_server_location => "#{PASSENGER_ROOT}/bin/passenger-spawn-server",
:ruby => RUBY
wait
@@ -242,6 +250,35 @@ private
color_puts " Search Google."
end
end
+
+ def natively_packaged?
+ return self.class.natively_packaged?
+ end
+
+ def self.natively_packaged?
+ return File.expand_path(File.dirname(__FILE__)) == "/usr/bin"
+ end
+
+ def self.determine_version
+ if natively_packaged?
+ require 'rbconfig'
+ return File.read(Config::CONFIG['rubylibdir'] + "/passenger/VERSION.TXT")
+ else
+ File.read("#{PASSENGER_ROOT}/Rakefile") =~ /^PACKAGE_VERSION = "(.*)"$/
+ return $1
+ end
+ end
+
+ def self.determine_users_guide
+ if natively_packaged?
+ return "/usr/share/doc/passenger/Users guide.html"
+ else
+ return "#{PASSENGER_ROOT}/doc/Users guide.html"
+ end
+ end
+
+ PASSENGER_VERSION = determine_version
+ USERS_GUIDE = determine_users_guide
end
Installer.new.start
View
14 bin/passenger-make-enterprisey
@@ -35,8 +35,13 @@ require 'digest/md5'
+
+def natively_packaged?
+ return File.expand_path(File.dirname(__FILE__)) == "/usr/bin"
+end
+
trap("INT") { exit 1 }
-if File.exist?("#{PASSENGER_ROOT}/enterprisey.txt")
+if File.exist?("#{PASSENGER_ROOT}/enterprisey.txt") || File.exist?("/etc/passenger_enterprisey.txt")
puts "Congratulations, your Passenger Enterprise License has already been activated!"
else
puts %{
@@ -56,7 +61,12 @@ else
STDERR.puts "Invalid key given. Please try again:"
end
end
- if system("touch", "#{PASSENGER_ROOT}/enterprisey.txt")
+ if natively_packaged?
+ enterprise_file = "/etc/passenger_enterprisey.txt"
+ else
+ enterprise_file = "#{PASSENGER_ROOT}/enterprisey.txt"
+ end
+ if system("touch", enterprise_file)
puts "Congratulations! Your Passenger Enterprise License has been activated!"
puts "Please restart Apache to take full advantage of your Enterprise License."
else
View
1  debian/compat
@@ -0,0 +1 @@
+5
View
17 debian/control
@@ -0,0 +1,17 @@
+Package: passenger
+Version: 1.0.5
+Section: net
+Priority: optional
+Architecture: any
+Essential: no
+Depends: ruby1.8 (>= 1.8.6), apache2 (>= 2.0.0)
+Pre-Depends:
+Recommends:
+Suggests:
+Maintainer: Hongli Lai <hongli@phusion.nl>
+Conflicts:
+Replaces:
+Provides:
+Installed-Size: 1741
+Description: Phusion Passenger, Ruby on Rails deployment module for Apache.
+ Phusion Passenger makes deploying Ruby on Rails applications on Apache a breeze.
View
2  debian/postinst
@@ -0,0 +1,2 @@
+#!/bin/sh
+exit 0
View
2  debian/prerm
@@ -0,0 +1,2 @@
+#!/bin/sh
+
View
30 lib/passenger/request_handler.rb
@@ -102,13 +102,6 @@ class RequestHandler
NINJA_PATCHING_LOCK = Mutex.new
@@ninja_patched_action_controller = false
- File.read("#{File.dirname(__FILE__)}/../../Rakefile") =~ /^PACKAGE_VERSION = "(.*)"$/
- PASSENGER_VERSION = $1
- PASSENGER_HEADER = "Phusion Passenger (mod_rails) #{PASSENGER_VERSION}"
- if File.exist?("#{File.dirname(__FILE__)}/../../enterprisey.txt")
- PASSENGER_HEADER << ", Enterprise Edition"
- end
-
# The name of the socket on which the request handler accepts
# new connections. This is either a Unix socket filename, or
# the name for an abstract namespace Unix socket.
@@ -328,6 +321,29 @@ def generate_random_id(method)
end
return data
end
+
+ def self.determine_passenger_version
+ rakefile = "#{File.dirname(__FILE__)}/../../Rakefile"
+ if File.exist?(rakefile)
+ File.read(rakefile) =~ /^PACKAGE_VERSION = "(.*)"$/
+ return $1
+ else
+ return File.read("#{File.dirname(__FILE__)}/VERSION.TXT")
+ end
+ end
+
+ def self.determine_passenger_header
+ header = "Phusion Passenger (mod_rails) #{PASSENGER_VERSION}"
+ if File.exist?("#{File.dirname(__FILE__)}/../../enterprisey.txt") ||
+ File.exist?("/etc/passenger_enterprisey.txt")
+ header << ", Enterprise Edition"
+ end
+ return header
+ end
+
+public
+ PASSENGER_VERSION = determine_passenger_version
+ PASSENGER_HEADER = determine_passenger_header
end
end # module Passenger
View
3  lib/passenger/spawn_manager.rb
@@ -247,7 +247,8 @@ def cleaner_thread_main
end
def send_error_page(channel, template_name, options = {})
- options["enterprisey"] = File.exist?("#{File.dirname(__FILE__)}/../../enterprisey.txt")
+ options["enterprisey"] = File.exist?("#{File.dirname(__FILE__)}/../../enterprisey.txt") ||
+ File.exist?("/etc/passenger_enterprisey.txt")
data = HTMLTemplate.new(template_name, options).result
channel.write('error_page')
channel.write_scalar(data)
View
6 lib/passenger/utils.rb
@@ -20,7 +20,11 @@
require 'thread'
require 'fastthread'
require 'timeout'
-require File.expand_path("#{File.dirname(__FILE__)}/../../ext/passenger/native_support.so")
+begin
+ require 'passenger/native_support'
+rescue LoadError
+ require File.expand_path("#{File.dirname(__FILE__)}/../../ext/passenger/native_support.so")
+end
module Passenger
Please sign in to comment.
Something went wrong with that request. Please try again.