class Unbound < Formula desc "Validating, recursive, caching DNS resolver" homepage "https://www.unbound.net" url "https://nlnetlabs.nl/downloads/unbound/unbound-1.13.0.tar.gz" sha256 "a954043a95b0326ca4037e50dace1f3a207a0a19e9a4a22f4c6718fc623db2a1" license "BSD-3-Clause" head "https://github.com/NLnetLabs/unbound.git" # We check the GitHub repo tags instead of # https://nlnetlabs.nl/downloads/unbound/ since the first-party site has a # tendency to lead to an `execution expired` error. livecheck do url :head regex(/^(?:release-)?v?(\d+(?:\.\d+)+)$/i) end bottle do sha256 "cef5d9843ecaabaa0a4cb9b89e04bc3d370ce143e4ff2e0f6711aa6572b1ad3a" => :big_sur sha256 "132e7387adde0939a0f50d125ef5b6bdfa0186bae6dd9628668e9813813f4a9a" => :catalina sha256 "a1941e3c48de236e9310547620b1fdf71ec5c07ff8cb6dadc9e9433d02dfa1a7" => :mojave end depends_on "libevent" depends_on "nghttp2" depends_on "openssl@1.1" uses_from_macos "expat" def install args = %W[ --prefix=#{prefix} --sysconfdir=#{etc} --enable-event-api --enable-tfo-client --enable-tfo-server --with-libevent=#{Formula["libevent"].opt_prefix} --with-libnghttp2=#{Formula["nghttp2"].opt_prefix} --with-ssl=#{Formula["openssl@1.1"].opt_prefix} ] args << "--with-libexpat=#{MacOS.sdk_path}/usr" if MacOS.sdk_path_if_needed system "./configure", *args inreplace "doc/example.conf", 'username: "unbound"', 'username: "@@HOMEBREW-UNBOUND-USER@@"' system "make" 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