homebrew-core/Formula/varnish.rb

89 lines
3.6 KiB
Ruby

class Varnish < Formula
desc "High-performance HTTP accelerator"
homepage "https://www.varnish-cache.org/"
url "https://varnish-cache.org/_downloads/varnish-7.1.0.tgz"
mirror "https://fossies.org/linux/www/varnish-7.1.0.tgz"
sha256 "f54ab88685667664e5b3c39eb56ac8c624b6c1093436a7f8c555491144c69eba"
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: "89554b939bb1b85fc8032305c681ef1c240e8a00920a64ae8b71618259b155bc"
sha256 arm64_big_sur: "6eab839b361de2e0dc9c14c8ddfb977b8599962d567c73ec3521c92704c47f30"
sha256 monterey: "5758ad59d68f22e014015e7ea212ae3f52514e88032abcb9567f298f626534f1"
sha256 big_sur: "1e0724142d7a233ccfbb6ec48714ba51abff81016892b40ba1cf36625ef8dcc7"
sha256 catalina: "f7b97c17fad0a2359978f822e0d812d2b2332de828e4182d1f8e398a00d7788b"
sha256 x86_64_linux: "18a1935aa5b9b726a6d36e0712081ba0eba1721240401a25d1a54d6b37bbbf0f"
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"
# Fix -flat_namespace being used on Big Sur and later.
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-big_sur.diff"
sha256 "35acd6aebc19843f1a2b3a63e880baceb0f5278ab1ace661e57a502d9d78c93c"
end
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