homebrew-core/Formula/squid.rb
2019-02-18 11:25:49 +01:00

86 lines
2.5 KiB
Ruby

class Squid < Formula
desc "Advanced proxy caching server for HTTP, HTTPS, FTP, and Gopher"
homepage "http://www.squid-cache.org/"
url "http://www.squid-cache.org/Versions/v4/squid-4.5.tar.xz"
sha256 "553edf76d6ee9a1627af9c2be7be850c14cd6836170b3d6c1393fd700d44ccc5"
bottle do
sha256 "dc48028ff57b2a850792a9009bfc0d10acdebdeb6153680df1bc659f10c25718" => :mojave
sha256 "4c10e05a05409468cb46c3f488d943ba5e50213928a53b4324d46502f8f8ec83" => :high_sierra
sha256 "954bc51b342e278f3192fc136694414d035a39f322e94f1afa8d04ab528b4549" => :sierra
end
head do
url "lp:squid", :using => :bzr
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "openssl"
def install
# https://stackoverflow.com/questions/20910109/building-squid-cache-on-os-x-mavericks
ENV.append "LDFLAGS", "-lresolv"
# For --disable-eui, see:
# http://www.squid-cache.org/mail-archive/squid-users/201304/0040.html
args = %W[
--disable-debug
--disable-dependency-tracking
--prefix=#{prefix}
--localstatedir=#{var}
--sysconfdir=#{etc}
--enable-ssl
--enable-ssl-crtd
--disable-eui
--enable-pf-transparent
--with-included-ltdl
--with-openssl
--enable-delay-pools
--enable-disk-io=yes
--enable-removal-policies=yes
--enable-storeio=yes
]
system "./bootstrap.sh" if build.head?
system "./configure", *args
system "make", "install"
end
plist_options :manual => "squid"
def plist; <<~EOS
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_sbin}/squid</string>
<string>-N</string>
<string>-d 1</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
</dict>
</plist>
EOS
end
test do
# This test should start squid and then check it runs correctly.
# However currently dies under the sandbox and "Current Directory"
# seems to be set hard on HOMEBREW_PREFIX/var/cache/squid.
# https://github.com/Homebrew/homebrew/pull/44348#issuecomment-143477353
# If you can fix this, please submit a PR. Thank you!
assert_match version.to_s, shell_output("#{sbin}/squid -v")
end
end