144 lines
5.5 KiB
Ruby
144 lines
5.5 KiB
Ruby
class Passenger < Formula
|
|
desc "Server for Ruby, Python, and Node.js apps via Apache/NGINX"
|
|
homepage "https://www.phusionpassenger.com/"
|
|
url "https://github.com/phusion/passenger/releases/download/release-6.0.4/passenger-6.0.4.tar.gz"
|
|
sha256 "ec1e4b555c176642c1c316897177d54b6f7d369490280e8ee3e54644e40b250b"
|
|
revision 3
|
|
head "https://github.com/phusion/passenger.git", :branch => "stable-6.0"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "52e6169eb22468b838a17661c7ed25f56cb7f8c1d143d8604c325ca637a8a066" => :catalina
|
|
sha256 "18063ca49a123ab31ed77826dea3e7708d37d9ea84c5281420f6ffd4b5705a53" => :mojave
|
|
sha256 "68c8208cdcc497d722e70ea772f7001ed777a611bbcfd434705dbd0443c04ae1" => :high_sierra
|
|
end
|
|
|
|
# to build nginx module
|
|
depends_on "nginx" => [:build, :test]
|
|
depends_on "openssl@1.1"
|
|
depends_on "pcre"
|
|
|
|
# Enables setting temp path to avoid sandbox violations, already merged upstream
|
|
patch do
|
|
url "https://github.com/phusion/passenger/commit/e512231f.patch?full_index=1"
|
|
sha256 "9f39f5c1c8b68516f7bac0ba07921144a5de30b6a72ef2423ea83a77d512bea8"
|
|
end
|
|
|
|
def install
|
|
if MacOS.version >= :mojave && MacOS::CLT.installed?
|
|
ENV["SDKROOT"] = MacOS::CLT.sdk_path(MacOS.version)
|
|
else
|
|
ENV.delete("SDKROOT")
|
|
end
|
|
|
|
inreplace "src/ruby_supportlib/phusion_passenger/platform_info/openssl.rb" do |s|
|
|
s.gsub! "-I/usr/local/opt/openssl/include", "-I#{Formula["openssl@1.1"].opt_include}"
|
|
s.gsub! "-L/usr/local/opt/openssl/lib", "-L#{Formula["openssl@1.1"].opt_lib}"
|
|
end
|
|
|
|
system "rake", "apache2"
|
|
system "rake", "nginx"
|
|
nginx_addon_dir = `./bin/passenger-config about nginx-addon-dir`.strip
|
|
|
|
mkdir "nginx" do
|
|
system "tar", "-xf", "#{Formula["nginx"].opt_pkgshare}/src/src.tar.xz", "--strip-components", "1"
|
|
args = (Formula["nginx"].opt_pkgshare/"src/configure_args.txt").read.split("\n")
|
|
args << "--add-dynamic-module=#{nginx_addon_dir}"
|
|
|
|
system "./configure", *args
|
|
system "make"
|
|
(libexec/"modules").install "objs/ngx_http_passenger_module.so"
|
|
end
|
|
|
|
(libexec/"download_cache").mkpath
|
|
|
|
# Fixes https://github.com/phusion/passenger/issues/1288
|
|
rm_rf "buildout/libev"
|
|
rm_rf "buildout/libuv"
|
|
rm_rf "buildout/cache"
|
|
|
|
necessary_files = %w[configure Rakefile README.md CONTRIBUTORS
|
|
CONTRIBUTING.md LICENSE CHANGELOG package.json
|
|
passenger.gemspec build bin doc images dev src
|
|
resources buildout]
|
|
|
|
cp_r necessary_files, libexec, :preserve => true
|
|
|
|
# Allow Homebrew to create symlinks for the Phusion Passenger commands.
|
|
bin.install_symlink Dir["#{libexec}/bin/*"]
|
|
|
|
# Ensure that the Phusion Passenger commands can always find their library
|
|
# files.
|
|
|
|
locations_ini = `./bin/passenger-config --make-locations-ini --for-native-packaging-method=homebrew`
|
|
locations_ini.gsub!(/=#{Regexp.escape Dir.pwd}/, "=#{libexec}")
|
|
(libexec/"src/ruby_supportlib/phusion_passenger/locations.ini").write(locations_ini)
|
|
|
|
ruby_libdir = `./bin/passenger-config about ruby-libdir`.strip
|
|
ruby_libdir.gsub!(/^#{Regexp.escape Dir.pwd}/, libexec)
|
|
system "./dev/install_scripts_bootstrap_code.rb",
|
|
"--ruby", ruby_libdir, *Dir[libexec/"bin/*"]
|
|
|
|
system "./bin/passenger-config", "compile-nginx-engine"
|
|
cp Dir["buildout/support-binaries/nginx*"], libexec/"buildout/support-binaries", :preserve => true
|
|
|
|
nginx_addon_dir.gsub!(/^#{Regexp.escape Dir.pwd}/, libexec)
|
|
system "./dev/install_scripts_bootstrap_code.rb",
|
|
"--nginx-module-config", libexec/"bin", "#{nginx_addon_dir}/config"
|
|
|
|
man1.install Dir["man/*.1"]
|
|
man8.install Dir["man/*.8"]
|
|
end
|
|
|
|
def caveats; <<~EOS
|
|
To activate Phusion Passenger for Nginx, run:
|
|
brew install nginx
|
|
And add the following to #{etc}/nginx/nginx.conf at the top scope (outside http{}):
|
|
load_module #{opt_libexec}/modules/ngx_http_passenger_module.so;
|
|
And add the following to #{etc}/nginx/nginx.conf in the http scope:
|
|
passenger_root #{opt_libexec}/src/ruby_supportlib/phusion_passenger/locations.ini;
|
|
passenger_ruby /usr/bin/ruby;
|
|
|
|
To activate Phusion Passenger for Apache, create /etc/apache2/other/passenger.conf:
|
|
LoadModule passenger_module #{opt_libexec}/buildout/apache2/mod_passenger.so
|
|
PassengerRoot #{opt_libexec}/src/ruby_supportlib/phusion_passenger/locations.ini
|
|
PassengerDefaultRuby /usr/bin/ruby
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
ruby_libdir = `#{HOMEBREW_PREFIX}/bin/passenger-config --ruby-libdir`.strip
|
|
assert_equal "#{libexec}/src/ruby_supportlib", ruby_libdir
|
|
|
|
(testpath/"nginx.conf").write <<~EOS
|
|
load_module #{opt_libexec}/modules/ngx_http_passenger_module.so;
|
|
worker_processes 4;
|
|
error_log #{testpath}/error.log;
|
|
pid #{testpath}/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
passenger_root #{opt_libexec}/src/ruby_supportlib/phusion_passenger/locations.ini;
|
|
passenger_ruby /usr/bin/ruby;
|
|
client_body_temp_path #{testpath}/client_body_temp;
|
|
fastcgi_temp_path #{testpath}/fastcgi_temp;
|
|
proxy_temp_path #{testpath}/proxy_temp;
|
|
scgi_temp_path #{testpath}/scgi_temp;
|
|
uwsgi_temp_path #{testpath}/uwsgi_temp;
|
|
passenger_temp_path #{testpath}/passenger_temp;
|
|
|
|
server {
|
|
passenger_enabled on;
|
|
listen 8080;
|
|
root #{testpath};
|
|
access_log #{testpath}/access.log;
|
|
error_log #{testpath}/error.log;
|
|
}
|
|
}
|
|
EOS
|
|
system "#{Formula["nginx"].opt_bin}/nginx", "-t", "-c", testpath/"nginx.conf"
|
|
end
|
|
end
|