From 99f4730aafc59491876ea22a2c9dc80256069dde Mon Sep 17 00:00:00 2001 From: empathicqubit Date: Fri, 19 Oct 2018 11:32:07 -0700 Subject: [PATCH] Initial commit. --- Formula/tinyproxy.rb | 91 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Formula/tinyproxy.rb diff --git a/Formula/tinyproxy.rb b/Formula/tinyproxy.rb new file mode 100644 index 0000000..732f9e9 --- /dev/null +++ b/Formula/tinyproxy.rb @@ -0,0 +1,91 @@ +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.8.4/tinyproxy-1.8.4.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