161 lines
7 KiB
Ruby
161 lines
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.lua/cassandra/3.10/apache-cassandra-3.10-bin.tar.gz"
|
|
mirror "https://archive.apache.org/dist/cassandra/3.10/apache-cassandra-3.10-bin.tar.gz"
|
|
sha256 "c09c3f92d4f80d5639e3f1624c9eec45d25793bbb6b3e3640937b68a9c6d107f"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "efce0fd800b955a5f3d428696da6cae3f1a757879ea87a2f458189dad6d51e80" => :sierra
|
|
sha256 "d559b43ebeba88e45a8f0cf04798b7d0221748973b4430217ce843d53dfb4a58" => :el_capitan
|
|
sha256 "406646e26f02a96dd5494c270f2d420cabbea63d0fdc0750f0d46b9659910d35" => :yosemite
|
|
end
|
|
|
|
depends_on :python if MacOS.version <= :snow_leopard
|
|
|
|
# Only >=Yosemite has new enough setuptools for successful compile of the below deps.
|
|
resource "setuptools" do
|
|
url "https://files.pythonhosted.org/packages/26/d1/dc7fe14ce4a3ff3faebf1ac11350de4104ea2d2a80c98393b55c84362b0c/setuptools-32.1.0.tar.gz"
|
|
sha256 "86d57bf86edc0ecfd2dc0907ed3710bc4501fb13a06c0fcaf7632305b00ce832"
|
|
end
|
|
|
|
resource "Cython" do
|
|
url "https://files.pythonhosted.org/packages/b7/67/7e2a817f9e9c773ee3995c1e15204f5d01c8da71882016cac10342ef031b/Cython-0.25.2.tar.gz"
|
|
sha256 "f141d1f9c27a07b5a93f7dc5339472067e2d7140d1c5a9e20112a5665ca60306"
|
|
end
|
|
|
|
resource "futures" do
|
|
url "https://files.pythonhosted.org/packages/55/db/97c1ca37edab586a1ae03d6892b6633d8eaa23b23ac40c7e5bbc55423c78/futures-3.0.5.tar.gz"
|
|
sha256 "0542525145d5afc984c88f914a0c85c77527f65946617edb5274f72406f981df"
|
|
end
|
|
|
|
resource "six" do
|
|
url "https://files.pythonhosted.org/packages/b3/b2/238e2590826bfdd113244a40d9d3eb26918bd798fc187e2360a8367068db/six-1.10.0.tar.gz"
|
|
sha256 "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a"
|
|
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/d0/eb/9b9e7f1adcc8e11a9f106a2f40316e22b51af50107a449139ba796e9a71f/cassandra-driver-3.8.0.tar.gz"
|
|
sha256 "10b0c88854f3bddcfd994cb208d780507de62524ef8dcb4f068c084d335b7054"
|
|
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.undent
|
|
<?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
|