class Tinyproxy < Formula desc "HTTP/HTTPS proxy for POSIX systems" homepage "https://www.banu.com/tinyproxy/" url "https://github.com/tinyproxy/tinyproxy/releases/download/1.10.0/tinyproxy-1.10.0.tar.xz" sha256 "59be87689c415ba0d9c9bc6babbdd3df3b372d60b21e526b118d722dbc995682" bottle do rebuild 1 sha256 "7e7250cfbda60dcf40e291ce777842953bdfa573023ca28d2b09eefe41c0e523" => :high_sierra end option "with-reverse", "Enable reverse proxying" option "with-transparent", "Enable transparent proxying" option "with-filter", "Enable url filtering" deprecated_option "reverse" => "with-reverse" depends_on "asciidoc" => :build depends_on "docbook-xsl" => :build def install ENV["XML_CATALOG_FILES"] = "#{etc}/xml/catalog" args = %W[ --disable-debug --disable-dependency-tracking --disable-silent-rules --prefix=#{prefix} --localstatedir=#{var} --sysconfdir=#{etc} --disable-regexcheck ] args << "--enable-reverse" if build.with? "reverse" args << "--enable-transparent" if build.with? "transparent" args << "--enable-filter" if build.with? "filter" system "./configure", *args # Fix broken XML lint # See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=154624 inreplace %w[docs/man5/Makefile docs/man8/Makefile], "-f manpage", "-f manpage \\\n -L" system "make", "install" end def post_install (var/"log/tinyproxy").mkpath (var/"run/tinyproxy").mkpath end plist_options :manual => "tinyproxy" def plist; <<~EOS Label #{plist_name} RunAtLoad KeepAlive ProgramArguments #{opt_sbin}/tinyproxy -d WorkingDirectory #{HOMEBREW_PREFIX} EOS end test do pid = fork do exec "#{sbin}/tinyproxy" end sleep 2 begin assert_match /tinyproxy/, shell_output("curl localhost:8888") ensure Process.kill("SIGINT", pid) Process.wait(pid) end end end