155 lines
6.7 KiB
Ruby
155 lines
6.7 KiB
Ruby
class Cassandra < Formula
|
|
desc "Eventually consistent, distributed key-value store"
|
|
homepage "https://cassandra.apache.org"
|
|
url "https://www.apache.org/dyn/closer.cgi?path=cassandra/3.11.2/apache-cassandra-3.11.2-bin.tar.gz"
|
|
sha256 "e922770ad95d5288d42442c3cfa1475938597b38418b7be5c4234a9de388c720"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "890b92afc0ff89760e82e60efc6d5b63f62c9e564b27a9eeef5a5cf74801e211" => :high_sierra
|
|
sha256 "6d09f021f24b66291bc4f03b57e307a9ebce7e24924e168e03df31d20a0d8a81" => :sierra
|
|
sha256 "1434b2bda7a0cb828343684296d87e64a865c639dc915b35c9b841116d2a92a2" => :el_capitan
|
|
end
|
|
|
|
depends_on "python@2" if MacOS.version <= :snow_leopard
|
|
depends_on "cython"
|
|
|
|
# Only >=Yosemite has new enough setuptools for successful compile of the below deps.
|
|
resource "setuptools" do
|
|
url "https://files.pythonhosted.org/packages/a4/c8/9a7a47f683d54d83f648d37c3e180317f80dc126a304c45dc6663246233a/setuptools-36.5.0.zip"
|
|
sha256 "ce2007c1cea3359870b80657d634253a0765b0c7dc5a988d77ba803fc86f2c64"
|
|
end
|
|
|
|
resource "futures" do
|
|
url "https://files.pythonhosted.org/packages/cc/26/b61e3a4eb50653e8a7339d84eeaa46d1e93b92951978873c220ae64d0733/futures-3.1.1.tar.gz"
|
|
sha256 "51ecb45f0add83c806c68e4b06106f90db260585b25ef2abfcda0bd95c0132fd"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz"
|
|
sha256 "70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
|
|
end
|
|
|
|
resource "thrift" do
|
|
url "https://files.pythonhosted.org/packages/a3/ea/84a41e03f1ab14fb314c8bcf1c451090efa14c5cdfb9797d1079f502b54e/thrift-0.10.0.zip"
|
|
sha256 "b7f6c09155321169af03f9fb20dc15a4a0c7481e7c334a5ba8f7f0d864633209"
|
|
end
|
|
|
|
resource "cql" do
|
|
url "https://files.pythonhosted.org/packages/0b/15/523f6008d32f05dd3c6a2e7c2f21505f0a785b6dc8949cad325306858afc/cql-1.4.0.tar.gz"
|
|
sha256 "7857c16d8aab7b736ab677d1016ef8513dedb64097214ad3a50a6c550cb7d6e0"
|
|
end
|
|
|
|
resource "cassandra-driver" do
|
|
url "https://files.pythonhosted.org/packages/5a/96/a5b2458a0483d3cefdf13064d40119754c1552ea34b7f0e8c6e03e66eb0a/cassandra-driver-3.11.0.tar.gz"
|
|
sha256 "643bed0fac08ee91630f0f35556bb62c3b4b007c20d4e6e8d349f769ea648150"
|
|
end
|
|
|
|
def install
|
|
(var/"lib/cassandra").mkpath
|
|
(var/"log/cassandra").mkpath
|
|
|
|
pypath = libexec/"vendor/lib/python2.7/site-packages"
|
|
ENV.prepend_create_path "PYTHONPATH", pypath
|
|
resources.each do |r|
|
|
r.stage do
|
|
system "python", *Language::Python.setup_install_args(libexec/"vendor")
|
|
end
|
|
end
|
|
|
|
inreplace "conf/cassandra.yaml", "/var/lib/cassandra", "#{var}/lib/cassandra"
|
|
inreplace "conf/cassandra-env.sh", "/lib/", "/"
|
|
|
|
inreplace "bin/cassandra", "-Dcassandra.logdir\=$CASSANDRA_HOME/logs", "-Dcassandra.logdir\=#{var}/log/cassandra"
|
|
inreplace "bin/cassandra.in.sh" do |s|
|
|
s.gsub! "CASSANDRA_HOME=\"`dirname \"$0\"`/..\"", "CASSANDRA_HOME=\"#{libexec}\""
|
|
# Store configs in etc, outside of keg
|
|
s.gsub! "CASSANDRA_CONF=\"$CASSANDRA_HOME/conf\"", "CASSANDRA_CONF=\"#{etc}/cassandra\""
|
|
# Jars installed to prefix, no longer in a lib folder
|
|
s.gsub! "\"$CASSANDRA_HOME\"/lib/*.jar", "\"$CASSANDRA_HOME\"/*.jar"
|
|
# The jammm Java agent is not in a lib/ subdir either:
|
|
s.gsub! "JAVA_AGENT=\"$JAVA_AGENT -javaagent:$CASSANDRA_HOME/lib/jamm-", "JAVA_AGENT=\"$JAVA_AGENT -javaagent:$CASSANDRA_HOME/jamm-"
|
|
# Storage path
|
|
s.gsub! "cassandra_storagedir\=\"$CASSANDRA_HOME/data\"", "cassandra_storagedir\=\"#{var}/lib/cassandra\""
|
|
end
|
|
|
|
rm Dir["bin/*.bat", "bin/*.ps1"]
|
|
|
|
# This breaks on `brew uninstall cassandra && brew install cassandra`
|
|
# https://github.com/Homebrew/homebrew/pull/38309
|
|
(etc/"cassandra").install Dir["conf/*"]
|
|
|
|
libexec.install Dir["*.txt", "{bin,interface,javadoc,pylib,lib/licenses}"]
|
|
libexec.install Dir["lib/*.jar"]
|
|
|
|
pkgshare.install [libexec/"bin/cassandra.in.sh", libexec/"bin/stop-server"]
|
|
inreplace Dir["#{libexec}/bin/cassandra*", "#{libexec}/bin/debug-cql", "#{libexec}/bin/nodetool", "#{libexec}/bin/sstable*"],
|
|
%r{`dirname "?\$0"?`/cassandra.in.sh},
|
|
"#{pkgshare}/cassandra.in.sh"
|
|
|
|
# Make sure tools are installed
|
|
rm Dir[buildpath/"tools/bin/*.bat"] # Delete before install to avoid copying useless files
|
|
(libexec/"tools").install Dir[buildpath/"tools/lib/*.jar"]
|
|
|
|
# Tools use different cassandra.in.sh and should be changed differently
|
|
mv buildpath/"tools/bin/cassandra.in.sh", buildpath/"tools/bin/cassandra-tools.in.sh"
|
|
inreplace buildpath/"tools/bin/cassandra-tools.in.sh" do |s|
|
|
# Tools have slightly different path to CASSANDRA_HOME
|
|
s.gsub! "CASSANDRA_HOME=\"`dirname $0`/../..\"", "CASSANDRA_HOME=\"#{libexec}\""
|
|
# Store configs in etc, outside of keg
|
|
s.gsub! "CASSANDRA_CONF=\"$CASSANDRA_HOME/conf\"", "CASSANDRA_CONF=\"#{etc}/cassandra\""
|
|
# Core Jars installed to prefix, no longer in a lib folder
|
|
s.gsub! "\"$CASSANDRA_HOME\"/lib/*.jar", "\"$CASSANDRA_HOME\"/*.jar"
|
|
# Tools Jars are under tools folder
|
|
s.gsub! "\"$CASSANDRA_HOME\"/tools/lib/*.jar", "\"$CASSANDRA_HOME\"/tools/*.jar"
|
|
# Storage path
|
|
s.gsub! "cassandra_storagedir\=\"$CASSANDRA_HOME/data\"", "cassandra_storagedir\=\"#{var}/lib/cassandra\""
|
|
end
|
|
|
|
pkgshare.install [buildpath/"tools/bin/cassandra-tools.in.sh"]
|
|
|
|
# Update tools script files
|
|
inreplace Dir[buildpath/"tools/bin/*"],
|
|
"`dirname \"$0\"`/cassandra.in.sh",
|
|
"#{pkgshare}/cassandra-tools.in.sh"
|
|
|
|
# Make sure tools are available
|
|
bin.install Dir[buildpath/"tools/bin/*"]
|
|
bin.write_exec_script Dir["#{libexec}/bin/*"]
|
|
|
|
rm %W[#{bin}/cqlsh #{bin}/cqlsh.py] # Remove existing exec scripts
|
|
(bin/"cqlsh").write_env_script libexec/"bin/cqlsh", :PYTHONPATH => pypath
|
|
(bin/"cqlsh.py").write_env_script libexec/"bin/cqlsh.py", :PYTHONPATH => pypath
|
|
end
|
|
|
|
plist_options :manual => "cassandra -f"
|
|
|
|
def plist; <<~EOS
|
|
<?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>KeepAlive</key>
|
|
<true/>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/cassandra</string>
|
|
<string>-f</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{var}/lib/cassandra</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
assert_match version.to_s, shell_output("#{bin}/cassandra -v")
|
|
# This is enough to error out if env script is broken/insufficient.
|
|
system bin/"cqlsh", "--version"
|
|
end
|
|
end
|