passenger 4.0.14 → 4.0.16

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (121) hide show
  1. data.tar.gz.asc +7 -7
  2. data/NEWS +69 -0
  3. data/bin/passenger-install-apache2-module +7 -1
  4. data/bin/passenger-install-nginx-module +18 -1
  5. data/build/apache2.rb +25 -1
  6. data/build/basics.rb +7 -4
  7. data/build/debian.rb +72 -25
  8. data/build/nginx.rb +24 -0
  9. data/build/packaging.rb +45 -3
  10. data/debian.template/{control → control.template} +17 -8
  11. data/debian.template/ruby-passenger.install.template +1 -0
  12. data/debian.template/rules.template +9 -3
  13. data/dev/run_travis.sh +14 -0
  14. data/doc/Users guide Apache.idmap.txt +64 -48
  15. data/doc/Users guide Apache.txt +127 -93
  16. data/doc/Users guide Nginx.idmap.txt +46 -28
  17. data/doc/Users guide Nginx.txt +100 -12
  18. data/doc/images/{conservative_spawning.png → direct_spawning.png} +0 -0
  19. data/doc/images/{conservative_spawning.svg → direct_spawning.svg} +0 -0
  20. data/doc/users_guide_snippets/installation.txt +107 -66
  21. data/doc/users_guide_snippets/passenger_spawn_method.txt +1 -1
  22. data/doc/users_guide_snippets/rvm_helper_tool.txt +0 -12
  23. data/doc/users_guide_snippets/tips.txt +70 -3
  24. data/doc/users_guide_snippets/under_the_hood/page_caching_support.txt +2 -0
  25. data/doc/users_guide_snippets/under_the_hood/relationship_with_ruby.txt +114 -0
  26. data/ext/apache2/Configuration.cpp +53 -101
  27. data/ext/apache2/Configuration.hpp +19 -41
  28. data/ext/apache2/ConfigurationCommands.cpp +95 -0
  29. data/ext/apache2/ConfigurationCommands.cpp.erb +91 -0
  30. data/ext/apache2/ConfigurationFields.hpp +59 -0
  31. data/ext/apache2/ConfigurationFields.hpp.erb +89 -0
  32. data/ext/apache2/ConfigurationSetters.cpp +223 -0
  33. data/ext/apache2/ConfigurationSetters.cpp.erb +126 -0
  34. data/ext/apache2/CreateDirConfig.cpp +50 -0
  35. data/ext/apache2/CreateDirConfig.cpp.erb +71 -0
  36. data/ext/apache2/Hooks.cpp +6 -0
  37. data/ext/apache2/MergeDirConfig.cpp +103 -0
  38. data/ext/apache2/MergeDirConfig.cpp.erb +81 -0
  39. data/ext/common/ApplicationPool2/AppTypes.cpp +2 -0
  40. data/ext/common/ApplicationPool2/AppTypes.h +2 -0
  41. data/ext/common/ApplicationPool2/Common.h +1 -1
  42. data/ext/common/ApplicationPool2/Group.h +56 -7
  43. data/ext/common/ApplicationPool2/Implementation.cpp +133 -31
  44. data/ext/common/ApplicationPool2/Options.h +23 -2
  45. data/ext/common/ApplicationPool2/Pool.h +8 -1
  46. data/ext/common/ApplicationPool2/Process.h +9 -0
  47. data/ext/common/ApplicationPool2/Session.h +1 -0
  48. data/ext/common/ApplicationPool2/Spawner.h +21 -19
  49. data/ext/common/ApplicationPool2/SuperGroup.h +1 -1
  50. data/ext/common/Constants.h +21 -17
  51. data/ext/common/Constants.h.erb +1 -1
  52. data/ext/common/Exceptions.h +19 -0
  53. data/ext/common/ServerInstanceDir.h +8 -4
  54. data/ext/common/Utils.cpp +33 -1
  55. data/ext/common/Utils.h +14 -0
  56. data/ext/common/Utils/StrIntUtils.cpp +16 -0
  57. data/ext/common/Utils/StrIntUtils.h +5 -0
  58. data/ext/common/agents/HelperAgent/Main.cpp +5 -5
  59. data/ext/common/agents/HelperAgent/RequestHandler.h +94 -45
  60. data/ext/common/agents/LoggingAgent/Main.cpp +10 -26
  61. data/ext/common/agents/Watchdog/Main.cpp +4 -15
  62. data/ext/nginx/CacheLocationConfig.c +501 -0
  63. data/ext/nginx/CacheLocationConfig.c.erb +140 -0
  64. data/ext/nginx/Configuration.c +29 -453
  65. data/ext/nginx/Configuration.h +3 -21
  66. data/ext/nginx/ConfigurationCommands.c +501 -0
  67. data/ext/nginx/ConfigurationCommands.c.erb +136 -0
  68. data/ext/nginx/ConfigurationFields.h +89 -0
  69. data/ext/nginx/ConfigurationFields.h.erb +85 -0
  70. data/ext/nginx/ContentHandler.c +3 -166
  71. data/ext/nginx/CreateLocationConfig.c +146 -0
  72. data/ext/nginx/CreateLocationConfig.c.erb +70 -0
  73. data/ext/nginx/MergeLocationConfig.c +166 -0
  74. data/ext/nginx/MergeLocationConfig.c.erb +72 -0
  75. data/ext/nginx/config +4 -0
  76. data/ext/oxt/detail/tracable_exception_disabled.hpp +21 -1
  77. data/ext/oxt/detail/tracable_exception_enabled.hpp +4 -1
  78. data/ext/oxt/implementation.cpp +7 -1
  79. data/ext/oxt/macros.hpp +9 -7
  80. data/helper-scripts/backtrace-sanitizer.rb +23 -0
  81. data/helper-scripts/classic-rails-loader.rb +23 -0
  82. data/helper-scripts/classic-rails-preloader.rb +23 -0
  83. data/helper-scripts/download_binaries/extconf.rb +10 -5
  84. data/helper-scripts/meteor-loader.rb +127 -0
  85. data/helper-scripts/node-loader.js +1 -1
  86. data/helper-scripts/rack-preloader.rb +23 -0
  87. data/helper-scripts/system-memory-stats.py +22 -0
  88. data/helper-scripts/touch-dir.sh +48 -0
  89. data/lib/phusion_passenger.rb +1 -1
  90. data/lib/phusion_passenger/apache2/config_options.rb +104 -0
  91. data/lib/phusion_passenger/constants.rb +8 -0
  92. data/lib/phusion_passenger/native_support.rb +9 -1
  93. data/lib/phusion_passenger/nginx/config_options.rb +328 -0
  94. data/lib/phusion_passenger/packaging.rb +2 -2
  95. data/lib/phusion_passenger/platform_info/apache.rb +8 -0
  96. data/lib/phusion_passenger/platform_info/compiler.rb +2 -2
  97. data/lib/phusion_passenger/rails3_extensions/init.rb +19 -4
  98. data/lib/phusion_passenger/ruby_core_enhancements.rb +4 -1
  99. data/lib/phusion_passenger/standalone/app_finder.rb +3 -2
  100. data/lib/phusion_passenger/standalone/command.rb +1 -0
  101. data/lib/phusion_passenger/standalone/runtime_installer.rb +1 -6
  102. data/lib/phusion_passenger/standalone/runtime_locator.rb +9 -2
  103. data/lib/phusion_passenger/standalone/start_command.rb +45 -9
  104. data/lib/phusion_passenger/utils.rb +4 -1
  105. data/resources/templates/{nginx → installer_common}/run_installer_as_root.txt.erb +3 -1
  106. data/resources/templates/nginx/nginx_module_sources_not_available.txt.erb +6 -0
  107. data/resources/templates/standalone/config.erb +8 -8
  108. data/test/cxx/ApplicationPool2/PoolTest.cpp +120 -3
  109. data/test/cxx/RequestHandlerTest.cpp +66 -3
  110. data/test/integration_tests/native_packaging_spec.rb +41 -0
  111. data/test/integration_tests/nginx_tests.rb +1 -0
  112. data/test/integration_tests/standalone_tests.rb +4 -0
  113. data/test/ruby/shared/rails/analytics_logging_extensions_sharedspec.rb +22 -0
  114. data/test/stub/rails3.0/config/initializers/passenger.rb +2 -1
  115. data/test/stub/rails3.1/config/initializers/passenger.rb +2 -1
  116. data/test/stub/rails3.2/config/initializers/passenger.rb +2 -1
  117. data/test/stub/rails4.0/config/initializers/passenger.rb +5 -1
  118. data/test/stub/wsgi/passenger_wsgi.py +5 -0
  119. metadata +32 -7
  120. metadata.gz.asc +7 -7
  121. data/resources/templates/apache2/run_installer_as_root.txt.erb +0 -8
data.tar.gz.asc CHANGED
@@ -2,11 +2,11 @@
2
2
  Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
3
  Comment: GPGTools - http://gpgtools.org
4
4
 
5
- iQEcBAABAgAGBQJSEm1+AAoJECrHRaUKISqMwjAIAJrI1rdd3Cxrencb3E/rKc2R
6
- Fdb0rEgFsPDGSa/D51kAhma2jzxjkGzQUS9k6DCrs9Qfmb5G9PkLaPjh1dIMT0zA
7
- PhLuhZu4wjxrcwlrZsKxljOq1R+t9IYdjYNKgzwHbF51dM2yTrHmAAuCI4ZS44WD
8
- 2RnLomVLPmIsRVm7wxmtlMl1gUrVs2U1r259tF2+z4XS+VVOqM9bhgpFcY2Mj7Bg
9
- f0PFi+aXYpSjl1QwI7eyYdA/TLvOSbSRO9FuLvG3jnN4JI0/vzndS1+gRn5ToykI
10
- 7q4PfQPVhA/R6b05HcRfrXX+l9WNWFh1duuTAmfvi5jydoIpgY/ROmIAeitPkak=
11
- =2H4W
5
+ iQEcBAABAgAGBQJSKZrGAAoJECrHRaUKISqMSw4IALeI7526hdG7s9eK1Mg1Lq2R
6
+ AP5fKUs2NPcSs34YVNlUyWrnkYL+ekYdW1m9JvRFnQBfTi9IC4ZlTR8fl0DRujE5
7
+ 9EZotMJVqna3t/oKTHcG1ZhP9YbMH/InTs6VMtZJoXBBnlVqRsXyXusOoS95HZj8
8
+ uVzu5lMQ2r5uy1GrWaVURjilhn+qVMRgGP8e00HBEAjCBu12WMazctIhL6uQdlPi
9
+ vmClzAjp5MAJFFQyzqtClteobIzqRBekzgrpw6MRjiCgiCqxBRMlFsDTdOuWAnEj
10
+ CabdEhIalAfeNHgpPDdFNO3qKYdMZKMMr4UNIST/GyttFZQynTCWpsKu/Pul6hk=
11
+ =7YRG
12
12
  -----END PGP SIGNATURE-----
data/NEWS CHANGED
@@ -1,3 +1,72 @@
1
+ Release 4.0.16
2
+ --------------
3
+
4
+ * Allow Phusion Passenger to work properly on systems where the user's GID
5
+ does not have a proper entry in /etc/group, such as Heroku.
6
+
7
+
8
+ Release 4.0.15
9
+ --------------
10
+
11
+ * Out-of-band work has been much improved. The number of processes which
12
+ may perform out-of-band work concurrently has been limited to 1.
13
+ Furthermore, processes which are performing out-of-band work are now
14
+ included in the max pool size constraint calculation. However, this
15
+ means that in order to use out-of-band work, you need to have at least
16
+ 2 application processes running. Out-of-band work will never be triggered
17
+ if you just have 1 process. Partially fixes issue #892.
18
+ * Phusion Passenger now displays an error message to clients if too many
19
+ requests are queued up. By default, "too many" is 100. You may customize
20
+ this with `PassengerMaxRequestQueueSize` (Apache) or
21
+ `passenger_max_request_queue_size` (Nginx).
22
+ * A new configuration option, `PassengerStartTimeout` (Apache) and
23
+ `passenger_start_timeout` (Nginx), has been added. This option allows you
24
+ to specify a timeout for application startup. The startup timeout has exited
25
+ since version 4.0.0, but before version 4.0.15 it was hardcoded at a value
26
+ of 90 seconds. Now it is customizable. Fixes issue #936.
27
+ * [Enterprise] The `PassengerMaxRequestTime`/`passenger_max_request_time`
28
+ feature is now available for Python and Node.js as well, and is no longer
29
+ limited to just Ruby. Fixes issue #938.
30
+ * [Nginx] Introduced a configuration option `passenger_intercept_errors`,
31
+ which decides if Nginx will intercept responses with HTTP status codes of
32
+ 400 and higher. Its effect is similar to `proxy_intercept_errors`.
33
+ * [Standalone] Memory usage optimization: when `passenger start` is run with
34
+ `--daemonize`, the frontend exits after starting the Nginx core. This saves
35
+ ~20 MB of memory per `passenger start` instance.
36
+ * [Standalone] Phusion Passenger Standalone is now also packaged in the
37
+ Debian packages.
38
+ * [Standalone] Fix a problem with the `passenger stop` command on Ruby 1.8.7.
39
+ The 'thread' library was not properly required, causing a crash.
40
+ * [Standalone] There is now builtin support for SSL.
41
+ * Fix a crash when multiple `passenger_pass_header` directives are set.
42
+ Fixes issue #934.
43
+ * Permissions on the server instance directory are now explicitly set
44
+ with chmod, so that permissions are correct on systems with a non-default
45
+ umask. Fixes issue #928.
46
+ * Fix permission problems when running `passenger start` with `--user`.
47
+ * `passenger-config --detect-apache2` now correctly detects the eror log
48
+ filename on Amazon Linux. Fixes issue #933.
49
+ * An environment variable `PASSENGER_THREAD_LOCAL_STORAGE` has been added
50
+ to the build system for forcefully disabling the use of thread-local
51
+ storage within the Phusion Passenger codebase. This flag useful on systems
52
+ that have broken support for thread-local storage, despite passing our build
53
+ system's check for proper thread-local storage support. At the time of
54
+ writing, one user has reported that Ubuntu 12.04 32-bit has broken
55
+ thread-local storage report although neither the reporter nor us were able
56
+ to reproduce the problem on any other systems running Ubuntu 12.04 32-bit.
57
+ Note that this flag has no effect on non-Phusion Passenger code. Fixes
58
+ issue #937.
59
+ * It is now possible to preprocess events before they are sent to Union
60
+ Station. This is useful for removing confidential data as demonstrated in
61
+ this example `config/initializers/passenger.rb` file:
62
+
63
+ if defined?(PhusionPassenger)
64
+ event_preprocessor = lambda do |e|
65
+ e.payload[:sql].gsub!("secret","PASSWORD") if e.payload[:sql]
66
+ end
67
+ PhusionPassenger.install_framework_extensions!(:event_preprocessor => event_preprocessor)
68
+ end
69
+
1
70
  Release 4.0.14
2
71
  --------------
3
72
 
@@ -147,7 +147,12 @@ private
147
147
  if Process.uid == 0
148
148
  render_template 'apache2/no_write_permission_to_passenger_root'
149
149
  else
150
- render_template 'apache2/run_installer_as_root'
150
+ render_template 'installer_common/run_installer_as_root',
151
+ :dir => PhusionPassenger.source_root,
152
+ :sudo => PhusionPassenger::PlatformInfo.ruby_sudo_command,
153
+ :sudo_e => "#{PhusionPassenger::PlatformInfo.ruby_sudo_command} -E",
154
+ :ruby => PhusionPassenger::PlatformInfo.ruby_command,
155
+ :installer => "#{PhusionPassenger.bin_dir}/passenger-install-apache2-module #{ORIG_ARGV.join(' ')}"
151
156
  end
152
157
  return false
153
158
  ensure
@@ -205,6 +210,7 @@ private
205
210
  end
206
211
  end
207
212
 
213
+ ORIG_ARGV = ARGV.dup
208
214
  options = {}
209
215
  parser = OptionParser.new do |opts|
210
216
  opts.banner = "Usage: passenger-install-apache2-module [options]"
@@ -71,6 +71,7 @@ class Installer < PhusionPassenger::AbstractInstaller
71
71
  ENV['PATH'] = PhusionPassenger.bin_dir + ":" + ENV['PATH']
72
72
 
73
73
  show_welcome_screen
74
+ check_nginx_module_sources_available || exit(1)
74
75
  check_dependencies || exit(1)
75
76
  if needs_compiling_support_files?
76
77
  check_whether_we_can_write_to(PhusionPassenger.source_root) || exit(1)
@@ -136,6 +137,16 @@ private
136
137
  wait
137
138
  end
138
139
 
140
+ def check_nginx_module_sources_available
141
+ if PhusionPassenger.natively_packaged? && !File.exist?(PhusionPassenger.nginx_module_source_dir)
142
+ new_screen
143
+ render_template 'nginx/nginx_module_sources_not_available'
144
+ return false
145
+ else
146
+ return true
147
+ end
148
+ end
149
+
139
150
  def needs_compiling_support_files?
140
151
  return PhusionPassenger.originally_packaged?
141
152
  end
@@ -342,7 +353,12 @@ private
342
353
  if Process.uid == 0
343
354
  render_template 'nginx/cannot_write_to_dir', :dir => dir
344
355
  else
345
- render_template 'nginx/run_installer_as_root', :dir => dir
356
+ render_template 'installer_common/run_installer_as_root',
357
+ :dir => dir,
358
+ :sudo => PhusionPassenger::PlatformInfo.ruby_sudo_command,
359
+ :sudo_e => "#{PhusionPassenger::PlatformInfo.ruby_sudo_command} -E",
360
+ :ruby => PhusionPassenger::PlatformInfo.ruby_command,
361
+ :installer => "#{PhusionPassenger.bin_dir}/passenger-install-nginx-module #{ORIG_ARGV.join(' ')}"
346
362
  end
347
363
  return false
348
364
  ensure
@@ -457,6 +473,7 @@ private
457
473
  end
458
474
  end
459
475
 
476
+ ORIG_ARGV = ARGV.dup
460
477
  options = {}
461
478
  parser = OptionParser.new do |opts|
462
479
  opts.banner = "Usage: passenger-install-nginx-module [options]"
@@ -73,6 +73,14 @@ APACHE2_MODULE_COMMON_LIBRARIES = COMMON_LIBRARY.
73
73
  define_tasks(PlatformInfo.apache2_module_cflags).
74
74
  link_objects
75
75
 
76
+ auto_generated_sources = [
77
+ 'ext/apache2/ConfigurationCommands.cpp',
78
+ 'ext/apache2/ConfigurationFields.hpp',
79
+ 'ext/apache2/CreateDirConfig.cpp',
80
+ 'ext/apache2/MergeDirConfig.cpp',
81
+ 'ext/apache2/ConfigurationSetters.cpp'
82
+ ]
83
+
76
84
 
77
85
  desc "Build Apache 2 module"
78
86
  task :apache2 => [
@@ -87,7 +95,7 @@ task :apache2 => [
87
95
 
88
96
  # Define rules for the individual Apache 2 module source files.
89
97
  APACHE2_MODULE_INPUT_FILES.each_pair do |target, sources|
90
- extra_deps = ['ext/common/Constants.h']
98
+ extra_deps = ['ext/common/Constants.h'] + auto_generated_sources
91
99
  file(target => sources + extra_deps) do
92
100
  object_basename = File.basename(target)
93
101
  object_filename = APACHE2_OUTPUT_DIR + object_basename
@@ -97,6 +105,7 @@ end
97
105
 
98
106
 
99
107
  dependencies = [
108
+ auto_generated_sources,
100
109
  APACHE2_MODULE_COMMON_LIBRARIES,
101
110
  APACHE2_MODULE_BOOST_OXT_LIBRARY,
102
111
  APACHE2_MOD_PASSENGER_O,
@@ -135,3 +144,18 @@ task 'apache2:clean' => 'common:clean' do
135
144
  files << APACHE2_MODULE
136
145
  sh("rm", "-rf", *files)
137
146
  end
147
+
148
+ def create_apache2_auto_generated_source_task(source)
149
+ dependencies = [
150
+ "#{source}.erb",
151
+ 'lib/phusion_passenger/apache2/config_options.rb'
152
+ ]
153
+ file(source => dependencies) do
154
+ template = TemplateRenderer.new("#{source}.erb")
155
+ template.render_to(source)
156
+ end
157
+ end
158
+
159
+ auto_generated_sources.each do |source|
160
+ create_apache2_auto_generated_source_task(source)
161
+ end
@@ -21,7 +21,10 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
23
 
24
- require 'rubygems'
24
+ begin
25
+ require 'rubygems'
26
+ rescue LoadError
27
+ end
25
28
  require 'pathname'
26
29
  require 'fileutils'
27
30
  require 'phusion_passenger'
@@ -48,7 +51,7 @@ require 'build/cplusplus_support'
48
51
  class TemplateRenderer
49
52
  def initialize(filename)
50
53
  require 'erb' if !defined?(ERB)
51
- @erb = ERB.new(File.read(filename))
54
+ @erb = ERB.new(File.read(filename), nil, "-")
52
55
  @erb.filename = filename
53
56
  end
54
57
 
@@ -63,7 +66,7 @@ class TemplateRenderer
63
66
  # have write access to the source root (for example, when Passenger
64
67
  # Standalone is compiling its runtime), so we only write to the file
65
68
  # when necessary.
66
- if File.writable?(filename) || File.read(filename) != text
69
+ if !File.exist?(filename) || File.writable?(filename) || File.read(filename) != text
67
70
  File.open(filename, 'w') do |f|
68
71
  f.write(text)
69
72
  end
@@ -125,7 +128,6 @@ end
125
128
 
126
129
  PACKAGE_NAME = PhusionPassenger::PACKAGE_NAME
127
130
  PACKAGE_VERSION = PhusionPassenger::VERSION_STRING
128
- PACKAGE_SIGNING_KEY = string_option('PACKAGE_SIGNING_KEY', '0x0A212A8C')
129
131
  MAINTAINER_NAME = "Phusion"
130
132
  MAINTAINER_EMAIL = "info@phusion.nl"
131
133
 
@@ -173,6 +175,7 @@ EXTRA_CXXFLAGS << " -mno-tls-direct-seg-refs" if PlatformInfo.requires_no_tls_di
173
175
  EXTRA_CXXFLAGS << " -Wno-ambiguous-member-template" if PlatformInfo.cxx_is_clang?
174
176
  EXTRA_CXXFLAGS << " #{OPTIMIZATION_FLAGS}" if !OPTIMIZATION_FLAGS.empty?
175
177
  EXTRA_CXXFLAGS << " " << string_option('EXTRA_CXXFLAGS').gsub("\n", " ") if string_option('EXTRA_CXXFLAGS')
178
+ EXTRA_CXXFLAGS << " -DPASSENGER_DISABLE_THREAD_LOCAL_STORAGE" if !boolean_option('PASSENGER_THREAD_LOCAL_STORAGE', true)
176
179
 
177
180
  # Extra linker flags that should always be passed to the linker.
178
181
  # These should be included first in the command string, before anything else.
@@ -22,24 +22,32 @@
22
22
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  # THE SOFTWARE.
24
24
 
25
+ require 'phusion_passenger/constants'
25
26
  require 'build/preprocessor'
26
27
 
27
- ALL_DISTRIBUTIONS = ["raring", "quantal", "precise", "lucid"]
28
+ # If you change the default distribution list, don't forget to update the configuration
29
+ # file in passenger_apt_automation too: https://github.com/phusion/passenger_apt_automation
30
+ ALL_DISTRIBUTIONS = string_option("DEBIAN_DISTROS", "raring precise lucid").split(/[ ,]/)
28
31
  DEBIAN_NAME = "ruby-passenger"
29
32
  DEBIAN_EPOCH = 1
33
+ DEBIAN_ARCHS = string_option("DEBIAN_ARCHS", "i386 amd64").split(/[ ,]/)
30
34
  DEBIAN_ORIG_TARBALL_FILES = lambda { PhusionPassenger::Packaging.debian_orig_tarball_files }
31
35
 
32
- def create_debian_package_dir(distribution)
36
+ def create_debian_package_dir(distribution, output_dir = PKG_DIR)
33
37
  require 'time'
34
38
 
35
39
  variables = {
36
40
  :distribution => distribution
37
41
  }
38
42
 
39
- root = "#{PKG_DIR}/#{distribution}"
43
+ root = "#{output_dir}/#{distribution}"
44
+ orig_tarball = File.expand_path("#{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz")
45
+
40
46
  sh "rm -rf #{root}"
41
47
  sh "mkdir -p #{root}"
42
- recursive_copy_files(DEBIAN_ORIG_TARBALL_FILES.call, root)
48
+ sh "cd #{root} && tar xzf #{orig_tarball}"
49
+ sh "bash -c 'shopt -s dotglob && mv #{root}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}/* #{root}'"
50
+ sh "rmdir #{root}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}"
43
51
  recursive_copy_files(Dir["debian.template/**/*"], root,
44
52
  true, variables)
45
53
  sh "mv #{root}/debian.template #{root}/debian"
@@ -62,9 +70,19 @@ task 'debian:orig_tarball' => Packaging::PREGENERATED_FILES do
62
70
  "It will not be regenerated. If you are sure that the orig tarball is outdated, please delete it " +
63
71
  "and rerun this task."
64
72
  else
73
+ require 'phusion_passenger/constants'
74
+ sh "mkdir -p #{PKG_DIR}"
75
+ nginx_version = PhusionPassenger::PREFERRED_NGINX_VERSION
76
+ local_nginx_tarball = File.expand_path("#{PKG_DIR}/nginx-#{nginx_version}.tar.gz")
77
+ if File.exist?(local_nginx_tarball)
78
+ puts "#{local_nginx_tarball} already exists"
79
+ else
80
+ sh "curl -L -o #{local_nginx_tarball} http://nginx.org/download/nginx-#{nginx_version}.tar.gz"
81
+ end
65
82
  sh "rm -rf #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}"
66
83
  sh "mkdir -p #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}"
67
84
  recursive_copy_files(DEBIAN_ORIG_TARBALL_FILES.call, "#{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}")
85
+ sh "cd #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION} && tar xzf #{local_nginx_tarball}"
68
86
  sh "cd #{PKG_DIR} && tar -c #{DEBIAN_NAME}_#{PACKAGE_VERSION} | gzip --best > #{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz"
69
87
  end
70
88
  end
@@ -74,13 +92,10 @@ task 'debian:dev' do
74
92
  sh "rm -f #{PKG_DIR}/#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz"
75
93
  Rake::Task["debian:clean"].invoke
76
94
  Rake::Task["debian:orig_tarball"].invoke
77
- case distro = string_option('DISTRO', 'current')
78
- when 'current'
95
+ if string_option('DISTRO').nil?
79
96
  distributions = [File.read("/etc/lsb-release").scan(/^DISTRIB_CODENAME=(.+)/).first.first]
80
- when 'all'
81
- distributions = ALL_DISTRIBUTIONS
82
97
  else
83
- distributions = distro.split(',')
98
+ distributions = ALL_DISTRIBUTIONS
84
99
  end
85
100
  distributions.each do |distribution|
86
101
  create_debian_package_dir(distribution)
@@ -113,29 +128,61 @@ task 'debian:dev:reinstall' do
113
128
  end
114
129
  end
115
130
 
116
- desc "Build Debian source packages to be uploaded to repositories"
117
- task 'debian:production' => 'debian:orig_tarball' do
131
+ desc "Build official Debian source packages"
132
+ task 'debian:source_packages' => 'debian:orig_tarball' do
118
133
  if boolean_option('USE_CCACHE', false)
119
134
  # The resulting Debian rules file must not set USE_CCACHE.
120
- abort "USE_CCACHE must be returned off when running the debian:production task."
135
+ abort "USE_CCACHE must be returned off when running the debian:source_packages task."
121
136
  end
122
- if filename = string_option('GPG_PASSPHRASE_FILE')
123
- filename = File.expand_path(filename)
124
- if !File.exist?(filename)
125
- abort "GPG passphrase file #{filename} does not exist!"
126
- end
127
- if File.stat(filename).mode != 0100600
128
- abort "The GPG passphrase file #{filename} must be chmodded 0600!"
129
- end
130
- gpg_options = "-p'gpg --passphrase-file #{filename} --no-use-agent'"
137
+
138
+ pkg_dir = "#{PKG_DIR}/official"
139
+ if File.exist?(pkg_dir)
140
+ abort "#{pkg_dir} must not already exist when running the debian:source_packages task."
131
141
  end
142
+ sh "mkdir #{pkg_dir}"
143
+ sh "cd #{pkg_dir} && ln -s ../#{DEBIAN_NAME}_#{PACKAGE_VERSION}.orig.tar.gz ."
132
144
 
133
145
  ALL_DISTRIBUTIONS.each do |distribution|
134
- create_debian_package_dir(distribution)
135
- sh "cd #{PKG_DIR}/#{distribution} && dpkg-checkbuilddeps"
146
+ create_debian_package_dir(distribution, pkg_dir)
136
147
  end
137
148
  ALL_DISTRIBUTIONS.each do |distribution|
138
- sh "cd #{PKG_DIR}/#{distribution} && debuild -S -sa #{gpg_options} -k#{PACKAGE_SIGNING_KEY}"
149
+ sh "cd #{pkg_dir}/#{distribution} && debuild -S -us -uc"
150
+ end
151
+ end
152
+
153
+ def pbuilder_base_name(distribution, arch)
154
+ if arch == "amd64"
155
+ return distribution
156
+ else
157
+ return "#{distribution}-#{arch}"
158
+ end
159
+ end
160
+
161
+ desc "Build official Debian binary packages"
162
+ task 'debian:binary_packages' do
163
+ pkg_dir = "#{PKG_DIR}/official"
164
+ if !File.exist?(pkg_dir)
165
+ abort "Please run rake debian:source_packages first."
166
+ end
167
+
168
+ all_distributions = [string_option('DISTRO') || ALL_DISTRIBUTIONS].flatten
169
+ pbuilder_dir = File.expand_path("~/pbuilder")
170
+
171
+ all_distributions.each do |distribution|
172
+ DEBIAN_ARCHS.each do |arch|
173
+ pbase_name = pbuilder_base_name(distribution, arch) + "-base.tgz"
174
+ if !File.exist?("#{pbuilder_dir}/#{pbase_name}")
175
+ abort "Missing pbuilder environment for #{distribution}-#{arch}. " +
176
+ "Please run this first: pbuilder-dist #{distribution} #{arch} create"
177
+ end
178
+ end
179
+ end
180
+
181
+ all_distributions.each do |distribution|
182
+ base_name = "#{DEBIAN_NAME}_#{PACKAGE_VERSION}-1~#{distribution}1"
183
+ DEBIAN_ARCHS.each do |arch|
184
+ sh "cd #{pkg_dir} && pbuilder-dist #{distribution} #{arch} build #{base_name}.dsc"
185
+ end
139
186
  end
140
187
  end
141
188
 
@@ -143,7 +190,7 @@ desc "Clean Debian packaging products, except for orig tarball"
143
190
  task 'debian:clean' do
144
191
  files = Dir["#{PKG_DIR}/*.{changes,build,deb,dsc,upload}"]
145
192
  sh "rm -f #{files.join(' ')}"
146
- sh "rm -rf #{PKG_DIR}/dev"
193
+ sh "rm -rf #{PKG_DIR}/official"
147
194
  ALL_DISTRIBUTIONS.each do |distribution|
148
195
  sh "rm -rf #{PKG_DIR}/#{distribution}"
149
196
  end
@@ -21,6 +21,14 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
23
 
24
+ auto_generated_sources = [
25
+ 'ext/nginx/ConfigurationCommands.c',
26
+ 'ext/nginx/CreateLocationConfig.c',
27
+ 'ext/nginx/MergeLocationConfig.c',
28
+ 'ext/nginx/CacheLocationConfig.c',
29
+ 'ext/nginx/ConfigurationFields.h'
30
+ ]
31
+
24
32
  desc "Build Nginx support files"
25
33
  task :nginx => [
26
34
  :nginx_without_native_support,
@@ -28,6 +36,7 @@ task :nginx => [
28
36
  ].compact
29
37
 
30
38
  task :nginx_without_native_support => [
39
+ auto_generated_sources,
31
40
  AGENT_OUTPUT_DIR + 'PassengerHelperAgent',
32
41
  AGENT_OUTPUT_DIR + 'PassengerWatchdog',
33
42
  AGENT_OUTPUT_DIR + 'PassengerLoggingAgent',
@@ -40,3 +49,18 @@ desc "Clean all compiled Nginx files"
40
49
  task 'nginx:clean' => 'common:clean' do
41
50
  # Nothing to clean at this time.
42
51
  end
52
+
53
+ def create_nginx_auto_generated_source_task(source)
54
+ dependencies = [
55
+ "#{source}.erb",
56
+ 'lib/phusion_passenger/nginx/config_options.rb'
57
+ ]
58
+ file(source => dependencies) do
59
+ template = TemplateRenderer.new("#{source}.erb")
60
+ template.render_to(source)
61
+ end
62
+ end
63
+
64
+ auto_generated_sources.each do |source|
65
+ create_nginx_auto_generated_source_task(source)
66
+ end