require "language/go" class Mongodb < Formula homepage "https://www.mongodb.org/" depends_on "go" => :build stable do url "https://fastdl.mongodb.org/src/mongodb-src-r3.0.3.tar.gz" sha256 "57765a81c18a0bb674fbe63bc507111d8795596eb9c9492028903985b4720807" go_resource "github.com/mongodb/mongo-tools" do url "https://github.com/mongodb/mongo-tools.git", :tag => "r3.0.3", :revision => "13a7eac12d16edd41fa875df759b16e4b027db7f" end end devel do url "https://fastdl.mongodb.org/src/mongodb-src-r3.1.2.tar.gz" sha256 "ed49023f81242ae0daadaffcf366da6d748dc638826604e2a7150764618fad85" go_resource "github.com/mongodb/mongo-tools" do url "https://github.com/mongodb/mongo-tools.git", :tag => "r3.1.2", :revision => "546c61eee0904fb60d4afef276b9476218053015" end end bottle do cellar :any sha256 "11b56632d04d55ca9b84c2b3c5d84b71aaa4cd915871e3530f4a62f5e72666c1" => :yosemite sha256 "3b0c1f8d8b5d5f86e61cdc62cc20dd58316c56c110267d5d7fe439c821263d56" => :mavericks sha256 "3aa0133679f5ef2325403c6e4cd96bc3b48aad0ea529c33c497ae77823f7994f" => :mountain_lion end option "with-boost", "Compile using installed boost, not the version shipped with mongodb" depends_on "boost" => :optional depends_on "go" => :build depends_on :macos => :snow_leopard depends_on "scons" => :build depends_on "openssl" => :optional def install ENV.libcxx if build.devel? # New Go tools have their own build script but the server scons "install" target is still # responsible for installing them. Language::Go.stage_deps resources, buildpath/"src" cd "src/github.com/mongodb/mongo-tools" do args = %W[] # Once https://github.com/mongodb/mongo-tools/issues/11 is fixed, also set CPATH. # For now, use default include path # if build.with? "openssl" args << "ssl" ENV["LIBRARY_PATH"] = "#{Formula["openssl"].opt_prefix}/lib" # ENV["CPATH"] = "#{Formula["openssl"].opt_prefix}/include" end system "./build.sh", *args end mkdir "src/mongo-tools" cp Dir["src/github.com/mongodb/mongo-tools/bin/*"], "src/mongo-tools/" args = %W[ --prefix=#{prefix} -j#{ENV.make_jobs} --osx-version-min=#{MacOS.version} ] if build.stable? args << "--cc=#{ENV.cc}" args << "--cxx=#{ENV.cxx}" end if build.devel? args << "CC=#{ENV.cc}" args << "CXX=#{ENV.cxx}" end args << "--use-system-boost" if build.with? "boost" args << "--use-new-tools" if build.with? "openssl" args << "--ssl" << "--extrapath=#{Formula["openssl"].opt_prefix}" end scons "install", *args (buildpath+"mongod.conf").write mongodb_conf etc.install "mongod.conf" (var+"mongodb").mkpath (var+"log/mongodb").mkpath end def mongodb_conf; <<-EOS.undent systemLog: destination: file path: #{var}/log/mongodb/mongo.log logAppend: true storage: dbPath: #{var}/mongodb net: bindIp: 127.0.0.1 EOS end plist_options :manual => "mongod --config #{HOMEBREW_PREFIX}/etc/mongod.conf" def plist; <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_bin}/mongod --config #{etc}/mongod.conf RunAtLoad KeepAlive WorkingDirectory #{HOMEBREW_PREFIX} StandardErrorPath #{var}/log/mongodb/output.log StandardOutPath #{var}/log/mongodb/output.log HardResourceLimits NumberOfFiles 4096 SoftResourceLimits NumberOfFiles 4096 EOS end test do system "#{bin}/mongod", "--sysinfo" end end