require "formula" class ShadowsocksLibev < Formula homepage "https://github.com/madeye/shadowsocks-libev" url "https://github.com/madeye/shadowsocks-libev/archive/v1.4.7.tar.gz" sha1 "f14b0c59e8f290a0e77b231bf0d0967557c1ca88" bottle do sha1 "f30fc541d334ab784c027e34c98665ced8c9adac" => :mavericks sha1 "9b534282de12a38ecd456b531b7824b9b2ecc987" => :mountain_lion sha1 "b9b21fb9fcf1c2bd81094614e0a13467a85a8f1e" => :lion end head "https://github.com/madeye/shadowsocks-libev.git" option "with-polarssl", "Use PolarSSL instead of OpenSSL" depends_on "libev" depends_on "polarssl" => :optional depends_on "openssl" if build.without? "polarssl" def install args = ["--prefix=#{prefix}"] if build.with? "polarssl" polarssl = Formula["polarssl"] args << "--with-crypto-library=polarssl" args << "--with-polarssl=#{polarssl.opt_prefix}" end system "./configure", *args system "make", "install" (buildpath/"shadowsocks-libev.json").write <<-EOS.undent { "server":"localhost", "server_port":8388, "local_port":1080, "password":"barfoo!", "timeout":600, "method":null } EOS etc.install "shadowsocks-libev.json" inreplace "shadowsocks.8", "/etc/shadowsocks/config.json", "#{etc}/shadowsocks-libev.json" man8.install "shadowsocks.8" end plist_options :manual => "#{HOMEBREW_PREFIX}/opt/shadowsocks-libev/bin/ss-local -c #{HOMEBREW_PREFIX}/etc/shadowsocks-libev.json" def plist; <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_bin}/ss-local -c #{etc}/shadowsocks-libev.json RunAtLoad KeepAlive SuccessfulExit EOS end end