require "formula" class ShadowsocksLibev < Formula homepage "https://github.com/madeye/shadowsocks-libev" url "https://github.com/madeye/shadowsocks-libev/archive/v1.4.6.tar.gz" sha1 "b480559d6ad349138c46cfb00c9d1c3a6b2ef137" bottle do sha1 "c85772ca098fc62a670fc9bf47994efc74b5dada" => :mavericks sha1 "c34e3d20b2af99a5bd062be3d5f7dc8836ad3c7b" => :mountain_lion sha1 "5cabc840ff1e289aeb48f9fc4e1d0f754c9d9ed8" => :lion end head "https://github.com/madeye/shadowsocks-libev.git" option "with-polarssl", "Use PolarSSL instead of OpenSSL" depends_on "libev" if build.with? "polarssl" depends_on "polarssl" else depends_on "openssl" end 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