diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f69aee1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/zookeeper-3.4.5.tar.gz
diff --git a/ZOOKEEPER-1557.patch b/ZOOKEEPER-1557.patch
new file mode 100644
index 0000000..e273685
--- /dev/null
+++ b/ZOOKEEPER-1557.patch
@@ -0,0 +1,152 @@
+diff --git src/java/test/org/apache/zookeeper/test/SaslAuthFailNotifyTest.java src/java/test/org/apache/zookeeper/test/SaslAuthFailNotifyTest.java
+new file mode 100644
+index 0000000..2b00d86
+--- /dev/null
++++ src/java/test/org/apache/zookeeper/test/SaslAuthFailNotifyTest.java
+@@ -0,0 +1,98 @@
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.zookeeper.test;
++
++import java.io.File;
++import java.io.FileWriter;
++import java.io.IOException;
++import java.util.concurrent.atomic.AtomicInteger;
++
++import org.apache.zookeeper.CreateMode;
++import org.apache.zookeeper.TestableZooKeeper;
++import org.apache.zookeeper.WatchedEvent;
++import org.apache.zookeeper.ZooKeeper;
++import org.apache.zookeeper.Watcher.Event.KeeperState;
++import org.apache.zookeeper.ZooDefs.Ids;
++import org.junit.Test;
++import org.junit.Assert;
++
++public class SaslAuthFailNotifyTest extends ClientBase {
++ static {
++ System.setProperty("zookeeper.authProvider.1","org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
++ System.setProperty("zookeeper.allowSaslFailedClients","true");
++
++ try {
++ File tmpDir = createTmpDir();
++ File saslConfFile = new File(tmpDir, "jaas.conf");
++ FileWriter fwriter = new FileWriter(saslConfFile);
++
++ fwriter.write("" +
++ "Server {\n" +
++ " org.apache.zookeeper.server.auth.DigestLoginModule required\n" +
++ " user_super=\"test\";\n" +
++ "};\n" +
++ "Client {\n" +
++ " org.apache.zookeeper.server.auth.DigestLoginModule required\n" +
++ " username=\"super\"\n" +
++ " password=\"test1\";\n" + // NOTE: wrong password ('test' != 'test1') : this is to test SASL authentication failure.
++ "};" + "\n");
++ fwriter.close();
++ System.setProperty("java.security.auth.login.config",saslConfFile.getAbsolutePath());
++ }
++ catch (IOException e) {
++ // could not create tmp directory to hold JAAS conf file.
++ }
++ }
++
++ private AtomicInteger authFailed = new AtomicInteger(0);
++
++ @Override
++ protected TestableZooKeeper createClient(String hp)
++ throws IOException, InterruptedException
++ {
++ MyWatcher watcher = new MyWatcher();
++ return createClient(watcher, hp);
++ }
++
++ private class MyWatcher extends CountdownWatcher {
++ @Override
++ public synchronized void process(WatchedEvent event) {
++ if (event.getState() == KeeperState.AuthFailed) {
++ synchronized(authFailed) {
++ authFailed.incrementAndGet();
++ authFailed.notify();
++ }
++ }
++ else {
++ super.process(event);
++ }
++ }
++ }
++
++ @Test
++ public void testBadSaslAuthNotifiesWatch() throws Exception {
++ ZooKeeper zk = createClient();
++ // wait for authFailed event from client's EventThread.
++ synchronized(authFailed) {
++ authFailed.wait();
++ }
++ Assert.assertEquals(authFailed.get(),1);
++ zk.close();
++ }
++}
+diff --git src/java/test/org/apache/zookeeper/test/SaslAuthFailTest.java src/java/test/org/apache/zookeeper/test/SaslAuthFailTest.java
+index 1589b1f..33a505e 100644
+--- src/java/test/org/apache/zookeeper/test/SaslAuthFailTest.java
++++ src/java/test/org/apache/zookeeper/test/SaslAuthFailTest.java
+@@ -59,43 +59,6 @@ public class SaslAuthFailTest extends ClientBase {
+ // could not create tmp directory to hold JAAS conf file.
+ }
+ }
+-
+- private AtomicInteger authFailed = new AtomicInteger(0);
+-
+- @Override
+- protected TestableZooKeeper createClient(String hp)
+- throws IOException, InterruptedException
+- {
+- MyWatcher watcher = new MyWatcher();
+- return createClient(watcher, hp);
+- }
+-
+- private class MyWatcher extends CountdownWatcher {
+- @Override
+- public synchronized void process(WatchedEvent event) {
+- if (event.getState() == KeeperState.AuthFailed) {
+- synchronized(authFailed) {
+- authFailed.incrementAndGet();
+- authFailed.notify();
+- }
+- }
+- else {
+- super.process(event);
+- }
+- }
+- }
+-
+- @Test
+- public void testBadSaslAuthNotifiesWatch() throws Exception {
+- ZooKeeper zk = createClient();
+- // wait for authFailed event from client's EventThread.
+- synchronized(authFailed) {
+- authFailed.wait();
+- }
+- Assert.assertEquals(authFailed.get(),1);
+- zk.close();
+- }
+-
+
+ @Test
+ public void testAuthFail() throws Exception {
diff --git a/dead.package b/dead.package
deleted file mode 100644
index 5204a84..0000000
--- a/dead.package
+++ /dev/null
@@ -1 +0,0 @@
-Orphaned for 6+ weeks
diff --git a/sources b/sources
new file mode 100644
index 0000000..0f42bf6
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+f64fef86c0bf2e5e0484d19425b22dcb zookeeper-3.4.5.tar.gz
diff --git a/zookeeper-3.4.4-build.patch b/zookeeper-3.4.4-build.patch
new file mode 100644
index 0000000..609c76e
--- /dev/null
+++ b/zookeeper-3.4.4-build.patch
@@ -0,0 +1,447 @@
+diff -Nru zookeeper-3.4.4/build.xml zookeeper-3.4.4-gil/build.xml
+--- zookeeper-3.4.4/build.xml 2012-09-17 10:34:37.000000000 +0200
++++ zookeeper-3.4.4-gil/build.xml 2012-10-12 17:51:43.676211458 +0200
+@@ -36,7 +36,7 @@
+
+
+
+-
++
+
+
+
+@@ -89,46 +89,28 @@
+
+
+
+-
+-
+-
+-
+-
+
+
+
+
+
+-
+-
++ value="file:/usr/share/java/" />
++
++
+
+
+
+
+
+-
+-
+
+
+
+-
+-
+-
+-
+-
+-
+
+
+
+
+
+
+-
+-
+
+
+
+@@ -198,7 +180,6 @@
+
+
+
+-
+
+
+
+@@ -225,7 +206,7 @@
+
+
+
+-
++
+
+
+
+@@ -312,8 +293,8 @@
+
+
+-
++
+
+
+
+@@ -329,32 +310,20 @@
+
+
+
++ pattern="${ivy.lib}/[artifact].[ext]"/>
+
+
+
+
++ pattern="${ivy.test.lib}/[artifact].[ext]"/>
+
+
+
+
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
++ pattern="${ivy.package.lib}/[artifact].[ext]"/>
+
+
+-
++
+
+
+@@ -498,7 +467,6 @@
+
+
+
+-
+
+
+
+@@ -541,7 +509,6 @@
+
+
+
+-
+
+
+
+@@ -634,7 +601,7 @@
+
+
+
+
+
+@@ -733,7 +700,7 @@
+
+
+
+
+
+@@ -1094,9 +1061,6 @@
+
+
+
+-
+-
+-
+
+
+
+@@ -1260,7 +1224,6 @@
+
+
+
+-
+
+
+
+@@ -1304,50 +1267,6 @@
+
+
+
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+- Clover not found. Code coverage reports disabled.
+-
+-
+-
+-
+-
+- ##################################################################
+- Clover not found.
+- Please make sure clover.jar is in ANT_HOME/lib, or made available
+- to Ant using other mechanisms like -lib or CLASSPATH.
+- ##################################################################
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+
+
+
+@@ -1356,11 +1275,11 @@
+
+
+
++ classpath="${ivy.lib}/ant/ant-findbugs.jar" />
+
+
+-
++
+
+
+
+@@ -1369,7 +1288,7 @@
+
+
+
+-
++
+
+
+
+@@ -1479,51 +1398,6 @@
+
+
+
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+
+
+
+
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+
+
+
+diff -Nru zookeeper-3.4.4/ivysettings.xml zookeeper-3.4.4-gil/ivysettings.xml
+--- zookeeper-3.4.4/ivysettings.xml 2012-09-17 10:34:37.000000000 +0200
++++ zookeeper-3.4.4-gil/ivysettings.xml 2012-10-12 17:02:35.706545077 +0200
+@@ -18,13 +18,13 @@
+ -->
+
+
++ value="file:///usr/share/java/" override="false"/>
+
++ value="file:///usr/share/java/" override="false"/>
+
++ value="file:///usr/share/java/" override="false"/>
+
++ value="[module]"/>
+
+
+
+diff -Nru zookeeper-3.4.4/ivy.xml zookeeper-3.4.4-gil/ivy.xml
+--- zookeeper-3.4.4/ivy.xml 2012-09-17 10:34:37.000000000 +0200
++++ zookeeper-3.4.4-gil/ivy.xml 2012-10-12 17:41:46.216338834 +0200
+@@ -39,36 +39,36 @@
+
+
+
+-
+-
++
++
+
+
+-
+-
++
++
+
+-
++
+
+
+
+-
++
+
+-
+-
++
+-
+
+-
+-
+
+-
++
+
++ rev="" conf="releaseaudit->default"/>
+
++ rev="" conf="releaseaudit->default"/-->
+
+
+
diff --git a/zookeeper-3.4.5-add-PIE-and-RELRO.patch b/zookeeper-3.4.5-add-PIE-and-RELRO.patch
new file mode 100644
index 0000000..7a40d93
--- /dev/null
+++ b/zookeeper-3.4.5-add-PIE-and-RELRO.patch
@@ -0,0 +1,85 @@
+diff -Nru zookeeper-3.4.5/contrib/zktreeutil/src/Makefile.am zookeeper-3.4.5-gil/contrib/zktreeutil/src/Makefile.am
+--- zookeeper-3.4.5/contrib/zktreeutil/src/Makefile.am 2012-09-30 19:53:30.000000000 +0200
++++ zookeeper-3.4.5-gil/contrib/zktreeutil/src/Makefile.am 2013-06-11 18:09:15.097330579 +0200
+@@ -16,7 +16,7 @@
+
+ AM_CXXFLAGS = -I${ZOOKEEPER_PATH}/include -I${ZOOKEEPER_PATH}/generated \
+ -I$(top_srcdir)/include -I${LOG4CXX_INCLUDE} -I/usr/include \
+- -I${XML2_INCLUDE}
++ -I${XML2_INCLUDE} -fPIE
+
+ bin_PROGRAMS = zktreeutil
+
+diff -Nru zookeeper-3.4.5/recipes/lock/src/c/Makefile.am zookeeper-3.4.5-gil/recipes/lock/src/c/Makefile.am
+--- zookeeper-3.4.5/recipes/lock/src/c/Makefile.am 2012-09-30 19:53:31.000000000 +0200
++++ zookeeper-3.4.5-gil/recipes/lock/src/c/Makefile.am 2013-06-11 17:10:22.808629998 +0200
+@@ -17,14 +17,14 @@
+ include $(top_srcdir)/aminclude.am
+
+ AM_CFLAGS = -Wall -fPIC -I${ZOOKEEPER_PATH}/include -I${ZOOKEEPER_PATH}/generated \
+- -I$(top_srcdir)/include -I/usr/include
++ -I$(top_srcdir)/include -I/usr/include -fPIE
+ AM_CPPFLAGS = -Wall -I${ZOOKEEPER_PATH}/include -I${ZOOKEEPER_PATH}/generated\
+- -I${top_srcdir}/include -I/usr/include
++ -I${top_srcdir}/include -I/usr/include -fPIE
+ EXTRA_DIST = LICENSE
+ lib_LTLIBRARIES = libzoolock.la
+ libzoolock_la_SOURCES = src/zoo_lock.c include/zoo_lock.h
+ libzoolock_la_CPPFLAGS = -DDLOPEN_MODULE
+-libzoolock_la_LDFLAGS = -version-info 0:1:0
++libzoolock_la_LDFLAGS = -version-info 0:1:0 -pie -Wl,-z,relro -Wl,-z,now
+
+ #run the tests now
+
+diff -Nru zookeeper-3.4.5/recipes/queue/src/c/Makefile.am zookeeper-3.4.5-gil/recipes/queue/src/c/Makefile.am
+--- zookeeper-3.4.5/recipes/queue/src/c/Makefile.am 2012-09-30 19:53:31.000000000 +0200
++++ zookeeper-3.4.5-gil/recipes/queue/src/c/Makefile.am 2013-06-11 17:09:50.816288611 +0200
+@@ -17,14 +17,14 @@
+ include $(top_srcdir)/aminclude.am
+
+ AM_CFLAGS = -Wall -fPIC -I${ZOOKEEPER_PATH}/include -I${ZOOKEEPER_PATH}/generated \
+- -I$(top_srcdir)/include -I/usr/include
++ -I$(top_srcdir)/include -I/usr/include -fPIE
+ AM_CPPFLAGS = -Wall -I${ZOOKEEPER_PATH}/include -I${ZOOKEEPER_PATH}/generated\
+- -I${top_srcdir}/include -I/usr/include
++ -I${top_srcdir}/include -I/usr/include -fPIE
+ EXTRA_DIST = LICENSE
+ lib_LTLIBRARIES = libzooqueue.la
+ libzooqueue_la_SOURCES = src/zoo_queue.c include/zoo_queue.h
+ libzooqueue_la_CPPFLAGS = -DDLOPEN_MODULE
+-libzooqueue_la_LDFLAGS = -version-info 0:1:0
++libzooqueue_la_LDFLAGS = -version-info 0:1:0 -pie -Wl,-z,relro -Wl,-z,now
+
+ #run the tests now
+
+diff -Nru zookeeper-3.4.5/src/c/Makefile.am zookeeper-3.4.5-gil/src/c/Makefile.am
+--- zookeeper-3.4.5/src/c/Makefile.am 2012-09-30 19:53:31.000000000 +0200
++++ zookeeper-3.4.5-gil/src/c/Makefile.am 2013-06-11 17:02:31.701054099 +0200
+@@ -1,11 +1,11 @@
+ # need this for Doxygen integration
+ include $(top_srcdir)/aminclude.am
+
+-AM_CPPFLAGS = -I${srcdir}/include -I${srcdir}/tests -I${srcdir}/generated
+-AM_CFLAGS = -Wall -Werror
+-AM_CXXFLAGS = -Wall $(USEIPV6)
++AM_CPPFLAGS = -I${srcdir}/include -I${srcdir}/tests -I${srcdir}/generated -fPIE
++AM_CFLAGS = -Wall -Werror -fPIE
++AM_CXXFLAGS = -Wall $(USEIPV6) -fPIE
+
+-LIB_LDFLAGS = -no-undefined -version-info 2
++LIB_LDFLAGS = -no-undefined -version-info 2 -pie -Wl,-z,relro -Wl,-z,now
+
+ pkginclude_HEADERS = include/zookeeper.h include/zookeeper_version.h include/zookeeper_log.h include/proto.h include/recordio.h generated/zookeeper.jute.h
+ EXTRA_DIST=LICENSE
+diff -Nru zookeeper-3.4.5/src/contrib/zktreeutil/src/Makefile.am zookeeper-3.4.5-gil/src/contrib/zktreeutil/src/Makefile.am
+--- zookeeper-3.4.5/src/contrib/zktreeutil/src/Makefile.am 2012-09-30 19:53:32.000000000 +0200
++++ zookeeper-3.4.5-gil/src/contrib/zktreeutil/src/Makefile.am 2013-06-11 18:12:03.908634751 +0200
+@@ -16,7 +16,7 @@
+
+ AM_CXXFLAGS = -I${ZOOKEEPER_PATH}/include -I${ZOOKEEPER_PATH}/generated \
+ -I$(top_srcdir)/include -I${LOG4CXX_INCLUDE} -I/usr/include \
+- -I${XML2_INCLUDE}
++ -I${XML2_INCLUDE} -fPIE
+
+ bin_PROGRAMS = zktreeutil
+
diff --git a/zookeeper-3.4.5-atomic.patch b/zookeeper-3.4.5-atomic.patch
new file mode 100644
index 0000000..570a0ff
--- /dev/null
+++ b/zookeeper-3.4.5-atomic.patch
@@ -0,0 +1,32 @@
+diff -up zookeeper-3.4.5/src/c/src/mt_adaptor.c.atomic zookeeper-3.4.5/src/c/src/mt_adaptor.c
+--- zookeeper-3.4.5/src/c/src/mt_adaptor.c.atomic 2013-06-14 09:58:27.000000000 +0200
++++ zookeeper-3.4.5/src/c/src/mt_adaptor.c 2013-06-14 10:00:09.000000000 +0200
+@@ -482,27 +482,7 @@ int32_t inc_ref_counter(zhandle_t* zh,in
+
+ int32_t fetch_and_add(volatile int32_t* operand, int incr)
+ {
+-#ifndef WIN32
+- int32_t result;
+- asm __volatile__(
+- "lock xaddl %0,%1\n"
+- : "=r"(result), "=m"(*(int *)operand)
+- : "0"(incr)
+- : "memory");
+- return result;
+-#else
+- volatile int32_t result;
+- _asm
+- {
+- mov eax, operand; //eax = v;
+- mov ebx, incr; // ebx = i;
+- mov ecx, 0x0; // ecx = 0;
+- lock xadd dword ptr [eax], ecx;
+- lock xadd dword ptr [eax], ebx;
+- mov result, ecx; // result = ebx;
+- }
+- return result;
+-#endif
++ return __atomic_add_fetch(operand, incr, __ATOMIC_SEQ_CST);
+ }
+
+ // make sure the static xid is initialized before any threads started
diff --git a/zookeeper-3.4.5-build-contrib.patch b/zookeeper-3.4.5-build-contrib.patch
new file mode 100644
index 0000000..8e988aa
--- /dev/null
+++ b/zookeeper-3.4.5-build-contrib.patch
@@ -0,0 +1,133 @@
+diff -Nru zookeeper-3.4.5/src/contrib/build-contrib.xml zookeeper-3.4.5-gil/src/contrib/build-contrib.xml
+--- zookeeper-3.4.5/src/contrib/build-contrib.xml 2012-09-30 19:53:32.000000000 +0200
++++ zookeeper-3.4.5-gil/src/contrib/build-contrib.xml 2013-04-27 11:51:59.684011892 +0200
+@@ -43,9 +43,9 @@
+
+
+
++ value="file:/usr/share/java/" />
+
+-
++
+
+
+
+@@ -70,24 +70,17 @@
+
+
+
+-
+-
+-
+-
++
++
++
++
++
++
++
++
+
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
++
++
+
+
+
+@@ -103,7 +96,7 @@
+
+
+
+-
++
+
+
+
+@@ -133,7 +126,7 @@
+
+
+
+
+@@ -233,15 +226,9 @@
+
+
+
+-
+-
+
+
+
+-
+
+
+
+diff -Nru zookeeper-3.4.5/src/contrib/zooinspector/build.xml zookeeper-3.4.5-gil/src/contrib/zooinspector/build.xml
+--- zookeeper-3.4.5/src/contrib/zooinspector/build.xml 2012-09-30 19:53:32.000000000 +0200
++++ zookeeper-3.4.5-gil/src/contrib/zooinspector/build.xml 2013-04-27 11:42:13.257105341 +0200
+@@ -20,7 +20,7 @@
+
+
+
+-
++
+
+
+
+@@ -37,11 +37,11 @@
+
+
+
+-
++
+
+
+
+-
++
+
+
+
+@@ -55,7 +55,6 @@
+
+
+
+-
+
+
+
+@@ -140,12 +139,12 @@
+
+
+
+-
++
+
+
+
diff --git a/zookeeper-3.4.5-disable-cygwin-detection.patch b/zookeeper-3.4.5-disable-cygwin-detection.patch
new file mode 100644
index 0000000..f639907
--- /dev/null
+++ b/zookeeper-3.4.5-disable-cygwin-detection.patch
@@ -0,0 +1,27 @@
+--- bin/zkServer.sh 2012-09-30 19:53:31.000000000 +0200
++++ bin/zkServer.sh-gil 2013-04-27 11:27:59.972764863 +0200
+@@ -69,15 +69,6 @@
+ ZOOCFG="$2"
+ fi
+
+-if $cygwin
+-then
+- ZOOCFG=`cygpath -wp "$ZOOCFG"`
+- # cygwin has a "kill" in the shell itself, gets confused
+- KILL=/bin/kill
+-else
+- KILL=kill
+-fi
+-
+ echo "Using config: $ZOOCFG" >&2
+
+ if [ -z $ZOOPIDFILE ]; then
+@@ -140,7 +131,7 @@
+ then
+ echo "no zookeeper to stop (could not find file $ZOOPIDFILE)"
+ else
+- $KILL -9 $(cat "$ZOOPIDFILE")
++ kill -9 $(cat "$ZOOPIDFILE")
+ rm "$ZOOPIDFILE"
+ echo STOPPED
+ fi
diff --git a/zookeeper-3.4.5-log4j.patch b/zookeeper-3.4.5-log4j.patch
new file mode 100644
index 0000000..a513ef3
--- /dev/null
+++ b/zookeeper-3.4.5-log4j.patch
@@ -0,0 +1,26 @@
+--- a/conf/log4j.properties 2012-09-30 12:53:31.000000000 -0500
++++ b/conf/log4j.properties 2013-06-25 12:28:56.833948571 -0500
+@@ -1,10 +1,11 @@
+ # Define some default values that can be overridden by system properties
+-zookeeper.root.logger=INFO, CONSOLE
++zookeeper.root.logger=INFO, SYSTEMD
+ zookeeper.console.threshold=INFO
+-zookeeper.log.dir=.
++zookeeper.systemd.threshold=INFO
++zookeeper.log.dir=/var/log/zookeeper
+ zookeeper.log.file=zookeeper.log
+ zookeeper.log.threshold=DEBUG
+-zookeeper.tracelog.dir=.
++zookeeper.tracelog.dir=/var/log/zookeeper
+ zookeeper.tracelog.file=zookeeper_trace.log
+
+ #
+@@ -56,3 +57,8 @@
+ log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
+ ### Notice we are including log4j's NDC here (%x)
+ log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n
++
++log4j.appender.SYSTEMD=org.apache.log4j.ConsoleAppender
++log4j.appender.SYSTEMD.Threshold=${zookeeper.systemd.threshold}
++log4j.appender.SYSTEMD.layout=org.apache.log4j.PatternLayout
++log4j.appender.SYSTEMD.layout.ConversionPattern=[myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n
diff --git a/zookeeper-3.4.5-zktreeutil-gcc.patch b/zookeeper-3.4.5-zktreeutil-gcc.patch
new file mode 100644
index 0000000..7cee0fb
--- /dev/null
+++ b/zookeeper-3.4.5-zktreeutil-gcc.patch
@@ -0,0 +1,10 @@
+--- src/contrib/zktreeutil/src/ZkAdaptor.h 2012-09-30 19:53:32.000000000 +0200
++++ src/contrib/zktreeutil/src/ZkAdaptor.h-gil 2013-04-04 03:37:46.731950855 +0200
+@@ -21,6 +21,7 @@
+
+ #include
+ #include
++#include
+
+ extern "C" {
+ #include "zookeeper.h"
diff --git a/zookeeper-ZooInspector-template.pom b/zookeeper-ZooInspector-template.pom
new file mode 100644
index 0000000..c7b0a3c
--- /dev/null
+++ b/zookeeper-ZooInspector-template.pom
@@ -0,0 +1,48 @@
+
+ 4.0.0
+ org.apache.zookeeper
+ zookeeper-ZooInspector
+ @version@
+
+
+ org.apache.zookeeper
+ zookeeper
+ @version@
+
+
+ org.slf4j
+ slf4j-api
+ any
+
+
+ org.slf4j
+ slf4j-log4j12
+ any
+
+
+ log4j
+ log4j
+ any
+
+
+ org.jboss.netty
+ netty
+ any
+
+
+ jline
+ jline
+ any
+
+
+ com.nitido
+ jtoaster
+ any
+
+
+ xerces
+ xercesImpl
+ any
+
+
+
\ No newline at end of file
diff --git a/zookeeper-test-template.pom b/zookeeper-test-template.pom
new file mode 100644
index 0000000..2c957f4
--- /dev/null
+++ b/zookeeper-test-template.pom
@@ -0,0 +1,48 @@
+
+ 4.0.0
+ org.apache.zookeeper
+ zookeeper-test
+ @version@
+
+
+ org.apache.zookeeper
+ zookeeper
+ @version@
+
+
+ org.slf4j
+ slf4j-api
+ any
+
+
+ org.slf4j
+ slf4j-log4j12
+ any
+
+
+ log4j
+ log4j
+ any
+
+
+ org.jboss.netty
+ netty
+ any
+
+
+ junit
+ junit
+ any
+
+
+ org.mockito
+ mockito-core
+ any
+
+
+ com.puppycrawl.tools
+ checkstyle
+ any
+
+
+
\ No newline at end of file
diff --git a/zookeeper.service b/zookeeper.service
new file mode 100644
index 0000000..e5ae08e
--- /dev/null
+++ b/zookeeper.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=Apache ZooKeeper
+After=network.target
+ConditionPathExists=/etc/zookeeper/zoo.cfg
+ConditionPathExists=/etc/zookeeper/log4j.properties
+ConditionPathExists=/var/lib/zookeeper/data/myid
+
+[Service]
+Type=simple
+User=zookeeper
+SyslogIdentifier=zookeeper
+WorkingDirectory=/var/lib/zookeeper
+UMask=0027
+Environment="CP=/etc/zookeeper:/usr/share/java/slf4j/slf4j-log4j12.jar:/usr/share/java/slf4j/slf4j-api.jar:/usr/share/java/netty.jar:/usr/share/java/log4j.jar:/usr/share/java/jline.jar:/usr/share/java/zookeeper/zookeeper.jar"
+Environment="IPv6=-Djava.net.preferIPv4Stack=false -Djava.net.preferIPv6Addresses=true"
+#Environment="JMX=-Dcom.sun.management.jmxremote"
+ExecStart=/usr/lib/jvm/jre-1.7.0/bin/java -cp $CP $JMX $IPv6 org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/zoo.cfg
+
+[Install]
+WantedBy=multi-user.target
diff --git a/zookeeper.spec b/zookeeper.spec
new file mode 100644
index 0000000..0ed3b80
--- /dev/null
+++ b/zookeeper.spec
@@ -0,0 +1,410 @@
+%global _hardened_build 1
+Name: zookeeper
+Version: 3.4.5
+Release: 9%{?dist}
+Summary: A high-performance coordination service for distributed applications
+Group: Development/Libraries
+License: ASL 2.0 and BSD
+URL: http://zookeeper.apache.org/
+Source0: http://www.apache.org/dist/%{name}/stable/%{name}-%{version}.tar.gz
+Source1: %{name}-test-template.pom
+Source2: %{name}-ZooInspector-template.pom
+Source3: %{name}.service
+# remove non free clover references
+# configure ivy to use system libraries
+# disable rat-lib and jdiff support
+Patch0: %{name}-3.4.4-build.patch
+# https://issues.apache.org/jira/browse/ZOOKEEPER-1557
+Patch1: https://issues.apache.org/jira/secure/attachment/12548109/ZOOKEEPER-1557.patch
+Patch2: %{name}-3.4.5-zktreeutil-gcc.patch
+Patch3: %{name}-3.4.5-disable-cygwin-detection.patch
+Patch4: %{name}-3.4.5-build-contrib.patch
+Patch5: %{name}-3.4.5-add-PIE-and-RELRO.patch
+Patch6: %{name}-3.4.5-atomic.patch
+# remove date/time from console output since journald will keep track of date/time
+Patch7: %{name}-3.4.5-log4j.patch
+
+BuildRequires: autoconf
+BuildRequires: automake
+BuildRequires: boost-devel
+BuildRequires: cppunit-devel
+BuildRequires: dos2unix
+BuildRequires: doxygen
+BuildRequires: graphviz
+BuildRequires: java-devel
+BuildRequires: java-javadoc
+BuildRequires: jpackage-utils
+BuildRequires: libtool
+BuildRequires: libxml2-devel
+BuildRequires: log4cxx-devel
+BuildRequires: python-devel
+
+BuildRequires: ant
+BuildRequires: ant-junit
+BuildRequires: apache-ivy
+BuildRequires: checkstyle
+BuildRequires: jline
+BuildRequires: jtoaster
+BuildRequires: junit
+BuildRequires: log4j
+BuildRequires: mockito
+BuildRequires: netty
+BuildRequires: slf4j
+BuildRequires: xerces-j2
+BuildRequires: xml-commons-apis
+
+# BuildRequires: rat-lib
+# BuildRequires: apache-rat-tasks
+# BuildRequires: apache-commons-collections
+# BuildRequires: apache-commons-lang
+# BuildRequires: jdiff
+
+BuildRequires: systemd
+
+%description
+ZooKeeper is a centralized service for maintaining configuration information,
+naming, providing distributed synchronization, and providing group services.
+
+%package lib
+Summary: Zookeeper C client library
+Group: System Environment/Libraries
+
+%description lib
+ZooKeeper C client library for communicating with ZooKeeper Server.
+
+%package lib-devel
+Summary: Development files for the %{name} library
+Group: Development/Libraries
+Requires: %{name}-lib%{?_isa} = %{version}-%{release}
+
+%description lib-devel
+Development files for the ZooKeeper C client library.
+
+%package lib-doc
+Summary: Documentation for the %{name} library
+Group: Documentation
+BuildArch: noarch
+
+%description lib-doc
+Documentation for the ZooKeeper C client library.
+
+%package java
+Group: Development/Libraries
+Summary: Zookeeper Java client library
+# Requires: felix-framework
+# Requires: felix-osgi-compendium
+Requires: checkstyle
+Requires: jline
+Requires: jtoaster
+Requires: junit
+Requires: log4j
+Requires: mockito
+Requires: netty
+Requires: slf4j
+
+Requires: java
+Requires: jpackage-utils
+BuildArch: noarch
+
+%description java
+This package provides a Java client interface to Zookeeper server.
+
+%package javadoc
+Group: Documentation
+Summary: Javadoc for %{name}
+BuildArch: noarch
+
+%description javadoc
+This package contains javadoc for %{name}.
+
+%package -n python-ZooKeeper
+Group: Development/Libraries
+Summary: ZooKeeper python binding library
+Requires: %{name}-lib%{?_isa} = %{version}-%{release}
+Provides: zkpython%{?_isa} = %{version}-%{release}
+
+%description -n python-ZooKeeper
+ZooKeeper python binding library
+
+%package server
+Group: System Environment/Daemons
+Summary: ZooKeeper server
+Requires: %{name}-java = %{version}-%{release}
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+Requires(pre): shadow-utils
+BuildArch: noarch
+
+%description server
+ZooKeeper server
+
+%prep
+%setup -q
+find -name "*.jar" -delete
+find -name "*.class" -delete
+find -name "*.cmd" -delete
+find -name "*.so*" -delete
+find -name "*.dll" -delete
+
+%patch0 -p1
+%patch1 -p0
+%pom_remove_dep org.vafer:jdeb dist-maven/%{name}-%{version}.pom
+# jdiff task deps
+%pom_remove_dep jdiff:jdiff dist-maven/%{name}-%{version}.pom
+%pom_remove_dep xerces:xerces dist-maven/%{name}-%{version}.pom
+# rat-lib task deps
+%pom_remove_dep org.apache.rat:apache-rat-tasks dist-maven/%{name}-%{version}.pom
+%pom_remove_dep commons-collections:commons-collections dist-maven/%{name}-%{version}.pom
+%pom_remove_dep commons-lang:commons-lang dist-maven/%{name}-%{version}.pom
+
+%patch2 -p0
+%patch3 -p0
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+
+sed -i "s|pom|jar|" dist-maven/%{name}-%{version}.pom
+sed -i "s|checkstyle|com.puppycrawl.tools|" dist-maven/%{name}-%{version}.pom
+sed -i "s|mockito-all|mockito-core|" dist-maven/%{name}-%{version}.pom
+
+cp -p %{SOURCE1} dist-maven/%{name}-%{version}-test.pom
+cp -p %{SOURCE2} dist-maven/%{name}-%{version}-ZooInspector.pom
+sed -i "s|@version@|%{version}|" dist-maven/%{name}-%{version}-test.pom dist-maven/%{name}-%{version}-ZooInspector.pom
+
+iconv -f iso8859-1 -t utf-8 src/c/ChangeLog > src/c/ChangeLog.conv && mv -f src/c/ChangeLog.conv src/c/ChangeLog
+sed -i 's/\r//' src/c/ChangeLog
+
+# fix build problem on f18
+sed -i 's|||' build.xml
+sed -i 's|||' build.xml
+
+sed -i 's@^dataDir=.*$@dataDir=%{_sharedstatedir}/zookeeper/data\ndataLogDir=%{_sharedstatedir}/zookeeper/log@' conf/zoo_sample.cfg
+
+%build
+
+# ensure that source and target are 1.5
+%ant -Dtarget.jdk=1.5 \
+ -Djavadoc.link.java=%{_javadocdir}/java \
+ -Dant.build.javac.source=1.5 \
+ -Dant.build.javac.target=1.5 \
+ build-generated jar test-jar javadoc javadoc-dev
+
+(
+cd src/contrib
+%ant -Dversion=%{version} \
+ -Dcontribfilesetincludes="zooinspector/build.xml" \
+ -Dant.build.javac.source=1.5 \
+ -Dant.build.javac.target=1.5 \
+ -Dtarget.jdk=1.5 \
+ -DlastRevision=-1 \
+ -Divy.jar.exists=true \
+ -Divy.initialized=true \
+ -Ddest.dir=../../build/zookeeper
+)
+
+pushd src/c
+rm -rf autom4te.cache
+autoreconf -fis
+
+%configure --disable-static --disable-rpath --with-syncapi
+# Remove rpath
+sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
+sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
+%{__make} %{?_smp_mflags}
+make doxygen-doc
+popd
+
+# Compile zktreeutil
+pushd src/contrib/zktreeutil
+rm -rf autom4te.cache
+autoreconf -if
+%configure
+%{__make} %{?_smp_mflags}
+popd
+
+%if 0
+%check
+# Execute multi-threaded test suite
+mkdir -p build/lib
+for jar in jline log4j xerces-j2 xml-commons-apis; do \
+ln -sf %{_javadir}/$jar.jar build/lib/$jar.jar; \
+done
+pushd src/c
+%{__make} %{?_smp_mflags} zktest-mt
+./zktest-mt
+popd
+%ifarch i386
+# Run core Java test suite against zookeeper
+ant -Dversion=%{version} -DlastRevision=-1 test-core-java
+%endif
+%endif
+
+%install
+
+mkdir -p %{buildroot}%{_javadir}/%{name}
+install -pm 644 build/%{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}/%{name}.jar
+install -pm 644 build/%{name}-%{version}-test.jar %{buildroot}%{_javadir}/%{name}/%{name}-test.jar
+install -pm 644 build/contrib/ZooInspector/%{name}-ZooInspector-%{version}.jar %{buildroot}%{_javadir}/%{name}/%{name}-ZooInspector.jar
+
+mkdir -p %{buildroot}%{_mavenpomdir}
+install -pm 644 dist-maven/%{name}-%{version}.pom %{buildroot}%{_mavenpomdir}/JPP.%{name}-%{name}.pom
+%add_maven_depmap JPP.%{name}-%{name}.pom %{name}/%{name}.jar
+install -pm 644 dist-maven/%{name}-%{version}-test.pom %{buildroot}%{_mavenpomdir}/JPP.%{name}-%{name}-test.pom
+%add_maven_depmap JPP.%{name}-%{name}-test.pom %{name}/%{name}-test.jar
+install -pm 644 dist-maven/%{name}-%{version}-ZooInspector.pom %{buildroot}%{_mavenpomdir}/JPP.%{name}-%{name}-ZooInspector.pom
+%add_maven_depmap JPP.%{name}-%{name}-ZooInspector.pom %{name}/%{name}-ZooInspector.jar
+
+mkdir -p %{buildroot}%{_javadocdir}/%{name}/dev
+cp -pr build/docs/api/* %{buildroot}%{_javadocdir}/%{name}/
+cp -pr build/docs/dev-api/* %{buildroot}%{_javadocdir}/%{name}/dev/
+
+pushd src/c
+%{__make} install DESTDIR=%{buildroot}
+# cleanup
+rm -f docs/html/*.map
+popd
+
+pushd src/contrib/zktreeutil
+%{__make} install DESTDIR=%{buildroot}
+popd
+
+pushd src/contrib/zkpython
+%{__python} src/python/setup.py build --build-base=$PWD/build \
+install --root=%{buildroot} ;\
+chmod 0755 %{buildroot}%{python_sitearch}/zookeeper.so
+popd
+
+find %{buildroot} -name '*.la' -exec rm -f {} ';'
+
+mkdir -p %{buildroot}%{_unitdir}
+mkdir -p %{buildroot}%{_sysconfdir}/zookeeper
+mkdir -p %{buildroot}%{_localstatedir}/log/zookeeper
+mkdir -p %{buildroot}%{_sharedstatedir}/zookeeper
+mkdir -p %{buildroot}%{_sharedstatedir}/zookeeper/data
+mkdir -p %{buildroot}%{_sharedstatedir}/zookeeper/log
+install -p -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}
+install -p -m 0640 conf/log4j.properties %{buildroot}%{_sysconfdir}/zookeeper
+install -p -m 0640 conf/zoo_sample.cfg %{buildroot}%{_sysconfdir}/zookeeper
+touch %{buildroot}%{_sysconfdir}/zookeeper/zoo.cfg
+touch %{buildroot}%{_sharedstatedir}/zookeeper/data/myid
+
+# TODO
+# bin/zkCleanup.sh
+# bin/zkCli.sh
+# bin/zkEnv.sh
+
+%post lib -p /sbin/ldconfig
+%postun lib -p /sbin/ldconfig
+
+%pre server
+getent group zookeeper >/dev/null || groupadd -r zookeeper
+getent passwd zookeeper >/dev/null || \
+ useradd -r -g zookeeper -d %{_sharedstatedir}/zookeeper -s /sbin/nologin \
+ -c "ZooKeeper service account" zookeeper
+%post server
+%systemd_post zookeeper.service
+
+%preun server
+%systemd_preun zookeeper.service
+
+%postun server
+%systemd_postun_with_restart zookeeper.service
+
+%files
+%{_bindir}/cli_mt
+%{_bindir}/cli_st
+%{_bindir}/load_gen
+%{_bindir}/zktreeutil
+%doc src/c/ChangeLog src/c/LICENSE src/c/NOTICE.txt src/c/README src/contrib/zktreeutil/README.txt
+
+%files lib
+%{_libdir}/lib*.so.*
+%doc src/c/LICENSE src/c/NOTICE.txt
+
+%files lib-devel
+%dir %{_includedir}/%{name}
+%{_includedir}/%{name}/*.h
+%{_libdir}/*.so
+%doc src/c/LICENSE src/c/NOTICE.txt
+
+%files lib-doc
+%doc src/c/LICENSE src/c/NOTICE.txt src/c/docs/html/*
+
+%files java
+%dir %{_javadir}/%{name}
+%{_javadir}/%{name}/%{name}.jar
+%{_javadir}/%{name}/%{name}-test.jar
+%{_javadir}/%{name}/%{name}-ZooInspector.jar
+%{_mavenpomdir}/JPP.%{name}-%{name}.pom
+%{_mavenpomdir}/JPP.%{name}-%{name}-test.pom
+%{_mavenpomdir}/JPP.%{name}-%{name}-ZooInspector.pom
+%{_mavendepmapfragdir}/%{name}
+%doc CHANGES.txt LICENSE.txt NOTICE.txt README.txt
+
+%files javadoc
+%{_javadocdir}/%{name}
+%doc LICENSE.txt NOTICE.txt
+
+%files -n python-ZooKeeper
+%{python_sitearch}/ZooKeeper-?.?-py%{python_version}.egg-info
+%{python_sitearch}/zookeeper.so
+%doc LICENSE.txt NOTICE.txt src/contrib/zkpython/README
+
+%files server
+%attr(0755,root,root) %dir %{_sysconfdir}/zookeeper
+%attr(0644,root,root) %ghost %config(noreplace) %{_sysconfdir}/zookeeper/zoo.cfg
+%attr(0644,root,root) %{_sysconfdir}/zookeeper/zoo_sample.cfg
+%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/zookeeper/log4j.properties
+
+%attr(0750,zookeeper,zookeeper) %dir %{_localstatedir}/log/zookeeper
+%attr(0755,root,root) %dir %{_sharedstatedir}/zookeeper
+%attr(0750,zookeeper,zookeeper) %dir %{_sharedstatedir}/zookeeper/data
+%attr(0640,zookeeper,zookeeper) %ghost %{_sharedstatedir}/zookeeper/data/myid
+%attr(0750,zookeeper,zookeeper) %dir %{_sharedstatedir}/zookeeper/log
+%{_unitdir}/zookeeper.service
+
+%changelog
+* Mon Jun 22 2013 Timothy St. Clair - 3.4.5-9
+- revert old sematics defattr and update permissions
+
+* Mon Jun 22 2013 Timothy St. Clair - 3.4.5-8
+- cleanup file ownership properties.
+
+* Tue Jun 15 2013 Jeffrey C. Ollie - 3.4.5-7
+- add server subpackage
+
+* Fri Jun 14 2013 Dan Horák - 3.4.5-6
+- use fetch_and_add from GCC, fixes build on non-x86 arches
+
+* Tue Jun 11 2013 gil cattaneo 3.4.5-5
+- fixed zookeeper.so non-standard-executable-perm thanks to Björn Esser
+
+* Tue Jun 11 2013 gil cattaneo 3.4.5-4
+- enabled hardened-builds
+- fixed fully versioned dependency in subpackages (lib-devel and python)
+- fixed License tag
+- moved large documentation in lib-doc subpackage
+
+* Sat Apr 27 2013 gil cattaneo 3.4.5-3
+- built ZooInspector
+- added additional poms files
+
+* Tue Apr 23 2013 gil cattaneo 3.4.5-2
+- building/packaging of the zookeeper-test.jar thanks to Robert Rati
+
+* Sun Dec 02 2012 gil cattaneo 3.4.5-1
+- update to 3.4.5
+
+* Tue Oct 30 2012 gil cattaneo 3.4.4-3
+- fix missing hostname
+
+* Fri Oct 12 2012 gil cattaneo 3.4.4-2
+- add ant-junit as BR
+
+* Fri Oct 12 2012 gil cattaneo 3.4.4-1
+- update to 3.4.4
+
+* Fri May 18 2012 gil cattaneo 3.4.3-1
+- initial rpm