-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
couchdb.rb
100 lines (86 loc) 路 3.6 KB
/
couchdb.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
class Couchdb < Formula
desc "Apache CouchDB database server"
homepage "https://couchdb.apache.org/"
url "https://www.apache.org/dyn/closer.lua?path=couchdb/source/3.2.2/apache-couchdb-3.2.2.tar.gz"
mirror "https://archive.apache.org/dist/couchdb/source/3.2.2/apache-couchdb-3.2.2.tar.gz"
sha256 "69c9fd6f80133557f68a02e92dda72a4fd646d646f429f45bb8329a30f82f20e"
license "Apache-2.0"
livecheck do
url :homepage
regex(/href=.*?apache-couchdb[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "2fab358208981deafd146d0c49f3e533a06bb412a4d02d5d7afa5e828e89df57"
sha256 cellar: :any, arm64_big_sur: "0fcb0bf58416bb2ad58e578ea70e63982de166a6645e9370733191729a2375a6"
sha256 cellar: :any, monterey: "475a734c8519a6cd0982b008e234a7b6ddc15caec38a8ce4ed14b0510464573d"
sha256 cellar: :any, big_sur: "73ba80635c07e059358000befd3065dca3b6e4d9bac445b34f54af645316bcc9"
sha256 cellar: :any, catalina: "8f6a375c94f538db7bc63228bbf6c832c8bdd063b26b214ee13822ce0ae28cc9"
sha256 cellar: :any_skip_relocation, x86_64_linux: "f8804f85eb24a94f2e5168ed8eb70f1b3cf6850fb2554d9cac95b68284586416"
end
depends_on "autoconf" => :build
depends_on "autoconf-archive" => :build
depends_on "automake" => :build
depends_on "erlang" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "icu4c"
depends_on "openssl@1.1"
# NOTE: Supported `spidermonkey` versions are hardcoded at
# https://github.com/apache/couchdb/blob/#{version}/src/couch/rebar.config.script
depends_on "spidermonkey"
on_linux do
depends_on "gcc"
end
conflicts_with "ejabberd", because: "both install `jiffy` lib"
fails_with :gcc do
version "5"
cause "mfbt (and Gecko) require at least gcc 6.1 to build."
end
def install
spidermonkey = Formula["spidermonkey"]
inreplace "src/couch/rebar.config.script" do |s|
s.gsub! "-I/usr/local/include/mozjs", "-I#{spidermonkey.opt_include}/mozjs"
s.gsub! "-L/usr/local/lib", "-L#{spidermonkey.opt_lib} -L#{HOMEBREW_PREFIX}/lib"
end
system "./configure", "--spidermonkey-version", spidermonkey.version.major
system "make", "release"
# setting new database dir
inreplace "rel/couchdb/etc/default.ini", "./data", "#{var}/couchdb/data"
# remove windows startup script
rm_rf("rel/couchdb/bin/couchdb.cmd")
# install files
prefix.install Dir["rel/couchdb/*"]
if File.exist?(prefix/"Library/LaunchDaemons/org.apache.couchdb.plist")
(prefix/"Library/LaunchDaemons/org.apache.couchdb.plist").delete
end
end
def post_install
# creating database directory
(var/"couchdb/data").mkpath
end
def caveats
<<~EOS
CouchDB 3.x requires a set admin password set before startup.
Add one to your #{etc}/local.ini before starting CouchDB e.g.:
[admins]
admin = youradminpassword
EOS
end
service do
run opt_bin/"couchdb"
keep_alive true
end
test do
cp_r prefix/"etc", testpath
port = free_port
inreplace "#{testpath}/etc/default.ini", "port = 5984", "port = #{port}"
inreplace "#{testpath}/etc/default.ini", "#{var}/couchdb/data", "#{testpath}/data"
inreplace "#{testpath}/etc/local.ini", ";admin = mysecretpassword", "admin = mysecretpassword"
fork do
exec "#{bin}/couchdb -couch_ini #{testpath}/etc/default.ini #{testpath}/etc/local.ini"
end
sleep 30
output = JSON.parse shell_output("curl --silent localhost:#{port}")
assert_equal "Welcome", output["couchdb"]
end
end