2010-08-19 13:40:55 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Zookeeper < Formula
|
2011-03-27 20:09:35 +00:00
|
|
|
homepage 'http://zookeeper.apache.org/'
|
2012-11-19 17:44:08 +00:00
|
|
|
url 'http://www.apache.org/dyn/closer.cgi?path=zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz'
|
|
|
|
sha1 'fd921575e02478909557034ea922de871926efc7'
|
2012-02-17 08:35:49 +00:00
|
|
|
|
|
|
|
head 'http://svn.apache.org/repos/asf/zookeeper/trunk'
|
2011-02-28 04:54:32 +00:00
|
|
|
|
2012-08-23 22:11:55 +00:00
|
|
|
if build.head?
|
2012-07-07 18:08:22 +00:00
|
|
|
depends_on :automake
|
|
|
|
depends_on :libtool
|
|
|
|
end
|
|
|
|
|
2012-07-30 19:51:49 +00:00
|
|
|
option "c", "Build C bindings."
|
|
|
|
option "perl", "Build Perl bindings."
|
|
|
|
option "python", "Build Python bindings."
|
2010-08-19 13:40:55 +00:00
|
|
|
|
|
|
|
def shim_script target
|
|
|
|
<<-EOS.undent
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
. "#{etc}/zookeeper/defaults"
|
2012-07-30 19:57:03 +00:00
|
|
|
cd "#{libexec}/bin"
|
|
|
|
./#{target} "$@"
|
2010-08-19 13:40:55 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_zk_env
|
|
|
|
<<-EOS.undent
|
|
|
|
export ZOOCFGDIR="#{etc}/zookeeper"
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_log4j_properties
|
|
|
|
<<-EOS.undent
|
|
|
|
log4j.rootCategory=WARN, zklog
|
|
|
|
log4j.appender.zklog = org.apache.log4j.FileAppender
|
|
|
|
log4j.appender.zklog.File = #{var}/log/zookeeper/zookeeper.log
|
|
|
|
log4j.appender.zklog.Append = true
|
|
|
|
log4j.appender.zklog.layout = org.apache.log4j.PatternLayout
|
|
|
|
log4j.appender.zklog.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def install
|
2011-05-10 09:56:44 +00:00
|
|
|
# Don't try to build extensions for PPC
|
|
|
|
if Hardware.is_32_bit?
|
|
|
|
ENV['ARCHFLAGS'] = "-arch i386"
|
|
|
|
else
|
|
|
|
ENV['ARCHFLAGS'] = "-arch i386 -arch x86_64"
|
|
|
|
end
|
|
|
|
|
2011-02-28 04:54:32 +00:00
|
|
|
# Prep work for svn compile.
|
2012-07-30 19:51:49 +00:00
|
|
|
if build.head?
|
2011-02-28 04:54:32 +00:00
|
|
|
system "ant", "compile_jute"
|
|
|
|
|
|
|
|
cd "src/c" do
|
|
|
|
system "autoreconf", "-if"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-30 19:51:49 +00:00
|
|
|
build_python = build.include? "python"
|
|
|
|
build_perl = build.include? "perl"
|
2012-10-03 13:42:18 +00:00
|
|
|
build_c = build_python || build_perl || build.include?("c")
|
2012-02-29 01:30:16 +00:00
|
|
|
|
2011-02-28 04:54:32 +00:00
|
|
|
# Build & install C libraries.
|
|
|
|
cd "src/c" do
|
2012-07-30 19:57:03 +00:00
|
|
|
system "./configure", "--disable-dependency-tracking",
|
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--without-cppunit"
|
2011-02-28 04:54:32 +00:00
|
|
|
system "make install"
|
2012-02-29 01:30:16 +00:00
|
|
|
end if build_c
|
2011-02-28 04:54:32 +00:00
|
|
|
|
|
|
|
# Install Python bindings
|
|
|
|
cd "src/contrib/zkpython" do
|
|
|
|
system "python", "src/python/setup.py", "build"
|
|
|
|
system "python", "src/python/setup.py", "install", "--prefix=#{prefix}"
|
2012-02-29 01:30:16 +00:00
|
|
|
end if build_python
|
2011-02-28 04:54:32 +00:00
|
|
|
|
|
|
|
# Install Perl bindings
|
|
|
|
cd "src/contrib/zkperl" do
|
2012-07-30 19:57:03 +00:00
|
|
|
system "perl", "Makefile.PL", "PREFIX=#{prefix}",
|
|
|
|
"--zookeeper-include=#{include}/c-client-src",
|
|
|
|
"--zookeeper-lib=#{lib}"
|
2011-02-28 04:54:32 +00:00
|
|
|
system "make install"
|
2012-02-29 01:30:16 +00:00
|
|
|
end if build_perl
|
2011-02-28 04:54:32 +00:00
|
|
|
|
2010-08-19 13:40:55 +00:00
|
|
|
# Remove windows executables
|
|
|
|
rm_f Dir["bin/*.cmd"]
|
|
|
|
|
|
|
|
# Install Java stuff
|
2012-07-30 19:51:49 +00:00
|
|
|
if build.head?
|
2011-02-28 04:54:32 +00:00
|
|
|
system "ant"
|
|
|
|
libexec.install %w(bin src/contrib src/java/lib)
|
|
|
|
libexec.install Dir['build/*.jar']
|
|
|
|
else
|
|
|
|
libexec.install %w(bin contrib lib)
|
|
|
|
libexec.install Dir['*.jar']
|
|
|
|
end
|
2010-08-19 13:40:55 +00:00
|
|
|
|
2012-01-04 06:05:05 +00:00
|
|
|
# Create necessary directories
|
2010-08-19 13:40:55 +00:00
|
|
|
bin.mkpath
|
|
|
|
(etc+'zookeeper').mkpath
|
|
|
|
(var+'log/zookeeper').mkpath
|
|
|
|
(var+'run/zookeeper/data').mkpath
|
|
|
|
|
|
|
|
# Install shim scripts to bin
|
|
|
|
Dir["#{libexec}/bin/*.sh"].map { |p| Pathname.new p }.each { |path|
|
|
|
|
next if path == libexec+'bin/zkEnv.sh'
|
|
|
|
script_name = path.basename
|
|
|
|
bin_name = path.basename '.sh'
|
|
|
|
(bin+bin_name).write shim_script(script_name)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install default config files
|
2012-07-30 19:57:03 +00:00
|
|
|
defaults = etc/'zookeeper/defaults'
|
2010-08-19 13:40:55 +00:00
|
|
|
defaults.write(default_zk_env) unless defaults.exist?
|
|
|
|
|
2012-07-30 19:57:03 +00:00
|
|
|
log4j_properties = etc/'zookeeper/log4j.properties'
|
2010-08-19 13:40:55 +00:00
|
|
|
log4j_properties.write(default_log4j_properties) unless log4j_properties.exist?
|
|
|
|
|
2012-07-30 19:57:03 +00:00
|
|
|
unless (etc/'zookeeper/zoo.cfg').exist?
|
|
|
|
inreplace 'conf/zoo_sample.cfg',
|
|
|
|
/^dataDir=.*/, "dataDir=#{var}/run/zookeeper/data"
|
|
|
|
(etc/'zookeeper').install 'conf/zoo_sample.cfg'
|
2010-08-19 13:40:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|