homebrew-core/Formula/varnish.rb

82 lines
3.2 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.1.tgz"
mirror "https://fossies.org/linux/www/varnish-7.0.1.tgz"
sha256 "c4e75beff0d461611742361fe8039ee1233ddf755b2b8a1e18a5fcacbe2b4660"
license "BSD-2-Clause"
revision 1
livecheck do
url "https://varnish-cache.org/releases/"
regex(/href=.*?varnish[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 arm64_big_sur: "5627a636277bc9d9361b245d521755799c53782b4585d709cff88e3c43fae50a"
sha256 monterey: "7cb4ae49e8618bd05741eeddf5de9f563b1c1c9a541216ad7444cbdd04383810"
sha256 big_sur: "30eabfc78b2a616339e8d931c7ca2d70356b3c9b2bb223ea045195e9d59445bf"
sha256 catalina: "ef8a23c4bd73ffd8431808cad95c0c738fc3a2b5a98a70aa30f9a99dc25918e4"
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"
# 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"] = which("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\"'"
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