class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://www.unbound.net/downloads/unbound-1.6.7.tar.gz" sha256 "4e7bd43d827004c6d51bef73adf941798e4588bdb40de5e79d89034d69751c9f" bottle do sha256 "6c2088a0ce3d415e5364c3580bdd797c77f5302f054216d2e5f08455b0654f32" => :high_sierra sha256 "aa331fd3f81151688aefe67289323cfeaf2e7ab176eb3f786f8bfd732337a681" => :sierra sha256 "ffe70f8e112a42fd48128e8cbea512bbef73a04a4416b9137279c8de957930a3" => :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 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