homebrew-core/Formula/couchdb.rb

80 lines
2.5 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.1/apache-couchdb-3.2.1.tar.gz"
mirror "https://archive.apache.org/dist/couchdb/source/3.2.1/apache-couchdb-3.2.1.tar.gz"
sha256 "11de2d1c3a5b317017a7459ec3f76230d5c43aba427a1e71ca3437845874acf8"
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: "d9cf6a2a9391564687d13d399483531a16b359b58e7e360e9bb5e07077a4b5ff"
sha256 cellar: :any, catalina: "d3143b2e8fde79e0cec1472d9318988f32dd4337c742f25b98e41c43f01d39f0"
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