forked from lotia/homebrew-versions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongodb30.rb
136 lines (114 loc) · 3.96 KB
/
mongodb30.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
require "language/go"
class Mongodb30 < Formula
desc "High-performance document-oriented database"
homepage "https://www.mongodb.org/"
url "https://fastdl.mongodb.org/src/mongodb-src-r3.0.12.tar.gz"
sha256 "b9bea5e3d59b93775d5d55fb1dd161272aeefa193c2311a8f6722ad46d7a21ab"
bottle do
cellar :any_skip_relocation
sha256 "61b1e171727f9ef4f591bf67edae88070c5641dd3de3ffe3a25e191312351bf5" => :el_capitan
sha256 "08a60c93e6f9db053a2e395ae81726f1b5002cdd7a953a3e9207a2ee07ef05a3" => :yosemite
sha256 "b13af26aec7da81a371d445c2d4de538e6881f4af3b1c87391ae70d31ad8dc78" => :mavericks
end
option "with-boost", "Compile using installed boost, not the version shipped with mongodb"
needs :cxx11
depends_on "boost" => :optional
depends_on "go" => :build
depends_on :macos => :mountain_lion
depends_on "scons" => :build
depends_on "openssl" => :optional
go_resource "github.com/mongodb/mongo-tools" do
url "https://github.com/mongodb/mongo-tools.git",
:tag => "r3.0.12",
:revision => "81c527a658a687b83564dfb9767df64420e9bcab"
end
def install
ENV.cxx11 if MacOS.version < :mavericks
# 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
# https://github.com/Homebrew/homebrew/issues/40136
inreplace "build.sh", '-ldflags "-X github.com/mongodb/mongo-tools/common/options.Gitspec=`git rev-parse HEAD` -X github.com/mongodb/mongo-tools/common/options.VersionStr=$(git describe)"', ""
args = %w[]
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}
--cc=#{ENV.cc}
--cxx=#{ENV.cxx}
]
args << "--use-system-boost" if build.with? "boost"
args << "--use-new-tools"
args << "--disable-warnings-as-errors" if MacOS.version >= :yosemite
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/mongod</string>
<string>--config</string>
<string>#{etc}/mongod.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/mongodb/output.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/mongodb/output.log</string>
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>4096</integer>
</dict>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>4096</integer>
</dict>
</dict>
</plist>
EOS
end
test do
system "#{bin}/mongod", "--sysinfo"
end
end