-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openresty: bundle openssl and debug formula (#244)
* add formulas (openresty, openresty-openssl and openresty-debug) * fix problems detected by `brew audit --strict --online`
- Loading branch information
Showing
3 changed files
with
203 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
class OpenrestyDebug < Formula | ||
desc "Scalable Web Platform by Extending NGINX with Lua" | ||
homepage "http://openresty.org" | ||
VERSION = "1.11.2.2".freeze | ||
url "https://openresty.org/download/openresty-#{VERSION}.tar.gz" | ||
sha256 "7f9ca62cfa1e4aedf29df9169aed0395fd1b90de254139996e554367db4d5a01" | ||
|
||
depends_on "pcre" | ||
depends_on "homebrew/nginx/openresty-openssl" | ||
depends_on "geoip" | ||
|
||
skip_clean "site" | ||
skip_clean "pod" | ||
skip_clean "nginx" | ||
skip_clean "luajit" | ||
|
||
def install | ||
# Configure | ||
cc_opt = "-I#{HOMEBREW_PREFIX}/include -I#{Formula["pcre"].opt_include} -I#{Formula["openresty-openssl"].opt_include}" | ||
ld_opt = "-L#{HOMEBREW_PREFIX}/lib -L#{Formula["pcre"].opt_lib} -L#{Formula["openresty-openssl"].opt_lib}" | ||
|
||
args = %W[ | ||
--prefix=#{prefix} | ||
--with-debug | ||
--with-cc-opt=#{cc_opt} | ||
--with-ld-opt=#{ld_opt} | ||
--with-pcre-jit | ||
--without-http_rds_json_module | ||
--without-http_rds_csv_module | ||
--without-lua_rds_parser | ||
--with-ipv6 | ||
--with-stream | ||
--with-stream_ssl_module | ||
--with-http_v2_module | ||
--without-mail_pop3_module | ||
--without-mail_imap_module | ||
--without-mail_smtp_module | ||
--with-http_stub_status_module | ||
--with-http_realip_module | ||
--with-http_addition_module | ||
--with-http_auth_request_module | ||
--with-http_secure_link_module | ||
--with-http_random_index_module | ||
--with-http_geoip_module | ||
--with-http_gzip_static_module | ||
--with-http_sub_module | ||
--with-http_dav_module | ||
--with-http_flv_module | ||
--with-http_mp4_module | ||
--with-http_gunzip_module | ||
--with-threads | ||
--with-luajit-xcflags=-DLUAJIT_NUMMODE=2\ -DLUAJIT_ENABLE_LUA52COMPAT | ||
--with-dtrace-probes | ||
] | ||
|
||
system "./configure", *args | ||
|
||
# Install | ||
system "make" | ||
system "make", "install" | ||
end | ||
|
||
plist_options :manual => "openresty" | ||
|
||
def plist; <<-EOS.undent | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Label</key> | ||
<string>#{plist_name}</string> | ||
<key>RunAtLoad</key> | ||
<true/> | ||
<key>KeepAlive</key> | ||
<false/> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>#{opt_prefix}/bin/openresty</string> | ||
<string>-g</string> | ||
<string>daemon off;</string> | ||
</array> | ||
<key>WorkingDirectory</key> | ||
<string>#{HOMEBREW_PREFIX}</string> | ||
</dict> | ||
</plist> | ||
EOS | ||
end | ||
|
||
test do | ||
system "#{bin}/openresty", "-V" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
class OpenrestyOpenssl < Formula | ||
desc "This OpenSSL library build is specifically for OpenResty uses" | ||
homepage "https://www.openssl.org/" | ||
VERSION = "1.0.2j".freeze | ||
|
||
stable do | ||
url "https://www.openssl.org/source/openssl-#{VERSION}.tar.gz" | ||
mirror "https://dl.bintray.com/homebrew/mirror/openssl-1#{VERSION}.tar.gz" | ||
mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-#{VERSION}.tar.gz" | ||
sha256 "e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431" | ||
|
||
patch do | ||
url "https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.0.2h-sess_set_get_cb_yield.patch" | ||
sha256 "6d6e02c21769784b106b62a146bfbfeac54884e23520c8dd29b74f3e1348d4a1" | ||
end | ||
end | ||
|
||
def install | ||
# OpenSSL will prefer the PERL environment variable if set over $PATH | ||
# which can cause some odd edge cases & isn't intended. Unset for safety. | ||
ENV.delete("PERL") | ||
|
||
# Load zlib from an explicit path instead of relying on dyld's fallback | ||
# path, which is empty in a SIP context. This patch will be unnecessary | ||
# when we begin building openssl with no-comp to disable TLS compression. | ||
# https://langui.sh/2015/11/27/sip-and-dlopen | ||
inreplace "crypto/comp/c_zlib.c", | ||
'zlib_dso = DSO_load(NULL, "z", NULL, 0);', | ||
'zlib_dso = DSO_load(NULL, "/usr/lib/libz.dylib", NULL, DSO_FLAG_NO_NAME_TRANSLATION);' | ||
|
||
args = [ | ||
"no-threads", | ||
"shared", | ||
"zlib", | ||
"-g", | ||
"--openssldir=#{prefix}", | ||
"--libdir=lib", | ||
] | ||
|
||
if MacOS.prefer_64_bit? | ||
args << "darwin64-x86_64-cc" | ||
args << "enable-ec_nistp_64_gcc_128" | ||
else | ||
args << "darwin-i386-cc" | ||
end | ||
|
||
system "./Configure", *args | ||
|
||
# Install | ||
system "make" | ||
system "make", "install", "MANDIR=#{man}" | ||
end | ||
|
||
test do | ||
# Check OpenSSL itself functions as expected. | ||
(testpath/"testfile.txt").write("This is a test file") | ||
expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249" | ||
system "#{bin}/openssl", "dgst", "-sha256", "-out", "checksum.txt", "testfile.txt" | ||
open("checksum.txt") do |f| | ||
checksum = f.read(100).split("=").last.strip | ||
assert_equal checksum, expected_checksum | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters