81 lines
2.6 KiB
Ruby
81 lines
2.6 KiB
Ruby
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.0/apache-couchdb-3.2.0.tar.gz"
|
|
mirror "https://archive.apache.org/dist/couchdb/source/3.2.0/apache-couchdb-3.2.0.tar.gz"
|
|
sha256 "8bea574faa6bb0926c670542d8318c322268cf7e6614dab318dea734ccf1b00c"
|
|
license "Apache-2.0"
|
|
|
|
livecheck do
|
|
url :homepage
|
|
regex(/href=.*?apache-couchdb[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, big_sur: "4d0f0c145720db23f52483fdf3b35363f9343e3b39285c91255da1993ab91bff"
|
|
sha256 cellar: :any, catalina: "3a2892f1076c575372e4012c8858c23fc05a787abfa679376ce1c4a7ea4fa8ae"
|
|
sha256 cellar: :any, mojave: "ef4e1a3ef761a58fe16b4d163c0b4331f1ffd3833b7fe6d7cf820c6a5064c37d"
|
|
end
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "autoconf-archive" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "erlang@22" => :build
|
|
depends_on "libtool" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "icu4c"
|
|
depends_on "openssl@1.1"
|
|
depends_on "spidermonkey"
|
|
|
|
conflicts_with "ejabberd", because: "both install `jiffy` lib"
|
|
|
|
def install
|
|
system "./configure"
|
|
system "make", "release"
|
|
# setting new database dir
|
|
inreplace "rel/couchdb/etc/default.ini", "./data", "#{var}/couchdb/data"
|
|
# remove windows startup script
|
|
File.delete("rel/couchdb/bin/couchdb.cmd") if File.exist?("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
|