Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Updates nginx Formula for 1.12.1 Release #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 115 additions & 50 deletions files/brews/nginx.rb
Original file line number Diff line number Diff line change
@@ -1,67 +1,132 @@
require 'formula'

class Nginx < Formula
homepage 'https://nginx.org/'
url 'https://nginx.org/download/nginx-1.10.2.tar.gz'
sha256 '1045ac4987a396e2fa5d0011daf8987b612dd2f05181b67507da68cbe7d765c2'
version '1.10.2-boxen1'
desc "HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server"
homepage "https://nginx.org/"
url "https://nginx.org/download/nginx-1.12.1.tar.gz"
sha256 "8793bf426485a30f91021b6b945a9fd8a84d87d17b566562c3797aba8fac76fb"
version '1.12.1-boxen1'

depends_on 'pcre'
bottle do
sha256 "93bcf8e3aec465c219b6c0b4f4d5437c61bf00f2a930ef5702e0521edc51f20e" => :sierra
sha256 "8a7c3580534aa0854927f750d4f044a2a85f90d4c1936338a4a09fef7db0824e" => :el_capitan
sha256 "0caae754f402abbe1eca413a7f0291fe2499d5779bb1e537d7f80a4d7d3156d3" => :yosemite
end

# Before submitting more options to this formula please check they aren't
# already in Homebrew/homebrew-nginx/nginx-full:
# https://github.com/Homebrew/homebrew-nginx/blob/master/Formula/nginx-full.rb
option "with-passenger", "Compile with support for Phusion Passenger module"
option "with-webdav", "Compile with support for WebDAV module"
option "with-debug", "Compile with support for debug log"
option "with-gunzip", "Compile with support for gunzip module"

depends_on "pcre"
depends_on "passenger" => :optional

skip_clean 'logs'
# passenger uses apr, which uses openssl, so need to keep
# crypto library choice consistent throughout the tree.
if build.with? "passenger"
depends_on "openssl"
else
depends_on "openssl@1.1"
end

def options
[
['--with-passenger', "Compile with support for Phusion Passenger module"],
['--with-webdav', "Compile with support for WebDAV module"],
['--with-gzip-static', "Compile with support for Gzip Static module"],
['--with-http2', "Compile with support for the HTTP/2 module"],
def install
pcre = Formula["pcre"]

if build.with? "passenger"
openssl = Formula["openssl"]
else
openssl = Formula["openssl@1.1"]
end

cc_opt = "-I#{pcre.opt_include} -I#{openssl.opt_include}"
ld_opt = "-L#{pcre.opt_lib} -L#{openssl.opt_lib}"

args = %W[
--prefix=#{prefix}
--with-http_ssl_module
--with-pcre
--sbin-path=#{bin}/nginx
--with-cc-opt=#{cc_opt}
--with-ld-opt=#{ld_opt}
--conf-path=#{etc}/nginx/nginx.conf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks my version of nginx since the previous version has been built using at "--conf-path=/opt/boxen/config/nginx/nginx.conf", (from https://github.com/boxen/puppet-nginx/pull/51/files#diff-54d1ad9584e6ac1095707a81b10dc319L50).

Is this what is causing you the SIP issues?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just read up on the SIP directories and the problematic part will be /usr/local since Homebrew now uses that as the default. Would you be able to see where your nginx configuration file is managed and whether we can move this back under /opt/boxen?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been playing with this and on newer machines, using /opt/boxen causes it not to compile whereas on older machines it works so I'll have to have a think about how we are going to combat it.

Copy link

@ghost ghost Aug 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to install this package (1.7.0, same issue with 1.8.0) on OS X 10.11.6 and getting "Operation not permitted" errors when compiling. Looks related to what you mentioned above (I've tried disabling SIP but the error persists).

Have you made any progress thinking about a solution? I might be able to help out if you need it and can point me in the right direction.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened a discussion issue at boxen/boxen#214 since the configuration for Homebrew cannot be outside of the /etc directory anymore.

I'm looking into changing this across the board for all puppet modules (nginx, mysql, dnsmaq, etc) but not quite sure on the rollout plan for that just yet but I will open some PRs.

--pid-path=#{var}/run/nginx.pid
--lock-path=#{var}/run/nginx.lock
--http-client-body-temp-path=#{var}/run/nginx/client_body_temp
--http-proxy-temp-path=#{var}/run/nginx/proxy_temp
--http-fastcgi-temp-path=#{var}/run/nginx/fastcgi_temp
--http-uwsgi-temp-path=#{var}/run/nginx/uwsgi_temp
--http-scgi-temp-path=#{var}/run/nginx/scgi_temp
--http-log-path=#{var}/log/nginx/access.log
--error-log-path=#{var}/log/nginx/error.log
--with-http_gzip_static_module
--with-http_v2_module
]

if build.with? "passenger"
nginx_ext = `#{Formula["passenger"].opt_bin}/passenger-config --nginx-addon-dir`.chomp
args << "--add-module=#{nginx_ext}"
end

args << "--with-http_dav_module" if build.with? "webdav"
args << "--with-debug" if build.with? "debug"
args << "--with-http_gunzip_module" if build.with? "gunzip"

system "./configure", *args

system "make", "install"
man8.install "man/nginx.8"
end

depends_on "pcre"
depends_on "openssl" => :recommended
def passenger_caveats; <<-EOS.undent
To activate Phusion Passenger, add this to #{etc}/nginx/nginx.conf, inside the 'http' context:
passenger_root #{Formula["passenger"].opt_libexec}/src/ruby_supportlib/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
EOS
end

def passenger_config_args
passenger_root = `passenger-config --root`.chomp
def caveats
s = <<-EOS.undent
Docroot is: #{var}/www

if File.directory?(passenger_root)
return "--add-module=#{passenger_root}/ext/nginx"
end
The default port has been set in #{etc}/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

puts "Unable to install nginx with passenger support. The passenger"
puts "gem must be installed and passenger-config must be in your path"
puts "in order to continue."
exit
nginx will load all files in #{etc}/nginx/servers/.
EOS
s << "\n" << passenger_caveats if build.with? "passenger"
s
end

def install
pcre = Formula["pcre"]
openssl = Formula["openssl"]
cc_opt = "-I#{pcre.include} -I#{openssl.include}"
ld_opt = "-L#{pcre.lib} -L#{openssl.lib}"

args = ["--prefix=#{prefix}",
"--with-http_ssl_module",
"--with-pcre",
"--with-ipv6",
"--with-cc-opt=#{cc_opt}",
"--with-ld-opt=#{ld_opt}",
"--conf-path=/opt/boxen/config/nginx/nginx.conf",
"--pid-path=/opt/boxen/data/nginx/nginx.pid",
"--lock-path=/opt/boxen/data/nginx/nginx.lock"]

args << passenger_config_args if ARGV.include? '--with-passenger'
args << "--with-http_dav_module" if ARGV.include? '--with-webdav'
args << "--with-http_gzip_static_module" if ARGV.include? '--with-gzip-static'
args << "--with-http_v2_module" if ARGV.include? "--with-http2"
plist_options :manual => "nginx"

system "./configure", *args
system "make"
system "make install"
man8.install "objs/nginx.8"
test do
(testpath/"nginx.conf").write <<-EOS
worker_processes 4;
error_log #{testpath}/error.log;
pid #{testpath}/nginx.pid;

events {
worker_connections 1024;
}

http {
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;

# remove unnecessary config files
system "rm -rf #{etc}/nginx"
server {
listen 8080;
root #{testpath};
access_log #{testpath}/access.log;
error_log #{testpath}/error.log;
}
}
EOS
system bin/"nginx", "-t", "-c", testpath/"nginx.conf"
end
end
end
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}

package { 'boxen/brews/nginx':
ensure => '1.10.2-boxen1',
ensure => '1.12.1-boxen1',
install_options => [
'--with-http2',
],
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
with_before('Package[boxen/brews/nginx]')

should contain_package('boxen/brews/nginx').with({
:ensure => '1.10.2-boxen1',
:ensure => '1.12.1-boxen1',
:notify => 'Service[dev.nginx]'
})

Expand Down