passenger 5.0.0.beta3 → 5.0.0.rc1
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.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.editorconfig +11 -5
- data/CHANGELOG +38 -0
- data/CONTRIBUTING.md +1 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -2
- data/Rakefile +33 -33
- data/bin/passenger +1 -1
- data/bin/passenger-config +1 -1
- data/bin/passenger-install-apache2-module +800 -800
- data/bin/passenger-install-nginx-module +592 -592
- data/bin/passenger-memory-stats +127 -127
- data/bin/passenger-status +216 -216
- data/build/agents.rb +127 -127
- data/build/apache2.rb +87 -87
- data/build/basics.rb +60 -60
- data/build/common_library.rb +165 -165
- data/build/cplusplus_support.rb +51 -51
- data/build/cxx_tests.rb +268 -268
- data/build/debian.rb +143 -143
- data/build/documentation.rb +58 -58
- data/build/integration_tests.rb +81 -81
- data/build/misc.rb +132 -132
- data/build/nginx.rb +20 -20
- data/build/node_tests.rb +7 -7
- data/build/oxt_tests.rb +14 -14
- data/build/packaging.rb +570 -570
- data/build/preprocessor.rb +260 -260
- data/build/rake_extensions.rb +71 -71
- data/build/ruby_extension.rb +29 -29
- data/build/ruby_tests.rb +6 -6
- data/build/test_basics.rb +37 -37
- data/debian.template/control.template +3 -5
- data/dev/copy_boost_headers +134 -134
- data/dev/install_scripts_bootstrap_code.rb +25 -25
- data/dev/list_tests +20 -20
- data/dev/ruby_server.rb +223 -223
- data/dev/runner +18 -18
- data/doc/ServerOptimizationGuide.txt.md +55 -2
- data/doc/Users guide Nginx.txt +0 -26
- data/doc/Users guide Standalone.txt +5 -1
- data/doc/users_guide_snippets/tips.txt +9 -0
- data/ext/common/ApplicationPool2/Group.h +23 -11
- data/ext/common/ApplicationPool2/Implementation.cpp +32 -7
- data/ext/common/ApplicationPool2/Pool.h +22 -17
- data/ext/common/ApplicationPool2/SmartSpawner.h +4 -1
- data/ext/common/ApplicationPool2/Spawner.h +1 -1
- data/ext/common/Constants.h +1 -1
- data/ext/common/agents/Base.cpp +35 -20
- data/ext/common/agents/HelperAgent/Main.cpp +8 -1
- data/ext/common/agents/HelperAgent/OptionParser.h +18 -4
- data/ext/common/agents/HelperAgent/RequestHandler.h +2 -83
- data/ext/common/agents/HelperAgent/RequestHandler/ForwardResponse.cpp +54 -1
- data/ext/common/agents/HelperAgent/RequestHandler/InitRequest.cpp +7 -4
- data/ext/common/agents/Main.cpp +1 -1
- data/ext/common/agents/Watchdog/Main.cpp +54 -19
- data/ext/nginx/Configuration.c +7 -0
- data/ext/nginx/ContentHandler.c +9 -1
- data/helper-scripts/backtrace-sanitizer.rb +106 -87
- data/helper-scripts/crash-watch.rb +32 -0
- data/helper-scripts/download_binaries/extconf.rb +38 -38
- data/helper-scripts/meteor-loader.rb +107 -107
- data/helper-scripts/prespawn +101 -101
- data/helper-scripts/rack-loader.rb +96 -96
- data/helper-scripts/rack-preloader.rb +137 -137
- data/lib/phusion_passenger.rb +292 -292
- data/lib/phusion_passenger/abstract_installer.rb +438 -438
- data/lib/phusion_passenger/active_support3_extensions/init.rb +168 -170
- data/lib/phusion_passenger/admin_tools.rb +20 -20
- data/lib/phusion_passenger/admin_tools/instance.rb +178 -178
- data/lib/phusion_passenger/admin_tools/instance_registry.rb +61 -61
- data/lib/phusion_passenger/admin_tools/memory_stats.rb +267 -267
- data/lib/phusion_passenger/apache2/config_options.rb +182 -182
- data/lib/phusion_passenger/common_library.rb +479 -485
- data/lib/phusion_passenger/config/about_command.rb +161 -161
- data/lib/phusion_passenger/config/admin_command_command.rb +129 -129
- data/lib/phusion_passenger/config/agent_compiler.rb +121 -121
- data/lib/phusion_passenger/config/build_native_support_command.rb +43 -43
- data/lib/phusion_passenger/config/command.rb +25 -25
- data/lib/phusion_passenger/config/compile_agent_command.rb +62 -62
- data/lib/phusion_passenger/config/compile_nginx_engine_command.rb +88 -73
- data/lib/phusion_passenger/config/detach_process_command.rb +72 -72
- data/lib/phusion_passenger/config/download_agent_command.rb +246 -227
- data/lib/phusion_passenger/config/download_nginx_engine_command.rb +245 -224
- data/lib/phusion_passenger/config/install_agent_command.rb +144 -132
- data/lib/phusion_passenger/config/install_standalone_runtime_command.rb +205 -185
- data/lib/phusion_passenger/config/installation_utils.rb +204 -204
- data/lib/phusion_passenger/config/list_instances_command.rb +64 -64
- data/lib/phusion_passenger/config/main.rb +152 -152
- data/lib/phusion_passenger/config/nginx_engine_compiler.rb +319 -300
- data/lib/phusion_passenger/config/reopen_logs_command.rb +67 -67
- data/lib/phusion_passenger/config/restart_app_command.rb +155 -155
- data/lib/phusion_passenger/config/system_metrics_command.rb +13 -13
- data/lib/phusion_passenger/config/utils.rb +95 -95
- data/lib/phusion_passenger/config/validate_install_command.rb +198 -198
- data/lib/phusion_passenger/console_text_template.rb +25 -25
- data/lib/phusion_passenger/constants.rb +90 -90
- data/lib/phusion_passenger/debug_logging.rb +106 -106
- data/lib/phusion_passenger/loader_shared_helpers.rb +447 -432
- data/lib/phusion_passenger/message_channel.rb +312 -312
- data/lib/phusion_passenger/message_client.rb +176 -176
- data/lib/phusion_passenger/native_support.rb +369 -369
- data/lib/phusion_passenger/nginx/config_options.rb +297 -297
- data/lib/phusion_passenger/packaging.rb +131 -131
- data/lib/phusion_passenger/platform_info.rb +360 -360
- data/lib/phusion_passenger/platform_info/apache.rb +767 -767
- data/lib/phusion_passenger/platform_info/apache_detector.rb +199 -199
- data/lib/phusion_passenger/platform_info/binary_compatibility.rb +107 -107
- data/lib/phusion_passenger/platform_info/compiler.rb +570 -570
- data/lib/phusion_passenger/platform_info/curl.rb +32 -32
- data/lib/phusion_passenger/platform_info/cxx_portability.rb +188 -188
- data/lib/phusion_passenger/platform_info/depcheck.rb +372 -372
- data/lib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +109 -109
- data/lib/phusion_passenger/platform_info/depcheck_specs/compiler_toolchain.rb +4 -4
- data/lib/phusion_passenger/platform_info/depcheck_specs/gems.rb +10 -34
- data/lib/phusion_passenger/platform_info/depcheck_specs/libs.rb +101 -101
- data/lib/phusion_passenger/platform_info/depcheck_specs/ruby.rb +5 -5
- data/lib/phusion_passenger/platform_info/depcheck_specs/utilities.rb +13 -13
- data/lib/phusion_passenger/platform_info/linux.rb +55 -55
- data/lib/phusion_passenger/platform_info/operating_system.rb +149 -149
- data/lib/phusion_passenger/platform_info/ruby.rb +468 -448
- data/lib/phusion_passenger/platform_info/zlib.rb +9 -9
- data/lib/phusion_passenger/plugin.rb +66 -66
- data/lib/phusion_passenger/preloader_shared_helpers.rb +126 -126
- data/lib/phusion_passenger/public_api.rb +191 -191
- data/lib/phusion_passenger/rack/out_of_band_gc.rb +93 -94
- data/lib/phusion_passenger/rack/thread_handler_extension.rb +231 -227
- data/lib/phusion_passenger/request_handler.rb +567 -577
- data/lib/phusion_passenger/request_handler/thread_handler.rb +379 -381
- data/lib/phusion_passenger/ruby_core_enhancements.rb +86 -86
- data/lib/phusion_passenger/ruby_core_io_enhancements.rb +74 -74
- data/lib/phusion_passenger/simple_benchmarking.rb +25 -25
- data/lib/phusion_passenger/standalone/app_finder.rb +153 -150
- data/lib/phusion_passenger/standalone/command.rb +44 -40
- data/lib/phusion_passenger/standalone/config_utils.rb +53 -53
- data/lib/phusion_passenger/standalone/control_utils.rb +38 -59
- data/lib/phusion_passenger/standalone/main.rb +73 -73
- data/lib/phusion_passenger/standalone/start_command.rb +697 -685
- data/lib/phusion_passenger/standalone/start_command/builtin_engine.rb +193 -155
- data/lib/phusion_passenger/standalone/start_command/nginx_engine.rb +162 -133
- data/lib/phusion_passenger/standalone/status_command.rb +64 -64
- data/lib/phusion_passenger/standalone/stop_command.rb +72 -72
- data/lib/phusion_passenger/standalone/version_command.rb +9 -9
- data/lib/phusion_passenger/union_station/connection.rb +32 -32
- data/lib/phusion_passenger/union_station/core.rb +251 -251
- data/lib/phusion_passenger/union_station/transaction.rb +126 -126
- data/lib/phusion_passenger/utils.rb +199 -167
- data/lib/phusion_passenger/utils/ansi_colors.rb +128 -128
- data/lib/phusion_passenger/utils/download.rb +196 -196
- data/lib/phusion_passenger/utils/file_system_watcher.rb +158 -158
- data/lib/phusion_passenger/utils/hosts_file_parser.rb +101 -101
- data/lib/phusion_passenger/utils/lock.rb +31 -31
- data/lib/phusion_passenger/utils/native_support_utils.rb +31 -31
- data/lib/phusion_passenger/utils/progress_bar.rb +26 -26
- data/lib/phusion_passenger/utils/shellwords.rb +20 -20
- data/lib/phusion_passenger/utils/terminal_choice_menu.rb +206 -206
- data/lib/phusion_passenger/utils/unseekable_socket.rb +272 -272
- data/lib/phusion_passenger/vendor/crash_watch/app.rb +129 -0
- data/lib/phusion_passenger/vendor/crash_watch/gdb_controller.rb +341 -0
- data/lib/phusion_passenger/vendor/crash_watch/version.rb +24 -0
- data/lib/phusion_passenger/vendor/daemon_controller.rb +877 -0
- data/lib/phusion_passenger/vendor/daemon_controller/lock_file.rb +127 -0
- data/lib/phusion_passenger/vendor/daemon_controller/spawn.rb +26 -0
- data/lib/phusion_passenger/vendor/daemon_controller/version.rb +29 -0
- data/packaging/rpm/passenger_spec/passenger.spec.template +0 -1
- data/passenger.gemspec +0 -1
- data/resources/templates/config/nginx_engine_compiler/possible_solutions_for_download_and_extraction_problems.txt.erb +27 -0
- data/resources/templates/standalone/config.erb +19 -15
- data/test/integration_tests/apache2_tests.rb +566 -566
- data/test/integration_tests/downloaded_binaries_tests.rb +126 -125
- data/test/integration_tests/native_packaging_spec.rb +296 -296
- data/test/integration_tests/nginx_tests.rb +393 -393
- data/test/integration_tests/shared/example_webapp_tests.rb +282 -280
- data/test/integration_tests/source_packaging_test.rb +138 -138
- data/test/integration_tests/spec_helper.rb +5 -5
- data/test/integration_tests/standalone_tests.rb +367 -367
- data/test/ruby/debug_logging_spec.rb +133 -133
- data/test/ruby/message_channel_spec.rb +186 -186
- data/test/ruby/rack/loader_spec.rb +28 -28
- data/test/ruby/rack/preloader_spec.rb +34 -34
- data/test/ruby/rails3.0/loader_spec.rb +12 -12
- data/test/ruby/rails3.0/preloader_spec.rb +18 -18
- data/test/ruby/rails3.1/loader_spec.rb +12 -12
- data/test/ruby/rails3.1/preloader_spec.rb +18 -18
- data/test/ruby/rails3.2/loader_spec.rb +12 -12
- data/test/ruby/rails3.2/preloader_spec.rb +18 -18
- data/test/ruby/rails4.0/loader_spec.rb +12 -12
- data/test/ruby/rails4.0/preloader_spec.rb +18 -18
- data/test/ruby/rails4.1/loader_spec.rb +12 -12
- data/test/ruby/rails4.1/preloader_spec.rb +18 -18
- data/test/ruby/request_handler_spec.rb +730 -730
- data/test/ruby/shared/loader_sharedspec.rb +224 -224
- data/test/ruby/shared/rails/union_station_extensions_sharedspec.rb +327 -327
- data/test/ruby/shared/ruby_loader_sharedspec.rb +47 -47
- data/test/ruby/spec_helper.rb +65 -65
- data/test/ruby/standalone/runtime_installer_spec.rb +384 -384
- data/test/ruby/union_station_spec.rb +276 -276
- data/test/ruby/utils/file_system_watcher_spec.rb +220 -220
- data/test/ruby/utils/hosts_file_parser.rb +248 -248
- data/test/ruby/utils/tee_input_spec.rb +215 -215
- data/test/ruby/utils/unseekable_socket_spec.rb +57 -57
- data/test/ruby/utils_spec.rb +21 -21
- data/test/stub/rack/config.ru +87 -87
- data/test/stub/rack/library.rb +8 -8
- data/test/stub/rack/start.rb +30 -30
- data/test/support/apache2_controller.rb +191 -191
- data/test/support/nginx_controller.rb +90 -99
- data/test/support/placebo-preloader.rb +57 -57
- data/test/support/test_helper.rb +435 -435
- metadata +11 -21
- metadata.gz.asc +7 -7
- data/lib/phusion_passenger/standalone/command2.rb +0 -292
- data/lib/phusion_passenger/standalone/start2_command.rb +0 -799
- data/resources/templates/standalone/download_tool_missing.txt.erb +0 -18
- data/resources/templates/standalone/possible_solutions_for_download_and_extraction_problems.txt.erb +0 -17
- data/resources/templates/standalone/run_installer_as_root.txt.erb +0 -8
data/build/nginx.rb
CHANGED
@@ -22,45 +22,45 @@
|
|
22
22
|
# THE SOFTWARE.
|
23
23
|
|
24
24
|
auto_generated_sources = [
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
30
|
]
|
31
31
|
|
32
32
|
desc "Build Nginx support files"
|
33
33
|
task :nginx => [
|
34
|
-
|
35
|
-
|
34
|
+
:nginx_without_native_support,
|
35
|
+
NATIVE_SUPPORT_TARGET
|
36
36
|
].compact
|
37
37
|
|
38
38
|
# Workaround for https://github.com/jimweirich/rake/issues/274
|
39
39
|
task :_nginx => :nginx
|
40
40
|
|
41
41
|
task :nginx_without_native_support => [
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
auto_generated_sources,
|
43
|
+
AGENT_OUTPUT_DIR + AGENT_EXE,
|
44
|
+
COMMON_LIBRARY.only(*NGINX_LIBS_SELECTOR).link_objects
|
45
45
|
].flatten
|
46
46
|
|
47
47
|
task :clean => 'nginx:clean'
|
48
48
|
desc "Clean all compiled Nginx files"
|
49
49
|
task 'nginx:clean' => 'common:clean' do
|
50
|
-
|
50
|
+
# Nothing to clean at this time.
|
51
51
|
end
|
52
52
|
|
53
53
|
def create_nginx_auto_generated_source_task(source)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
62
|
end
|
63
63
|
|
64
64
|
auto_generated_sources.each do |source|
|
65
|
-
|
65
|
+
create_nginx_auto_generated_source_task(source)
|
66
66
|
end
|
data/build/node_tests.rb
CHANGED
@@ -25,11 +25,11 @@
|
|
25
25
|
|
26
26
|
desc "Run unit tests for the Node.js libraries"
|
27
27
|
task 'test:node' do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
require 'shellwords'
|
29
|
+
command = "cd test && env NODE_PATH=#{PhusionPassenger.node_libdir} " +
|
30
|
+
"../node_modules/.bin/mocha -R spec node/*_spec.js"
|
31
|
+
if grep = string_option('G')
|
32
|
+
command << " -g #{Shellwords.escape(grep)}"
|
33
|
+
end
|
34
|
+
sh(command)
|
35
35
|
end
|
data/build/oxt_tests.rb
CHANGED
@@ -27,33 +27,33 @@ TEST_OXT_CFLAGS = "#{EXTRA_PRE_CXXFLAGS} -Iext -Itest/support #{TEST_COMMON_CFLA
|
|
27
27
|
TEST_OXT_LDFLAGS = "#{TEST_BOOST_OXT_LIBRARY} #{PlatformInfo.portability_cxx_ldflags} #{EXTRA_CXX_LDFLAGS}"
|
28
28
|
TEST_OXT_LDFLAGS << " #{PlatformInfo.adress_sanitizer_flag}" if USE_ASAN
|
29
29
|
TEST_OXT_OBJECTS = {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
'oxt_test_main.o' => %w(oxt_test_main.cpp),
|
31
|
+
'backtrace_test.o' => %w(backtrace_test.cpp counter.hpp),
|
32
|
+
'spin_lock_test.o' => %w(spin_lock_test.cpp),
|
33
|
+
'dynamic_thread_group_test.o' => %w(dynamic_thread_group_test.cpp counter.hpp),
|
34
|
+
'syscall_interruption_test.o' => %w(syscall_interruption_test.cpp)
|
35
35
|
}
|
36
36
|
|
37
37
|
desc "Run unit tests for the OXT library"
|
38
38
|
task 'test:oxt' => 'test/oxt/oxt_test_main' do
|
39
|
-
|
39
|
+
sh "cd test && ./oxt/oxt_test_main"
|
40
40
|
end
|
41
41
|
|
42
42
|
# Define task for test/oxt/oxt_test_main.
|
43
43
|
oxt_test_main_dependencies = TEST_OXT_OBJECTS.keys.map do |object|
|
44
|
-
|
44
|
+
"test/oxt/#{object}"
|
45
45
|
end
|
46
46
|
oxt_test_main_dependencies << TEST_BOOST_OXT_LIBRARY
|
47
47
|
file 'test/oxt/oxt_test_main' => oxt_test_main_dependencies do
|
48
|
-
|
49
|
-
|
48
|
+
objects = TEST_OXT_OBJECTS.keys.map{ |x| "test/oxt/#{x}" }.join(' ')
|
49
|
+
create_executable("test/oxt/oxt_test_main", objects, TEST_OXT_LDFLAGS)
|
50
50
|
end
|
51
51
|
|
52
52
|
# Define tasks for each OXT test source file.
|
53
53
|
TEST_OXT_OBJECTS.each_pair do |target, sources|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
file "test/oxt/#{target}" => sources.map{ |x| "test/oxt/#{x}" } do
|
55
|
+
source = "test/oxt/#{sources[0]}"
|
56
|
+
object = source.sub(/\.cpp$/, '.o')
|
57
|
+
compile_cxx source, "#{TEST_OXT_CFLAGS} -o #{object}"
|
58
|
+
end
|
59
59
|
end
|
data/build/packaging.rb
CHANGED
@@ -24,637 +24,637 @@
|
|
24
24
|
ORIG_TARBALL_FILES = lambda { PhusionPassenger::Packaging.files }
|
25
25
|
|
26
26
|
def recursive_copy_files(files, destination_dir, preprocess = false, variables = {})
|
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
|
-
|
27
|
+
require 'fileutils' if !defined?(FileUtils)
|
28
|
+
if !STDOUT.tty?
|
29
|
+
puts "Copying files..."
|
30
|
+
end
|
31
|
+
files.each_with_index do |filename, i|
|
32
|
+
dir = File.dirname(filename)
|
33
|
+
if !File.exist?("#{destination_dir}/#{dir}")
|
34
|
+
FileUtils.mkdir_p("#{destination_dir}/#{dir}")
|
35
|
+
end
|
36
|
+
if !File.directory?(filename)
|
37
|
+
if preprocess && filename =~ /\.template$/
|
38
|
+
real_filename = filename.sub(/\.template$/, '')
|
39
|
+
FileUtils.install(filename, "#{destination_dir}/#{real_filename}", :preserve => true)
|
40
|
+
Preprocessor.new.start(filename, "#{destination_dir}/#{real_filename}",
|
41
|
+
variables)
|
42
|
+
else
|
43
|
+
FileUtils.install(filename, "#{destination_dir}/#{filename}", :preserve => true)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
if STDOUT.tty?
|
47
|
+
printf "\r[%5d/%5d] [%3.0f%%] Copying files...", i + 1, files.size, i * 100.0 / files.size
|
48
|
+
STDOUT.flush
|
49
|
+
end
|
50
|
+
end
|
51
|
+
if STDOUT.tty?
|
52
|
+
printf "\r[%5d/%5d] [%3.0f%%] Copying files...\n", files.size, files.size, 100
|
53
|
+
end
|
54
54
|
end
|
55
55
|
|
56
56
|
def word_wrap(text, max = 72)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
57
|
+
while index = (lines = text.split("\n")).find_index{ |line| line.size > max }
|
58
|
+
line = lines[index]
|
59
|
+
pos = max
|
60
|
+
while pos >= 0 && line[pos..pos] != " "
|
61
|
+
pos -= 1
|
62
|
+
end
|
63
|
+
if pos < 0
|
64
|
+
raise "Cannot wrap line: #{line}"
|
65
|
+
else
|
66
|
+
lines[index] = line[0 .. pos - 1]
|
67
|
+
lines.insert(index + 1, line[pos + 1 .. -1])
|
68
|
+
text = lines.join("\n")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
return text
|
72
72
|
end
|
73
73
|
|
74
74
|
def is_open_source?
|
75
|
-
|
75
|
+
return !is_enterprise?
|
76
76
|
end
|
77
77
|
|
78
78
|
def is_enterprise?
|
79
|
-
|
79
|
+
return PACKAGE_NAME =~ /enterprise/
|
80
80
|
end
|
81
81
|
|
82
82
|
def enterprise_git_url
|
83
|
-
|
83
|
+
return "TODO"
|
84
84
|
end
|
85
85
|
|
86
86
|
def git_tag_prefix
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
if is_open_source?
|
88
|
+
return "release"
|
89
|
+
else
|
90
|
+
return "enterprise"
|
91
|
+
end
|
92
92
|
end
|
93
93
|
|
94
94
|
def git_tag
|
95
|
-
|
95
|
+
return "#{git_tag_prefix}-#{VERSION_STRING}"
|
96
96
|
end
|
97
97
|
|
98
98
|
def homebrew_dir
|
99
|
-
|
99
|
+
return "/tmp/homebrew"
|
100
100
|
end
|
101
101
|
|
102
102
|
|
103
103
|
task :clobber => 'package:clean'
|
104
104
|
|
105
105
|
task 'package:set_official' do
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
ENV['OFFICIAL_RELEASE'] = '1'
|
107
|
+
# These environment variables interfere with 'brew install'
|
108
|
+
# and maybe other stuff, so unset them.
|
109
|
+
ENV.delete('CC')
|
110
|
+
ENV.delete('CXX')
|
111
|
+
ENV.delete('USE_CCACHE')
|
112
112
|
end
|
113
113
|
|
114
114
|
desc "Build, sign & upload gem & tarball"
|
115
115
|
task 'package:release' => ['package:set_official', 'package:gem', 'package:tarball', 'package:sign'] do
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
116
|
+
PhusionPassenger.require_passenger_lib 'platform_info'
|
117
|
+
require 'yaml'
|
118
|
+
require 'uri'
|
119
|
+
require 'net/http'
|
120
|
+
require 'net/https'
|
121
|
+
basename = "#{PhusionPassenger::PACKAGE_NAME}-#{PhusionPassenger::VERSION_STRING}"
|
122
|
+
version = PhusionPassenger::VERSION_STRING
|
123
|
+
is_beta = !!version.split('.')[3]
|
124
|
+
|
125
|
+
if !`git status --porcelain | grep -Ev '^\\?\\? '`.empty?
|
126
|
+
STDERR.puts "-------------------"
|
127
|
+
abort "*** ERROR: There are uncommitted files. See 'git status'"
|
128
|
+
end
|
129
|
+
|
130
|
+
begin
|
131
|
+
website_config = YAML.load_file(File.expand_path("~/.passenger_website.yml"))
|
132
|
+
rescue Errno::ENOENT
|
133
|
+
STDERR.puts "-------------------"
|
134
|
+
abort "*** ERROR: Please put the Phusion Passenger website admin " +
|
135
|
+
"password in ~/.passenger_website.yml:\n" +
|
136
|
+
"admin_password: ..."
|
137
|
+
end
|
138
|
+
|
139
|
+
if !PhusionPassenger::PlatformInfo.find_command("hub")
|
140
|
+
STDERR.puts "-------------------"
|
141
|
+
abort "*** ERROR: Please 'brew install hub' first"
|
142
|
+
end
|
143
|
+
|
144
|
+
if is_open_source?
|
145
|
+
if boolean_option('HOMEBREW_UPDATE', true) && !is_beta
|
146
|
+
puts "Updating Homebrew formula..."
|
147
|
+
Rake::Task['package:update_homebrew'].invoke
|
148
|
+
else
|
149
|
+
puts "HOMEBREW_UPDATE set to false, not updating Homebrew formula."
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
sh "git tag -s #{git_tag} -u 0A212A8C -m 'Release #{version}'"
|
154
|
+
|
155
|
+
puts "Proceed with pushing tag to remote Git repo and uploading the gem and signatures? [y/n]"
|
156
|
+
if STDIN.readline == "y\n"
|
157
|
+
sh "git push origin #{git_tag}"
|
158
|
+
|
159
|
+
if is_open_source?
|
160
|
+
sh "s3cmd -P put #{PKG_DIR}/passenger-#{version}.{gem,tar.gz,gem.asc,tar.gz.asc} s3://phusion-passenger/releases/"
|
161
|
+
sh "gem push #{PKG_DIR}/passenger-#{version}.gem"
|
162
|
+
|
163
|
+
puts "Updating version number on website..."
|
164
|
+
if is_beta
|
165
|
+
uri = URI.parse("https://www.phusionpassenger.com/latest_beta_version")
|
166
|
+
else
|
167
|
+
uri = URI.parse("https://www.phusionpassenger.com/latest_stable_version")
|
168
|
+
end
|
169
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
170
|
+
http.use_ssl = true
|
171
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
172
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
173
|
+
request.basic_auth("admin", website_config["admin_password"])
|
174
|
+
request.set_form_data("version" => version)
|
175
|
+
response = http.request(request)
|
176
|
+
if response.code != 200 && response.body != "ok"
|
177
|
+
abort "*** ERROR: Cannot update version number on www.phusionpassenger.com:\n" +
|
178
|
+
"Status: #{response.code}\n\n" +
|
179
|
+
response.body
|
180
|
+
end
|
181
|
+
|
182
|
+
puts "Initiating building of binaries"
|
183
|
+
Rake::Task['package:initiate_binaries_building'].invoke
|
184
|
+
|
185
|
+
if !is_beta
|
186
|
+
puts "Initiating building of Debian packages"
|
187
|
+
Rake::Task['package:initiate_debian_building'].invoke
|
188
|
+
end
|
189
|
+
|
190
|
+
puts "Building OS X binaries..."
|
191
|
+
Rake::Task['package:build_osx_binaries'].invoke
|
192
|
+
|
193
|
+
if !is_beta && boolean_option('HOMEBREW_UPDATE', true)
|
194
|
+
if boolean_option('HOMEBREW_DRY_RUN', false)
|
195
|
+
puts "HOMEBREW_DRY_RUN set, not submitting pull request. Please find the repo in /tmp/homebrew."
|
196
|
+
else
|
197
|
+
puts "Submitting Homebrew pull request..."
|
198
|
+
sh "cd #{homebrew_dir} && hub pull-request 'Update passenger to version #{version}' -b Homebrew:master"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
puts "--------------"
|
203
|
+
puts "All done."
|
204
|
+
else
|
205
|
+
dir = "/u/apps/passenger_website/shared"
|
206
|
+
subdir = string_option('NAME', version)
|
207
|
+
|
208
|
+
sh "scp #{PKG_DIR}/#{basename}.{gem,tar.gz,gem.asc,tar.gz.asc} app@shell.phusion.nl:#{dir}/"
|
209
|
+
sh "ssh app@shell.phusion.nl 'mkdir -p \"#{dir}/assets/#{subdir}\" && mv #{dir}/#{basename}.{gem,tar.gz,gem.asc,tar.gz.asc} \"#{dir}/assets/#{subdir}/\"'"
|
210
|
+
command = "curl -F file=@#{PKG_DIR}/#{basename}.gem --user admin:'#{website_config['admin_password']}' " +
|
211
|
+
"--output /dev/stderr --write-out '%{http_code}' --silent " +
|
212
|
+
"https://www.phusionpassenger.com/enterprise_gems/upload"
|
213
|
+
puts command
|
214
|
+
result = `#{command}`
|
215
|
+
if result != "200"
|
216
|
+
abort "Gem upload failed. HTTP status code: #{result.inspect}"
|
217
|
+
else
|
218
|
+
# The response body does not contain a newline,
|
219
|
+
# so fix terminal output.
|
220
|
+
puts
|
221
|
+
end
|
222
|
+
|
223
|
+
puts "Initiating building of binaries"
|
224
|
+
Rake::Task['package:initiate_binaries_building'].invoke
|
225
|
+
|
226
|
+
if !is_beta
|
227
|
+
puts "Initiating building of Debian packages"
|
228
|
+
Rake::Task['package:initiate_debian_building'].invoke
|
229
|
+
end
|
230
|
+
|
231
|
+
puts "Building OS X binaries..."
|
232
|
+
Rake::Task['package:build_osx_binaries'].invoke
|
233
|
+
|
234
|
+
puts "--------------"
|
235
|
+
puts "All done."
|
236
|
+
end
|
237
|
+
else
|
238
|
+
puts "Did not upload anything."
|
239
|
+
end
|
240
240
|
end
|
241
241
|
|
242
242
|
task 'package:gem' => Packaging::PREGENERATED_FILES do
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
243
|
+
require 'phusion_passenger'
|
244
|
+
if ENV['OFFICIAL_RELEASE']
|
245
|
+
release_file = "#{PhusionPassenger.resources_dir}/release.txt"
|
246
|
+
File.unlink(release_file) rescue nil
|
247
|
+
end
|
248
|
+
begin
|
249
|
+
if release_file
|
250
|
+
File.open(release_file, "w").close
|
251
|
+
end
|
252
|
+
command = "gem build #{PhusionPassenger::PACKAGE_NAME}.gemspec"
|
253
|
+
if !boolean_option('SKIP_SIGNING')
|
254
|
+
command << " --sign --key 0x0A212A8C"
|
255
|
+
end
|
256
|
+
sh(command)
|
257
|
+
ensure
|
258
|
+
if release_file
|
259
|
+
File.unlink(release_file) rescue nil
|
260
|
+
end
|
261
|
+
end
|
262
|
+
sh "mkdir -p #{PKG_DIR}"
|
263
|
+
sh "mv #{PhusionPassenger::PACKAGE_NAME}-#{PhusionPassenger::VERSION_STRING}.gem #{PKG_DIR}/"
|
264
264
|
end
|
265
265
|
|
266
266
|
task 'package:tarball' => Packaging::PREGENERATED_FILES do
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
267
|
+
require 'phusion_passenger'
|
268
|
+
require 'fileutils'
|
269
|
+
|
270
|
+
basename = "#{PhusionPassenger::PACKAGE_NAME}-#{PhusionPassenger::VERSION_STRING}"
|
271
|
+
sh "rm -rf #{PKG_DIR}/#{basename}"
|
272
|
+
sh "mkdir -p #{PKG_DIR}/#{basename}"
|
273
|
+
recursive_copy_files(ORIG_TARBALL_FILES.call, "#{PKG_DIR}/#{basename}")
|
274
|
+
if ENV['OFFICIAL_RELEASE']
|
275
|
+
File.open("#{PKG_DIR}/#{basename}/resources/release.txt", "w").close
|
276
|
+
end
|
277
|
+
if PlatformInfo.os_name == "macosx"
|
278
|
+
sh "cd #{PKG_DIR}/#{basename} && find . -print0 | xargs -0 touch -t '201310270000'"
|
279
|
+
else
|
280
|
+
sh "cd #{PKG_DIR}/#{basename} && find . -print0 | xargs -0 touch -d '2013-10-27 00:00:00 UTC'"
|
281
|
+
end
|
282
|
+
sh "cd #{PKG_DIR} && tar -c #{basename} | gzip --no-name --best > #{basename}.tar.gz"
|
283
|
+
sh "rm -rf #{PKG_DIR}/#{basename}"
|
284
284
|
end
|
285
285
|
|
286
286
|
task 'package:sign' do
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
287
|
+
if File.exist?(File.expand_path("~/.gnupg/gpg-agent.conf")) || ENV['GPG_AGENT_INFO']
|
288
|
+
puts "It looks like you're using gpg-agent, so skipping automatically password caching."
|
289
|
+
else
|
290
|
+
begin
|
291
|
+
require 'highline'
|
292
|
+
rescue LoadError
|
293
|
+
abort "Please run `gem install highline` first."
|
294
|
+
end
|
295
|
+
h = HighLine.new
|
296
|
+
password = h.ask("Password for software-signing@phusion.nl GPG key: ") { |q| q.echo = false }
|
297
|
+
passphrase_opt = "--passphrase-file .gpg-password"
|
298
|
+
end
|
299
|
+
|
300
|
+
begin
|
301
|
+
if password
|
302
|
+
File.open(".gpg-password", "w", 0600) do |f|
|
303
|
+
f.write(password)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
version = PhusionPassenger::VERSION_STRING
|
307
|
+
["passenger-#{version}.gem",
|
308
|
+
"passenger-#{version}.tar.gz",
|
309
|
+
"passenger-enterprise-server-#{version}.gem",
|
310
|
+
"passenger-enterprise-server-#{version}.tar.gz"].each do |name|
|
311
|
+
if File.exist?("pkg/#{name}")
|
312
|
+
sh "gpg --sign --detach-sign #{passphrase_opt} --local-user software-signing@phusion.nl --armor pkg/#{name}"
|
313
|
+
end
|
314
|
+
end
|
315
|
+
ensure
|
316
|
+
File.unlink('.gpg-password') if File.exist?('.gpg-password')
|
317
|
+
end
|
318
318
|
end
|
319
319
|
|
320
320
|
task 'package:update_homebrew' do
|
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
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
321
|
+
require 'digest/sha1'
|
322
|
+
version = VERSION_STRING
|
323
|
+
sha1 = File.open("#{PKG_DIR}/passenger-#{version}.tar.gz", "rb") do |f|
|
324
|
+
Digest::SHA1.hexdigest(f.read)
|
325
|
+
end
|
326
|
+
sh "rm -rf #{homebrew_dir}"
|
327
|
+
sh "git clone git@github.com:phusion/homebrew.git #{homebrew_dir}"
|
328
|
+
sh "cd #{homebrew_dir} && git remote add Homebrew https://github.com/Homebrew/homebrew.git"
|
329
|
+
sh "cd #{homebrew_dir} && git fetch Homebrew"
|
330
|
+
sh "cd #{homebrew_dir} && git reset --hard Homebrew/master"
|
331
|
+
formula = File.read("/tmp/homebrew/Library/Formula/passenger.rb")
|
332
|
+
formula.gsub!(/passenger-.+?\.tar\.gz/, "passenger-#{version}.tar.gz") ||
|
333
|
+
abort("Unable to substitute Homebrew formula tarball filename")
|
334
|
+
formula.gsub!(/^ sha1 .*/, " sha1 '#{sha1}'") ||
|
335
|
+
abort("Unable to substitute Homebrew formula SHA-1")
|
336
|
+
necessary_dirs = ORIG_TARBALL_FILES.call.map{ |filename| filename.split("/").first }.uniq
|
337
|
+
necessary_dirs -= Packaging::HOMEBREW_EXCLUDE
|
338
|
+
necessary_dirs += ["buildout"]
|
339
|
+
necessary_dirs_str = word_wrap(necessary_dirs.inspect).split("\n").join("\n ")
|
340
|
+
formula.sub!(/necessary_files = .*?\]/m, "necessary_files = Dir#{necessary_dirs_str}") ||
|
341
|
+
abort("Unable to substitute file whitelist")
|
342
|
+
File.open("/tmp/homebrew/Library/Formula/passenger.rb", "w") do |f|
|
343
|
+
f.write(formula)
|
344
|
+
end
|
345
|
+
sh "cd #{homebrew_dir} && git commit -a -m 'passenger #{version}'"
|
346
|
+
sh "cd #{homebrew_dir} && git push -f"
|
347
|
+
if boolean_option('HOMEBREW_TEST', true)
|
348
|
+
sh "cp /tmp/homebrew/Library/Formula/passenger.rb /usr/local/Library/Formula/passenger.rb"
|
349
|
+
if `brew info passenger` !~ /^Not installed$/
|
350
|
+
sh "brew uninstall passenger"
|
351
|
+
end
|
352
|
+
sh "cp #{PKG_DIR}/passenger-#{version}.tar.gz `brew --cache`/"
|
353
|
+
sh "brew install passenger"
|
354
|
+
Rake::Task['test:integration:native_packaging'].invoke
|
355
|
+
end
|
356
356
|
end
|
357
357
|
|
358
358
|
task 'package:initiate_binaries_building' do
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
359
|
+
require 'yaml'
|
360
|
+
require 'uri'
|
361
|
+
require 'net/http'
|
362
|
+
require 'net/https'
|
363
|
+
version = VERSION_STRING
|
364
|
+
begin
|
365
|
+
website_config = YAML.load_file(File.expand_path("~/.passenger_website.yml"))
|
366
|
+
rescue Errno::ENOENT
|
367
|
+
STDERR.puts "-------------------"
|
368
|
+
abort "*** ERROR: Please put the Phusion Passenger website admin " +
|
369
|
+
"password in ~/.passenger_website.yml:\n" +
|
370
|
+
"admin_password: ..."
|
371
|
+
end
|
372
|
+
if is_open_source?
|
373
|
+
type = "open%20source"
|
374
|
+
jenkins_token = website_config["jenkins_token"]
|
375
|
+
if !jenkins_token
|
376
|
+
abort "*** ERROR: Please put the Passenger open source Jenkins " +
|
377
|
+
"authentication token in ~/.passenger_website.yml, under " +
|
378
|
+
"the 'jenkins_token' key."
|
379
|
+
end
|
380
|
+
else
|
381
|
+
type = "Enterprise"
|
382
|
+
jenkins_token = website_config["jenkins_enterprise_token"]
|
383
|
+
if !jenkins_token
|
384
|
+
abort "*** ERROR: Please put the Passenger Enterprise Jenkins " +
|
385
|
+
"authentication token in ~/.passenger_website.yml, under " +
|
386
|
+
"the 'jenkins_enterprise_token' key."
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
uri = URI.parse("https://oss-jenkins.phusion.nl/buildByToken/buildWithParameters?" +
|
391
|
+
"job=Passenger%20#{type}%20binaries%20(release)&tag=#{git_tag}")
|
392
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
393
|
+
http.use_ssl = true
|
394
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
395
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
396
|
+
request.set_form_data("token" => jenkins_token)
|
397
|
+
response = http.request(request)
|
398
|
+
if response.code != 200 && response.body != "Scheduled.\n"
|
399
|
+
abort "*** ERROR: Cannot initiate building of binaries:\n" +
|
400
|
+
"Status: #{response.code}\n\n" +
|
401
|
+
response.body
|
402
|
+
end
|
403
|
+
puts "Initiated building of binaries."
|
404
404
|
end
|
405
405
|
|
406
406
|
task 'package:initiate_debian_building' do
|
407
|
-
|
408
|
-
|
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
|
-
|
407
|
+
require 'yaml'
|
408
|
+
require 'uri'
|
409
|
+
require 'net/http'
|
410
|
+
require 'net/https'
|
411
|
+
version = VERSION_STRING
|
412
|
+
begin
|
413
|
+
website_config = YAML.load_file(File.expand_path("~/.passenger_website.yml"))
|
414
|
+
rescue Errno::ENOENT
|
415
|
+
STDERR.puts "-------------------"
|
416
|
+
abort "*** ERROR: Please put the Phusion Passenger website admin " +
|
417
|
+
"password in ~/.passenger_website.yml:\n" +
|
418
|
+
"admin_password: ..."
|
419
|
+
end
|
420
|
+
if is_open_source?
|
421
|
+
type = "open%20source"
|
422
|
+
jenkins_token = website_config["jenkins_token"]
|
423
|
+
if !jenkins_token
|
424
|
+
abort "*** ERROR: Please put the Passenger open source Jenkins " +
|
425
|
+
"authentication token in ~/.passenger_website.yml, under " +
|
426
|
+
"the 'jenkins_token' key."
|
427
|
+
end
|
428
|
+
else
|
429
|
+
type = "Enterprise"
|
430
|
+
jenkins_token = website_config["jenkins_enterprise_token"]
|
431
|
+
if !jenkins_token
|
432
|
+
abort "*** ERROR: Please put the Passenger Enterprise Jenkins " +
|
433
|
+
"authentication token in ~/.passenger_website.yml, under " +
|
434
|
+
"the 'jenkins_enterprise_token' key."
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
uri = URI.parse("https://oss-jenkins.phusion.nl/buildByToken/buildWithParameters?" +
|
439
|
+
"job=Passenger%20#{type}%20Debian%20packages%20(release)&ref=#{git_tag}")
|
440
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
441
|
+
http.use_ssl = true
|
442
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
443
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
444
|
+
request.set_form_data("token" => jenkins_token)
|
445
|
+
response = http.request(request)
|
446
|
+
if response.code != 200 && response.body != "Scheduled.\n"
|
447
|
+
abort "*** ERROR: Cannot initiate building of Debian packages:\n" +
|
448
|
+
"Status: #{response.code}\n\n" +
|
449
|
+
response.body
|
450
|
+
end
|
451
|
+
puts "Initiated building of Debian packages."
|
452
452
|
end
|
453
453
|
|
454
454
|
task 'package:build_osx_binaries' do
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
455
|
+
if is_open_source?
|
456
|
+
sh "cd ../passenger_autobuilder && " +
|
457
|
+
"git pull && " +
|
458
|
+
"./autobuild-osx https://github.com/phusion/passenger.git passenger " +
|
459
|
+
"psg_autobuilder_chroot@juvia-helper.phusion.nl --tag=#{git_tag}"
|
460
|
+
else
|
461
|
+
sh "cd ../passenger_autobuilder && " +
|
462
|
+
"git pull && " +
|
463
|
+
"./autobuild-osx #{enterprise_git_url} passenger-enterprise " +
|
464
|
+
"psg_autobuilder_chroot@juvia-helper.phusion.nl --tag=#{git_tag}"
|
465
|
+
end
|
466
466
|
end
|
467
467
|
|
468
468
|
desc "Remove gem, tarball and signatures"
|
469
469
|
task 'package:clean' do
|
470
|
-
|
471
|
-
|
472
|
-
|
470
|
+
require 'phusion_passenger'
|
471
|
+
basename = "#{PhusionPassenger::PACKAGE_NAME}-#{PhusionPassenger::VERSION_STRING}"
|
472
|
+
sh "rm -f pkg/#{basename}.{gem,gem.asc,tar.gz,tar.gz.asc}"
|
473
473
|
end
|
474
474
|
|
475
475
|
def change_shebang(filename, value)
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
476
|
+
contents = File.open(filename, "r") do |f|
|
477
|
+
f.read
|
478
|
+
end
|
479
|
+
contents.gsub!(/\A#\!.+$/, "#!#{value}")
|
480
|
+
File.open(filename, "w") do |f|
|
481
|
+
f.write(contents)
|
482
|
+
end
|
483
483
|
end
|
484
484
|
|
485
485
|
desc "Create a fakeroot, useful for building native packages"
|
486
486
|
task :fakeroot => [:apache2, :nginx, :doc] do
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
487
|
+
require 'rbconfig'
|
488
|
+
require 'fileutils'
|
489
|
+
include RbConfig
|
490
|
+
|
491
|
+
fs_prefix = ENV['FS_PREFIX'] || "/usr"
|
492
|
+
fs_bindir = ENV['FS_BINDIR'] || "#{fs_prefix}/bin"
|
493
|
+
fs_sbindir = ENV['FS_SBINDIR'] || "#{fs_prefix}/sbin"
|
494
|
+
fs_datadir = ENV['FS_DATADIR'] || "#{fs_prefix}/share"
|
495
|
+
fs_docdir = ENV['FS_DOCDIR'] || "#{fs_datadir}/doc"
|
496
|
+
fs_libdir = ENV['FS_LIBDIR'] || "#{fs_prefix}/lib"
|
497
|
+
|
498
|
+
# We don't use CONFIG['archdir'] and the like because we want
|
499
|
+
# the files to be installed to /usr, and the Ruby interpreter
|
500
|
+
# on the packaging machine might be in /usr/local.
|
501
|
+
psg_rubylibdir = ENV['RUBYLIBDIR'] || "#{fs_libdir}/ruby/vendor_ruby"
|
502
|
+
psg_nodelibdir = "#{fs_datadir}/#{GLOBAL_NAMESPACE_DIRNAME}/node"
|
503
|
+
psg_libdir = "#{fs_libdir}/#{GLOBAL_NAMESPACE_DIRNAME}"
|
504
|
+
psg_native_support_dir = ENV["RUBYARCHDIR"] || "#{fs_libdir}/ruby/#{CONFIG['ruby_version']}/#{CONFIG['arch']}"
|
505
|
+
psg_support_binaries_dir = "#{fs_libdir}/#{GLOBAL_NAMESPACE_DIRNAME}/support-binaries"
|
506
|
+
psg_helper_scripts_dir = "#{fs_datadir}/#{GLOBAL_NAMESPACE_DIRNAME}/helper-scripts"
|
507
|
+
psg_resources_dir = "#{fs_datadir}/#{GLOBAL_NAMESPACE_DIRNAME}"
|
508
|
+
psg_include_dir = "#{fs_datadir}/#{GLOBAL_NAMESPACE_DIRNAME}/include"
|
509
|
+
psg_docdir = "#{fs_docdir}/#{GLOBAL_NAMESPACE_DIRNAME}"
|
510
|
+
psg_bindir = "#{fs_bindir}"
|
511
|
+
psg_sbindir = "#{fs_sbindir}"
|
512
|
+
psg_apache2_module_path = ENV['APACHE2_MODULE_PATH'] || "#{fs_libdir}/apache2/modules/mod_passenger.so"
|
513
|
+
psg_ruby_extension_source_dir = "#{fs_datadir}/#{GLOBAL_NAMESPACE_DIRNAME}/ruby_extension_source"
|
514
|
+
psg_nginx_module_source_dir = "#{fs_datadir}/#{GLOBAL_NAMESPACE_DIRNAME}/ngx_http_passenger_module"
|
515
|
+
|
516
|
+
fakeroot = "pkg/fakeroot"
|
517
|
+
fake_rubylibdir = "#{fakeroot}#{psg_rubylibdir}"
|
518
|
+
fake_nodelibdir = "#{fakeroot}#{psg_nodelibdir}"
|
519
|
+
fake_libdir = "#{fakeroot}#{psg_libdir}"
|
520
|
+
fake_native_support_dir = "#{fakeroot}#{psg_native_support_dir}"
|
521
|
+
fake_support_binaries_dir = "#{fakeroot}#{psg_support_binaries_dir}"
|
522
|
+
fake_helper_scripts_dir = "#{fakeroot}#{psg_helper_scripts_dir}"
|
523
|
+
fake_resources_dir = "#{fakeroot}#{psg_resources_dir}"
|
524
|
+
fake_include_dir = "#{fakeroot}#{psg_include_dir}"
|
525
|
+
fake_docdir = "#{fakeroot}#{psg_docdir}"
|
526
|
+
fake_bindir = "#{fakeroot}#{psg_bindir}"
|
527
|
+
fake_sbindir = "#{fakeroot}#{psg_sbindir}"
|
528
|
+
fake_apache2_module_path = "#{fakeroot}#{psg_apache2_module_path}"
|
529
|
+
fake_ruby_extension_source_dir = "#{fakeroot}#{psg_ruby_extension_source_dir}"
|
530
|
+
fake_nginx_module_source_dir = "#{fakeroot}#{psg_nginx_module_source_dir}"
|
531
|
+
|
532
|
+
packaging_method = ENV['NATIVE_PACKAGING_METHOD'] || ENV['PACKAGING_METHOD'] || "deb"
|
533
|
+
|
534
|
+
sh "rm -rf #{fakeroot}"
|
535
|
+
sh "mkdir -p #{fakeroot}"
|
536
|
+
|
537
|
+
# Ruby sources
|
538
|
+
sh "mkdir -p #{fake_rubylibdir}"
|
539
|
+
sh "cp #{PhusionPassenger.ruby_libdir}/phusion_passenger.rb #{fake_rubylibdir}/"
|
540
|
+
sh "cp -R #{PhusionPassenger.ruby_libdir}/phusion_passenger #{fake_rubylibdir}/"
|
541
|
+
|
542
|
+
# Node.js sources
|
543
|
+
sh "mkdir -p #{fake_nodelibdir}"
|
544
|
+
sh "cp -R #{PhusionPassenger.node_libdir}/phusion_passenger #{fake_nodelibdir}/"
|
545
|
+
|
546
|
+
# Phusion Passenger common libraries
|
547
|
+
sh "mkdir -p #{fake_libdir}"
|
548
|
+
sh "cp -R #{PhusionPassenger.lib_dir}/common #{fake_libdir}/"
|
549
|
+
sh "rm -rf #{fake_libdir}/common/libboost_oxt"
|
550
|
+
|
551
|
+
# Ruby extension binaries
|
552
|
+
sh "mkdir -p #{fake_native_support_dir}"
|
553
|
+
native_support_archdir = PlatformInfo.ruby_extension_binary_compatibility_id
|
554
|
+
sh "mkdir -p #{fake_native_support_dir}"
|
555
|
+
sh "cp -R buildout/ruby/#{native_support_archdir}/*.#{LIBEXT} #{fake_native_support_dir}/"
|
556
|
+
|
557
|
+
# Support binaries
|
558
|
+
sh "mkdir -p #{fake_support_binaries_dir}"
|
559
|
+
sh "cp -R #{PhusionPassenger.support_binaries_dir}/* #{fake_support_binaries_dir}/"
|
560
|
+
sh "rm -rf #{fake_support_binaries_dir}/*.dSYM"
|
561
|
+
sh "rm -rf #{fake_support_binaries_dir}/*/*.dSYM"
|
562
|
+
sh "rm -rf #{fake_support_binaries_dir}/*.o"
|
563
|
+
|
564
|
+
# Helper scripts
|
565
|
+
sh "mkdir -p #{fake_helper_scripts_dir}"
|
566
|
+
sh "cp -R #{PhusionPassenger.helper_scripts_dir}/* #{fake_helper_scripts_dir}/"
|
567
|
+
|
568
|
+
# Resources
|
569
|
+
sh "mkdir -p #{fake_resources_dir}"
|
570
|
+
sh "cp -R resources/* #{fake_resources_dir}/"
|
571
|
+
|
572
|
+
# Headers necessary for building the Nginx module
|
573
|
+
sh "mkdir -p #{fake_include_dir}"
|
574
|
+
# Infer headers that the Nginx module needs
|
575
|
+
headers = []
|
576
|
+
Dir["ext/nginx/*.[ch]"].each do |filename|
|
577
|
+
File.read(filename).split("\n").grep(%r{#include "common/(.+)"}) do |match|
|
578
|
+
headers << ["ext/common/#{$1}", "common/#{$1}"]
|
579
|
+
end
|
580
|
+
end
|
581
|
+
# Manually add headers that could not be inferred through
|
582
|
+
# the above code
|
583
|
+
headers.concat([
|
584
|
+
["ext/common/Exceptions.h", "common/Exceptions.h"],
|
585
|
+
["ext/common/Utils/modp_b64.h", "common/Utils/modp_b64.h"],
|
586
|
+
["ext/common/Utils/modp_b64_data.h", "common/Utils/modp_b64_data.h"],
|
587
|
+
["ext/boost/detail/endian.hpp", "boost/detail/endian.hpp"]
|
588
|
+
])
|
589
|
+
headers.each do |header|
|
590
|
+
target = "#{fake_include_dir}/#{header[1]}"
|
591
|
+
dir = File.dirname(target)
|
592
|
+
if !File.directory?(dir)
|
593
|
+
sh "mkdir -p #{dir}"
|
594
|
+
end
|
595
|
+
sh "cp #{header[0]} #{target}"
|
596
|
+
end
|
597
|
+
|
598
|
+
# Nginx module sources
|
599
|
+
sh "mkdir -p #{fake_nginx_module_source_dir}"
|
600
|
+
sh "cp ext/nginx/* #{fake_nginx_module_source_dir}/"
|
601
|
+
|
602
|
+
# Documentation
|
603
|
+
sh "mkdir -p #{fake_docdir}"
|
604
|
+
sh "cp doc/*.html #{fake_docdir}/"
|
605
|
+
sh "cp -R doc/images #{fake_docdir}/"
|
606
|
+
|
607
|
+
# User binaries
|
608
|
+
sh "mkdir -p #{fake_bindir}"
|
609
|
+
Packaging::USER_EXECUTABLES.each do |exe|
|
610
|
+
sh "cp bin/#{exe} #{fake_bindir}/"
|
611
|
+
if !Packaging::EXECUTABLES_WITH_FREE_RUBY.include?(exe)
|
612
|
+
change_shebang("#{fake_bindir}/#{exe}", "#{fs_bindir}/ruby")
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
# Superuser binaries
|
617
|
+
sh "mkdir -p #{fake_sbindir}"
|
618
|
+
Packaging::SUPER_USER_EXECUTABLES.each do |exe|
|
619
|
+
sh "cp bin/#{exe} #{fake_sbindir}/"
|
620
|
+
if !Packaging::EXECUTABLES_WITH_FREE_RUBY.include?(exe)
|
621
|
+
change_shebang("#{fake_sbindir}/#{exe}", "#{fs_bindir}/ruby")
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
625
|
+
# Apache 2 module
|
626
|
+
sh "mkdir -p #{File.dirname(fake_apache2_module_path)}"
|
627
|
+
sh "cp #{APACHE2_MODULE} #{fake_apache2_module_path}"
|
628
|
+
|
629
|
+
# Ruby extension sources
|
630
|
+
sh "mkdir -p #{fake_ruby_extension_source_dir}"
|
631
|
+
sh "cp -R #{PhusionPassenger.ruby_extension_source_dir}/* #{fake_ruby_extension_source_dir}"
|
632
|
+
|
633
|
+
puts "Creating #{fake_rubylibdir}/phusion_passenger/locations.ini"
|
634
|
+
File.open("#{fake_rubylibdir}/phusion_passenger/locations.ini", "w") do |f|
|
635
|
+
f.puts "[locations]"
|
636
|
+
f.puts "packaging_method=#{packaging_method}"
|
637
|
+
f.puts "bin_dir=#{psg_bindir}"
|
638
|
+
f.puts "support_binaries_dir=#{psg_support_binaries_dir}"
|
639
|
+
f.puts "lib_dir=#{psg_libdir}"
|
640
|
+
f.puts "helper_scripts_dir=#{psg_helper_scripts_dir}"
|
641
|
+
f.puts "resources_dir=#{psg_resources_dir}"
|
642
|
+
f.puts "include_dir=#{psg_include_dir}"
|
643
|
+
f.puts "doc_dir=#{psg_docdir}"
|
644
|
+
f.puts "ruby_libdir=#{psg_rubylibdir}"
|
645
|
+
f.puts "node_libdir=#{psg_nodelibdir}"
|
646
|
+
f.puts "apache2_module_path=#{psg_apache2_module_path}"
|
647
|
+
f.puts "ruby_extension_source_dir=#{psg_ruby_extension_source_dir}"
|
648
|
+
f.puts "nginx_module_source_dir=#{psg_nginx_module_source_dir}"
|
649
|
+
end
|
650
|
+
|
651
|
+
# Sanity check the locations.ini file
|
652
|
+
options = PhusionPassenger.parse_ini_file("#{fake_rubylibdir}/phusion_passenger/locations.ini")
|
653
|
+
PhusionPassenger::REQUIRED_LOCATIONS_INI_FIELDS.each do |field|
|
654
|
+
if !options[field.to_s]
|
655
|
+
raise "Bug in build/packaging.rb: the generated locations.ini is missing the '#{field}' field"
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
sh "find #{fakeroot} -name .DS_Store -print0 | xargs -0 rm -f"
|
660
660
|
end
|