83 lines
3.3 KiB
Ruby
83 lines
3.3 KiB
Ruby
class Varnish < Formula
|
|
desc "High-performance HTTP accelerator"
|
|
homepage "https://www.varnish-cache.org/"
|
|
url "https://varnish-cache.org/_downloads/varnish-7.0.2.tgz"
|
|
mirror "https://fossies.org/linux/www/varnish-7.0.2.tgz"
|
|
sha256 "524a495a6ad2bf5b7e4092b0907ed1d283dd270af426efa82b70714c630c3f61"
|
|
license "BSD-2-Clause"
|
|
|
|
livecheck do
|
|
url "https://varnish-cache.org/releases/"
|
|
regex(/href=.*?varnish[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "c059ba08e596b84b66524b675d338724ddbeb9d05d91415646e3e6ce0493131f"
|
|
sha256 arm64_big_sur: "642303e8955d340044802c6706d19eb5cb9f958cd0362238e4638b6e9f9b02e3"
|
|
sha256 monterey: "f2551a4b59adbfad5bfb90738819d2461e344ff8ee136507a96fe375b6eff976"
|
|
sha256 big_sur: "ae409b80f09e9be344b52b583568a71bafc0b8f4d49e40d8bfbc674d24b4686f"
|
|
sha256 catalina: "e5b2da263487ce4b42193e60ddce6738b36b248d7fd4748c2e9a4cf074f70a3e"
|
|
sha256 x86_64_linux: "f12c80427d0ff61dd9c9b10b96fd68d14bd60c373ebf3c2d0ecc6b3783d02849"
|
|
end
|
|
|
|
depends_on "docutils" => :build
|
|
depends_on "graphviz" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "python@3.10" => :build
|
|
depends_on "sphinx-doc" => :build
|
|
depends_on "pcre2"
|
|
|
|
uses_from_macos "libedit"
|
|
uses_from_macos "ncurses"
|
|
|
|
def install
|
|
ENV["PYTHON"] = Formula["python@3.10"].opt_bin/"python3"
|
|
|
|
system "./configure", "--disable-dependency-tracking",
|
|
"--prefix=#{prefix}",
|
|
"--localstatedir=#{var}"
|
|
|
|
# flags to set the paths used by varnishd to load VMODs and VCL,
|
|
# pointing to the ${HOMEBREW_PREFIX}/ shared structure so other packages
|
|
# can install VMODs and VCL.
|
|
ENV.append_to_cflags "-DVARNISH_VMOD_DIR='\"#{HOMEBREW_PREFIX}/lib/varnish/vmods\"'"
|
|
ENV.append_to_cflags "-DVARNISH_VCL_DIR='\"#{pkgetc}:#{HOMEBREW_PREFIX}/share/varnish/vcl\"'"
|
|
|
|
# Fix missing pthread symbols on Linux
|
|
ENV.append_to_cflags "-pthread" if OS.linux?
|
|
|
|
system "make", "install", "CFLAGS=#{ENV.cflags}"
|
|
|
|
(etc/"varnish").install "etc/example.vcl" => "default.vcl"
|
|
(var/"varnish").mkpath
|
|
|
|
(pkgshare/"tests").install buildpath.glob("bin/varnishtest/tests/*.vtc")
|
|
(pkgshare/"tests/vmod").install buildpath.glob("vmod/tests/*.vtc")
|
|
end
|
|
|
|
service do
|
|
run [opt_sbin/"varnishd", "-n", var/"varnish", "-f", etc/"varnish/default.vcl", "-s", "malloc,1G", "-T",
|
|
"127.0.0.1:2000", "-a", "0.0.0.0:8080", "-F"]
|
|
keep_alive true
|
|
working_dir HOMEBREW_PREFIX
|
|
log_path var/"varnish/varnish.log"
|
|
error_log_path var/"varnish/varnish.log"
|
|
end
|
|
|
|
test do
|
|
assert_match version.to_s, shell_output("#{sbin}/varnishd -V 2>&1")
|
|
|
|
# run a subset of the varnishtest tests:
|
|
# - b*.vtc (basic functionality)
|
|
# - m*.vtc (VMOD modules, including loading), but skipping m00000.vtc which is known to fail
|
|
# but is "nothing of concern" (see varnishcache/varnish-cache#3710)
|
|
# - u*.vtc (utilities and background processes)
|
|
testpath = pkgshare/"tests"
|
|
tests = testpath.glob("[bmu]*.vtc") - [testpath/"m00000.vtc"]
|
|
# -j: run the tests (using up to half the cores available)
|
|
# -q: only report test failures
|
|
# varnishtest will exit early if a test fails (use -k to continue and find all failures)
|
|
system bin/"varnishtest", "-j", [Hardware::CPU.cores / 2, 1].max, "-q", *tests
|
|
end
|
|
end
|