class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://www.unbound.net/downloads/unbound-1.6.6.tar.gz" sha256 "972b14dc33093e672652a7b2b5f159bab2198b0fe9c9e1c5707e1895d4d4b390" bottle do sha256 "d9794999f370d360df19096477e9eb1ff2050f13f34f2857456dc1a8212635a4" => :high_sierra sha256 "532efb5f56d0eb0cef8212a8fbba423292ccce47b01bc92d02006260d2d616d5" => :sierra sha256 "e38168c1dc3b2a776fdc51e1384ff41fa1d4a8ad23c6254dacf94662489c7dd6" => :el_capitan end depends_on "openssl" depends_on "libevent" depends_on :python => :optional depends_on "swig" if build.with?("python") def install args = %W[ --prefix=#{prefix} --sysconfdir=#{etc} --with-libevent=#{Formula["libevent"].opt_prefix} --with-ssl=#{Formula["openssl"].opt_prefix} ] if build.with? "python" ENV.prepend "LDFLAGS", `python-config --ldflags`.chomp ENV.prepend "PYTHON_VERSION", "2.7" args << "--with-pyunbound" args << "--with-pythonmodule" args << "PYTHON_SITE_PKG=#{lib}/python2.7/site-packages" end args << "--with-libexpat=#{MacOS.sdk_path}/usr" unless MacOS::CLT.installed? system "./configure", *args inreplace "doc/example.conf", 'username: "unbound"', 'username: "@@HOMEBREW-UNBOUND-USER@@"' system "make" system "make", "test" system "make", "install" end def post_install conf = etc/"unbound/unbound.conf" return unless conf.exist? return unless conf.read.include?('username: "@@HOMEBREW-UNBOUND-USER@@"') inreplace conf, 'username: "@@HOMEBREW-UNBOUND-USER@@"', "username: \"#{ENV["USER"]}\"" end plist_options :startup => true def plist; <<-EOS.undent Label #{plist_name} KeepAlive RunAtLoad ProgramArguments #{opt_sbin}/unbound -d -c #{etc}/unbound/unbound.conf UserName root StandardErrorPath /dev/null StandardOutPath /dev/null EOS end test do system sbin/"unbound-control-setup", "-d", testpath end end