class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://www.unbound.net/downloads/unbound-1.6.0.tar.gz" sha256 "6b7db874e6debda742fee8869d722e5a17faf1086e93c911b8564532aeeffab7" bottle do sha256 "d105cae4a7e3580644c6036b4cdc5557887c34cc8c06715633578d925f6382da" => :sierra sha256 "6f06e1cb913655241055e92d15fc4be67d64134644eb8d35bc1dd3841c57c859" => :el_capitan sha256 "8e04a39562d3adb12cdf797eccec42c8bbe48305605252c407afff2ff154c3db" => :yosemite 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 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", "install" end def post_install if File.read(etc/"unbound/unbound.conf").include?('username: "@@HOMEBREW-UNBOUND-USER@@"') inreplace etc/"unbound/unbound.conf", 'username: "@@HOMEBREW-UNBOUND-USER@@"', "username: \"#{ENV["USER"]}\"" end 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