1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
require "formula"
class Zookeeper < Formula
homepage "https://zookeeper.apache.org/"
revision 1
stable do
url "http://www.apache.org/dyn/closer.cgi?path=zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz"
sha1 "2a9e53f5990dfe0965834a525fbcad226bf93474"
# To resolve Yosemite build errors.
# https://issues.apache.org/jira/browse/ZOOKEEPER-2049
if MacOS.version == :yosemite
patch :p0 do
url "https://issues.apache.org/jira/secure/attachment/12673210/ZOOKEEPER-2049.noprefix.branch-3.4.patch"
sha1 "ff0e971c028050ccebd8cc7caa348ab14716d664"
end
end
end
bottle do
revision 1
sha1 "4ef32a515592565bdf88546b9773725e4079a080" => :yosemite
sha1 "c2db3e5bf5f66cd575a827842d667ec7f1acf6d0" => :mavericks
sha1 "ac54b226852c9ec51477de8263bec2c767f7e842" => :mountain_lion
end
head do
url "https://svn.apache.org/repos/asf/zookeeper/trunk"
# To resolve Yosemite build errors.
# https://issues.apache.org/jira/browse/ZOOKEEPER-2049
if MacOS.version == :yosemite
patch :p0 do
url "https://issues.apache.org/jira/secure/attachment/12673212/ZOOKEEPER-2049.noprefix.trunk.patch"
sha1 "79ed0793e4693c9bbb83aad70582b55012f19eac"
end
end
depends_on "ant" => :build
depends_on "cppunit" => :build
depends_on "libtool" => :build
depends_on "autoconf" => :build
depends_on "automake" => :build
end
option "perl", "Build Perl bindings"
depends_on :python => :optional
def shim_script target
<<-EOS.undent
#!/usr/bin/env bash
. "#{etc}/zookeeper/defaults"
cd "#{libexec}/bin"
./#{target} "$@"
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
# Don't try to build extensions for PPC
if Hardware.is_32_bit?
ENV["ARCHFLAGS"] = "-arch #{Hardware::CPU.arch_32_bit}"
else
ENV["ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
end
if build.head?
system "ant", "compile_jute"
system "autoreconf", "-fvi", "src/c"
end
cd "src/c" do
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--without-cppunit"
system "make", "install"
end
cd "src/contrib/zkpython" do
system "python", "src/python/setup.py", "build"
system "python", "src/python/setup.py", "install", "--prefix=#{prefix}"
end if build.with? "python"
cd "src/contrib/zkperl" do
system "perl", "Makefile.PL", "PREFIX=#{prefix}",
"--zookeeper-include=#{include}",
"--zookeeper-lib=#{lib}"
system "make", "install"
end if build.include? "perl"
rm_f Dir["bin/*.cmd"]
if build.head?
system "ant"
libexec.install Dir["bin", "src/contrib", "src/java/lib", "build/*.jar"]
else
libexec.install Dir["bin", "contrib", "lib", "*.jar"]
end
bin.mkpath
(etc+"zookeeper").mkpath
(var+"log/zookeeper").mkpath
(var+"run/zookeeper/data").mkpath
Pathname.glob("#{libexec}/bin/*.sh") do |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)
end
defaults = etc/"zookeeper/defaults"
defaults.write(default_zk_env) unless defaults.exist?
log4j_properties = etc/"zookeeper/log4j.properties"
log4j_properties.write(default_log4j_properties) unless log4j_properties.exist?
inreplace "conf/zoo_sample.cfg",
/^dataDir=.*/, "dataDir=#{var}/run/zookeeper/data"
cp "conf/zoo_sample.cfg", "conf/zoo.cfg"
(etc/"zookeeper").install ["conf/zoo.cfg", "conf/zoo_sample.cfg"]
end
plist_options :manual => "zkServer start"
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>EnvironmentVariables</key>
<dict>
<key>SERVER_JVMFLAGS</key>
<string>-Dapple.awt.UIElement=true</string>
</dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/zkServer</string>
<string>start-foreground</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{var}</string>
</dict>
</plist>
EOS
end
end
|