class I2pd < Formula desc "Full-featured C++ implementation of I2P client" homepage "https://i2pd.website/" url "https://github.com/PurpleI2P/i2pd/archive/2.24.0.tar.gz" sha256 "809b37100f0f176432b01ab6edee96dc62b0f65d5bf7531e008a87117e742566" bottle do cellar :any sha256 "b2a0d315c4eaa02ec6c0c9a502f3962d613b4337f60449fcb00847112df5d9f6" => :mojave sha256 "4ada1645aad31dac7981cddd963aee8697edb483e537e2bc7c7eb1b4a9766d07" => :high_sierra sha256 "66186dbdace70d45a8f88a77cb2a47575cc17e9a8fbcfaea35faeedd165d426d" => :sierra end depends_on "boost" depends_on "miniupnpc" depends_on "openssl@1.1" def install system "make", "install", "DEBUG=no", "HOMEBREW=1", "USE_UPNP=yes", "USE_AENSI=no", "USE_AVX=no", "PREFIX=#{prefix}" # preinstall to prevent overwriting changed by user configs confdir = etc/"i2pd" rm_rf prefix/"etc" confdir.install doc/"i2pd.conf", doc/"subscriptions.txt", doc/"tunnels.conf" end def post_install # i2pd uses datadir from variable below. If that path not exists, create that directory and create symlinks to certificates and configs. # Certificates can be updated between releases, so we must re-create symlinks to latest version of it on upgrade. datadir = var/"lib/i2pd" if datadir.exist? rm datadir/"certificates" datadir.install_symlink pkgshare/"certificates" else datadir.dirname.mkpath datadir.install_symlink pkgshare/"certificates", etc/"i2pd/i2pd.conf", etc/"i2pd/subscriptions.txt", etc/"i2pd/tunnels.conf" end (var/"log/i2pd").mkpath end plist_options :manual => "i2pd" def plist; <<~EOS Label #{plist_name} RunAtLoad ProgramArguments #{opt_bin}/i2pd --datadir=#{var}/lib/i2pd --conf=#{etc}/i2pd/i2pd.conf --tunconf=#{etc}/i2pd/tunnels.conf --log=file --logfile=#{var}/log/i2pd/i2pd.log --pidfile=#{var}/run/i2pd.pid EOS end test do pid = fork do exec "#{bin}/i2pd", "--datadir=#{testpath}", "--daemon" end sleep 5 Process.kill "TERM", pid assert_predicate testpath/"router.keys", :exist?, "Failed to start i2pd" end end