class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://www.unbound.net/downloads/unbound-1.6.3.tar.gz" sha256 "4c7e655c1d0d2d133fdeb81bc1ab3aa5c155700f66c9f5fb53fa6a5c3ea9845f" bottle do sha256 "ed45f44d1b5216bd69d319d71b397a150476136ec54a0aeb108d5fb608fdf306" => :sierra sha256 "5c81ed76b13adc3f4ba10f2a7179dec44fbe49599451c48871cbfdf01500aac2" => :el_capitan sha256 "87e1425e241baa8b6f9795ebeeb01736bfd188cb8b4dd9fe5fc9e7ad3efcaeac" => :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", "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