homebrew-core/Formula/couchdb.rb

103 lines
4.0 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.2/apache-couchdb-3.3.0.tar.gz"
mirror "https://archive.apache.org/dist/couchdb/source/3.3.0/apache-couchdb-3.3.0.tar.gz"
sha256 "e8c6bf3f99a8f0d2af5806652f57d53796367e2d4b24dedc86e268cf86f787a0"
license "Apache-2.0"
livecheck do
url :homepage
regex(/href=.*?apache-couchdb[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "7a28d9819abd5d7ee722222ca187e2c63eb76905a178c6cf0743fe62aad11e05"
sha256 cellar: :any, arm64_monterey: "f7a2b0deb4cc8e654dfa29aa8c48e4f5eed34c1123e9986f3d9c1d43443e78f1"
sha256 cellar: :any, arm64_big_sur: "7274815dc32c5788dcb2ceeeb623597a4680e2dac9fb31d5af36d73375ae21d9"
sha256 cellar: :any, ventura: "8743e6f152213236f4d661d223c31f9afd89dd3f22760e6556b22631ea3fb230"
sha256 cellar: :any, monterey: "2cd2776a646c14fbd5f774596f6e8ddb740f38f045e70064facedc0109854238"
sha256 cellar: :any, big_sur: "a3e0206d18b52e3aa2af1ce87534150dfc4e8c991790cbbe259206368f8d5fde"
sha256 cellar: :any_skip_relocation, x86_64_linux: "10d7b4514130032b10269c156b9bef58b7cc2ebf9b9190bbef5f92cae91289d3"
end
depends_on "autoconf" => :build
depends_on "autoconf-archive" => :build
depends_on "automake" => :build
# Use Erlang 24 to work around a sporadic build error with rebar (v2) and Erlang 25.
# beam/beam_load.c(551): Error loading function rebar:save_options/2: op put_tuple u x:
# please re-compile this module with an Erlang/OTP 25 compiler
# escript: exception error: undefined function rebar:main/1
# Ref: https://github.com/Homebrew/homebrew-core/pull/105876
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"
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