You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ph...@apache.org on 2011/08/11 21:18:47 UTC

svn commit: r1156752 - in /zookeeper/trunk: ./ bin/ src/contrib/ src/contrib/zkpython/ src/contrib/zkpython/src/packages/ src/contrib/zkpython/src/packages/deb/ src/contrib/zkpython/src/packages/deb/zkpython.control/ src/contrib/zkpython/src/packages/r...

Author: phunt
Date: Thu Aug 11 19:18:45 2011
New Revision: 1156752

URL: http://svn.apache.org/viewvc?rev=1156752&view=rev
Log:
ZOOKEEPER-999. Create an package integration project (Eric Yang via phunt)

Added:
    zookeeper/trunk/README_packaging.txt
    zookeeper/trunk/src/contrib/zkpython/ivy.xml
    zookeeper/trunk/src/contrib/zkpython/src/packages/
    zookeeper/trunk/src/contrib/zkpython/src/packages/deb/
    zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/
    zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control
    zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/
    zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/
    zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec
    zookeeper/trunk/src/packages/
    zookeeper/trunk/src/packages/deb/
    zookeeper/trunk/src/packages/deb/init.d/
    zookeeper/trunk/src/packages/deb/init.d/zookeeper
    zookeeper/trunk/src/packages/deb/zookeeper.control/
    zookeeper/trunk/src/packages/deb/zookeeper.control/conffile
    zookeeper/trunk/src/packages/deb/zookeeper.control/control
    zookeeper/trunk/src/packages/deb/zookeeper.control/postinst
    zookeeper/trunk/src/packages/deb/zookeeper.control/postrm
    zookeeper/trunk/src/packages/deb/zookeeper.control/preinst
    zookeeper/trunk/src/packages/deb/zookeeper.control/prerm
    zookeeper/trunk/src/packages/rpm/
    zookeeper/trunk/src/packages/rpm/init.d/
    zookeeper/trunk/src/packages/rpm/init.d/zookeeper
    zookeeper/trunk/src/packages/rpm/spec/
    zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec
    zookeeper/trunk/src/packages/templates/
    zookeeper/trunk/src/packages/templates/conf/
    zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh
    zookeeper/trunk/src/packages/update-zookeeper-env.sh
Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/bin/zkCleanup.sh
    zookeeper/trunk/bin/zkCli.sh
    zookeeper/trunk/bin/zkEnv.sh
    zookeeper/trunk/bin/zkServer.sh
    zookeeper/trunk/build.xml
    zookeeper/trunk/ivy.xml
    zookeeper/trunk/src/contrib/build-contrib.xml
    zookeeper/trunk/src/contrib/build.xml
    zookeeper/trunk/src/contrib/zkpython/build.xml
    zookeeper/trunk/src/contrib/zkpython/src/python/setup.py
    zookeeper/trunk/src/recipes/build-recipes.xml
    zookeeper/trunk/src/recipes/build.xml
    zookeeper/trunk/src/recipes/lock/build.xml
    zookeeper/trunk/src/recipes/queue/build.xml

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Thu Aug 11 19:18:45 2011
@@ -399,6 +399,9 @@ NEW FEATURES:
 
   ZOOKEEPER-992. MT Native Version of Windows C Client (Dheeraj Agrawal via michim)
 
+  ZOOKEEPER-999. Create an package integration project
+  (Eric Yang via phunt)
+
 Release 3.3.0 - 2010-03-24
 
 Non-backward compatible changes:

Added: zookeeper/trunk/README_packaging.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/README_packaging.txt?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/README_packaging.txt (added)
+++ zookeeper/trunk/README_packaging.txt Thu Aug 11 19:18:45 2011
@@ -0,0 +1,65 @@
+README file for Packaging Notes
+
+Requirement
+-----------
+
+gcc, cppunit and python-setuptools are required to build 
+C and python bindings.
+
+On RHEL machine:
+
+yum install cppunit
+yum install python-setuptools
+
+On Ubuntu:
+
+apt-get --install cppunit
+apt-get --install python-setuptools
+
+Package build command
+---------------------
+
+Command to build Debian package: ant deb
+Command to build RPM Package: ant rpm
+
+rpm and deb packages are generated and placed in:
+
+build/zookeeper*.[rpm|deb]
+build/contrib/**.[rpm|deb]
+
+Default package file structure layout
+
+  /usr/bin                           - User executable
+  /usr/sbin                          - System executable
+  /usr/libexec                       - Configuration boot trap script
+  /usr/lib                           - Native libraries
+  /usr/share/doc/zookeeper           - Documents
+  /usr/share/zookeeper               - Project files
+  /usr/share/zookeeper/template/conf - Configuration template files
+  /etc/zookeeper                     - Configuration files
+  /etc/init.d/zookeeper              - OS startup script
+
+Source file structure layout
+---------------------
+
+src/packages/update-zookeeper-env.sh 
+  - setup environment variables and symlink $PREFIX/etc/zookeeper to 
+    /etc/zookeeper.
+  - This script is designed to run in post installation, and pre-remove 
+    phase of ZooKeeper package.
+  - Run update-zookeeper-env.sh -h to get a list of supported parameters.
+
+src/packages/template
+  - Standard configuration template
+
+src/packages/deb 
+  Meta data for creating Debian package
+
+src/packages/deb/init.d
+  Daemon start/stop script for Debian flavor of Linux
+
+src/packages/rpm 
+  Meta data for creating RPM package
+
+src/packages/rpm/init.d
+  Daemon start/stop script for Redhat flavor of Linux

Modified: zookeeper/trunk/bin/zkCleanup.sh
URL: http://svn.apache.org/viewvc/zookeeper/trunk/bin/zkCleanup.sh?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/bin/zkCleanup.sh (original)
+++ zookeeper/trunk/bin/zkCleanup.sh Thu Aug 11 19:18:45 2011
@@ -25,16 +25,16 @@
 # relative to the canonical path of this script.
 #
 
-# Only follow symlinks if readlink supports it
-if readlink -f "$0" > /dev/null 2>&1
-then
-  ZOOBIN=`readlink -f "$0"`
+# use POSTIX interface, symlink is followed automatically
+ZOOBIN="${BASH_SOURCE-$0}"
+ZOOBIN=`dirname ${ZOOBIN}`
+ZOOBINDIR=`cd ${ZOOBIN}; pwd`
+
+if [ -e "$ZOOBIN/../libexec/zkEnv.sh" ]; then
+  . "$ZOOBINDIR"/../libexec/zkEnv.sh
 else
-  ZOOBIN="$0"
+  . "$ZOOBINDIR"/zkEnv.sh
 fi
-ZOOBINDIR=`dirname "$ZOOBIN"`
-
-. "$ZOOBINDIR"/zkEnv.sh
 
 ZOODATADIR=$(grep "^[[:space:]]*dataDir=" "$ZOOCFG" | sed -e 's/.*=//')
 ZOODATALOGDIR=$(grep "^[[:space:]]*dataLogDir=" "$ZOOCFG" | sed -e 's/.*=//')

Modified: zookeeper/trunk/bin/zkCli.sh
URL: http://svn.apache.org/viewvc/zookeeper/trunk/bin/zkCli.sh?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/bin/zkCli.sh (original)
+++ zookeeper/trunk/bin/zkCli.sh Thu Aug 11 19:18:45 2011
@@ -25,16 +25,16 @@
 # relative to the canonical path of this script.
 #
 
-# Only follow symlinks if readlink supports it
-if readlink -f "$0" > /dev/null 2>&1
-then
-  ZOOBIN=`readlink -f "$0"`
+# use POSTIX interface, symlink is followed automatically
+ZOOBIN="${BASH_SOURCE-$0}"
+ZOOBIN=`dirname ${ZOOBIN}`
+ZOOBINDIR=`cd ${ZOOBIN}; pwd`
+
+if [ -e "$ZOOBIN/../libexec/zkEnv.sh" ]; then
+  . "$ZOOBINDIR"/../libexec/zkEnv.sh
 else
-  ZOOBIN="$0"
+  . "$ZOOBINDIR"/zkEnv.sh
 fi
-ZOOBINDIR=`dirname "$ZOOBIN"`
-
-. "$ZOOBINDIR"/zkEnv.sh
 
 $JAVA "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
      -cp "$CLASSPATH" $CLIENT_JVMFLAGS $JVMFLAGS \

Modified: zookeeper/trunk/bin/zkEnv.sh
URL: http://svn.apache.org/viewvc/zookeeper/trunk/bin/zkEnv.sh?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/bin/zkEnv.sh (original)
+++ zookeeper/trunk/bin/zkEnv.sh Thu Aug 11 19:18:45 2011
@@ -22,9 +22,21 @@
 # otherwise we use /etc/zookeeper
 # or the conf directory that is
 # a sibling of this script's directory
+
+ZOOBINDIR=${ZOOBINDIR:-/usr/bin}
+ZOOKEEPER_PREFIX=${ZOOBINDIR}/..
+
 if [ "x$ZOOCFGDIR" = "x" ]
 then
+  if [ -e "${ZOOKEEPER_PREFIX}/conf" ]; then
     ZOOCFGDIR="$ZOOBINDIR/../conf"
+  else
+    ZOOCFGDIR="$ZOOBINDIR/../etc/zookeeper"
+  fi
+fi
+
+if [ -f "${ZOOCFGDIR}/zookeeper-env.sh" ]; then
+  . "${ZOOCFGDIR}/zookeeper-env.sh"
 fi
 
 if [ "x$ZOOCFG" = "x" ]
@@ -64,13 +76,13 @@ do
 done
 
 #make it work in the release
-for i in "$ZOOBINDIR"/../lib/*.jar
-do
-    CLASSPATH="$i:$CLASSPATH"
-done
+if [ -d ${ZOOKEEPER_PREFIX}/share/zookeeper ]; then
+  LIBPATH="${ZOOKEEPER_PREFIX}"/share/zookeeper/*.jar
+else
+  LIBPATH="${ZOOBINDIR}"/../lib/*.jar
+fi
 
-#make it work in the release
-for i in "$ZOOBINDIR"/../zookeeper-*.jar
+for i in ${LIBPATH}
 do
     CLASSPATH="$i:$CLASSPATH"
 done

Modified: zookeeper/trunk/bin/zkServer.sh
URL: http://svn.apache.org/viewvc/zookeeper/trunk/bin/zkServer.sh?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/bin/zkServer.sh (original)
+++ zookeeper/trunk/bin/zkServer.sh Thu Aug 11 19:18:45 2011
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -42,16 +42,16 @@ else
     ZOOMAIN="org.apache.zookeeper.server.quorum.QuorumPeerMain"
 fi
 
-# Only follow symlinks if readlink supports it
-if readlink "$0" > /dev/null 2>&1
-then
-  ZOOBIN=`readlink "$0"`
+# use POSTIX interface, symlink is followed automatically
+ZOOBIN="${BASH_SOURCE-$0}"
+ZOOBIN=`dirname ${ZOOBIN}`
+ZOOBINDIR=`cd ${ZOOBIN}; pwd`
+
+if [ -e "$ZOOBIN/../libexec/zkEnv.sh" ]; then
+  . "$ZOOBINDIR"/../libexec/zkEnv.sh
 else
-  ZOOBIN="$0"
+  . "$ZOOBINDIR"/zkEnv.sh
 fi
-ZOOBINDIR=`dirname "$ZOOBIN"`
-
-. "$ZOOBINDIR"/zkEnv.sh
 
 if [ "x$SERVER_JVMFLAGS" ]
 then

Modified: zookeeper/trunk/build.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/build.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/build.xml (original)
+++ zookeeper/trunk/build.xml Thu Aug 11 19:18:45 2011
@@ -103,6 +103,7 @@
               value="http://repo2.maven.org/maven2/org/apache/ivy/ivy" />
     <property name="ivy.home" value="${user.home}/.ant" />
     <property name="ivy.lib" value="${build.dir}/lib"/>
+    <property name="ivy.package.lib" value="${build.dir}/package/lib"/>
     <property name="ivy.test.lib" value="${build.dir}/test/lib"/>
     <property name="ivy.jdiff.lib" value="${build.dir}/jdiff/lib"/>
     <property name="ivysettings.xml" value="${basedir}/ivysettings.xml"/>
@@ -150,6 +151,20 @@
     <property name="build.dir.eclipse-main-classes" value="${build.dir.eclipse}/classes-main"/>
     <property name="build.dir.eclipse-test-classes" value="${build.dir.eclipse}/classes-test"/>
 
+    <!-- cppunit property set -->
+    <property name="cppunit.lib" value="/usr/lib"/>
+    <property name="cppunit.m4" value="/usr/share/aclocal"/>
+
+    <!-- packaging property set -->
+    <property name="package.release" value="1"/>
+    <property name="package.prefix" value="/usr"/>
+    <property name="package.conf.dir" value="/etc/zookeeper"/>
+    <property name="package.log.dir" value="/var/log/zookeeper"/>
+    <property name="package.pid.dir" value="/var/run/zookeeper"/>
+    <property name="package.var.dir" value="/var/lib/zookeeper"/>
+    <property name="package.share.dir" value="/share/zookeeper"/>
+    <property name="package.buildroot" value="/tmp/zookeeper_package_build_${user.name}"/>
+    <property name="package.build.dir" value="/tmp/zookeeper_package_build_${user.name}/BUILD"/>
 
     <!-- ====================================================== -->
     <!-- Macro definitions                                      -->
@@ -194,6 +209,12 @@
       <path refid="java.classpath"/>
     </path>
 
+    <path id="package.classpath">
+      <fileset dir="${ivy.package.lib}">
+        <include name="**/jdeb*.jar" />
+      </fileset>
+    </path>
+
     <!-- ====================================================== -->
     <!-- Generate and compile the Java files                    -->
     <!-- ====================================================== -->
@@ -201,6 +222,7 @@
         <mkdir dir="${build.classes}" />
 
         <mkdir dir="${ivy.lib}"/>
+        <mkdir dir="${ivy.package.lib}"/>
         <mkdir dir="${ivy.test.lib}"/>
         <condition property="ivy.jar.exists">
           <available file="${lib.dir}/ivy-${ivy.version}.jar"/>
@@ -313,6 +335,11 @@
                     pattern="${ivy.test.lib}/[artifact]-[revision].[ext]"/>
     </target>
 
+    <target name="ivy-retrieve-package" depends="init,ivy-init">
+      <ivy:retrieve settingsRef="${ant.project.name}" conf="package"
+                    pattern="${ivy.package.lib}/[artifact]-[revision].[ext]"/>
+    </target>
+
     <target name="ivy-retrieve-jdiff" depends="init,ivy-init">
       <mkdir dir="${ivy.jdiff.lib}"/>
       <ivy:retrieve settingsRef="${ant.project.name}" type="jar" conf="jdiff"
@@ -346,6 +373,29 @@
       </javac>
     </target>
 
+    <target name="compile-native" depends="compile_jute" description="Make C binding">
+      <exec executable="autoreconf" dir="${c.src.dir}" searchpath="yes"
+            failonerror="yes">
+        <arg value="-if"/>
+        <env key="ACLOCAL" value="aclocal -I ${cppunit.m4}"/>
+      </exec>
+      <mkdir dir="${build.dir}/c" />
+      <exec executable="${c.src.dir}/configure" dir="${build.dir}/c"
+            failonerror="yes">
+        <env key="base_dir" value="${basedir}"/>
+        <env key="CALLER" value="ANT"/>
+        <arg value="--prefix=${build.dir}/c/build/${package.prefix}"/>
+      </exec>
+      <property name="c.build" value="${build.dir}/c/build"/>
+      <exec dir="${build.dir}/c" executable="make" failonerror="true">
+        <arg value="install"/>
+        <env key="LD_LIBRARY_PATH" value="${c.build}"/>
+        <env key="PATH" path="${env.PATH};${c.src.dir};"/>
+        <env key="CALLER" value="ANT"/>
+        <env key="base_dir" value="${basedir}"/>
+      </exec>
+    </target>
+
     <!-- ====================================================== -->
     <!-- Documentation                                          -->
     <!-- ====================================================== -->
@@ -581,24 +631,29 @@
     <!--                                                                    -->
     <!-- ================================================================== -->
     <target name="package"
-            depends="jar,bin-jar,src-jar,javadoc-jar,test-jar,api-report,create-cppunit-configure,compile-test"
+            depends="jar,bin-jar,src-jar,javadoc-jar,test-jar,api-report,create-cppunit-configure,compile-native,compile-test"
             description="Build distribution">
       <mkdir dir="${dist.dir}"/>
       <mkdir dir="${dist.dir}/lib"/>
-      <mkdir dir="${dist.dir}/contrib"/>
-      <mkdir dir="${dist.dir}/recipes"/>
+      <mkdir dir="${dist.dir}/libexec"/>
+      <mkdir dir="${dist.dir}/share/zookeeper/contrib"/>
+      <mkdir dir="${dist.dir}/share/zookeeper/recipes"/>
       <mkdir dir="${dist.dir}/bin"/>
       <mkdir dir="${dist.dir}/docs"/>
       <mkdir dir="${dist.dir}/docs/jdiff"/>
       <mkdir dir="${dist.dir}/docs/api"/>
+      <mkdir dir="${dist.dir}/share/zookeeper/templates/conf"/>
+      <mkdir dir="${dist.dir}/sbin"/>
 
-      <copy todir="${dist.dir}/lib" includeEmptyDirs="false">
+      <copy todir="${dist.dir}/share/zookeeper" includeEmptyDirs="false">
         <fileset dir="${lib.dir}">
           <exclude name="**/ivy*.jar" />
+          <exclude name="**/deb*.jar" />
         </fileset>
         <fileset dir="${ivy.lib}"/>
       </copy>
 
+      <copy file="${basedir}/src/packages/update-zookeeper-env.sh" tofile="${dist.dir}/sbin/update-zookeeper-env.sh"/>
       <subant target="package">
         <!--Pass down the version in case its needed again and the target
             distribution directory so contribs know where to install to.-->
@@ -608,12 +663,12 @@
         <fileset file="${recipes.dir}/build.xml"/>
       </subant>  	
 
-      <copy todir="${dist.dir}"> 
+      <copy todir="${dist.dir}/share/zookeeper"> 
         <fileset file="${build.dir}/${final.name}.jar"/>
       </copy>
 
-      <checksum file="${dist.dir}/${final.name}.jar" algorithm="md5"/>
-      <checksum file="${dist.dir}/${final.name}.jar" algorithm="sha1"/>
+      <checksum file="${dist.dir}/share/zookeeper/${final.name}.jar" algorithm="md5"/>
+      <checksum file="${dist.dir}/share/zookeeper/${final.name}.jar" algorithm="sha1"/>
 
       <mkdir dir="${dist.maven.dir}"/>
 
@@ -655,7 +710,15 @@
 
 
       <copy todir="${dist.dir}/bin">
-        <fileset dir="bin"/>
+        <fileset dir="bin" includes="zkCli*"/>
+      </copy>
+
+      <copy todir="${dist.dir}/libexec">
+        <fileset dir="bin" includes="zkEnv*"/>
+      </copy>
+
+      <copy todir="${dist.dir}/sbin">
+        <fileset dir="bin" includes="zkServer*"/>
       </copy>
 
       <copy todir="${dist.dir}/conf">
@@ -679,9 +742,20 @@
       <copy todir="${dist.dir}/src" includeEmptyDirs="true">
         <fileset dir="src" excludes="**/*.template **/docs/build/**/* **/ivy*.jar"/>
       </copy>
+
+      <copy todir="${dist.dir}/${package.share.dir}/templates/conf">
+        <fileset dir="src/packages/templates/conf"/>
+      </copy>
+
+      <copy file="${basedir}/conf/zoo_sample.cfg" tofile="${dist.dir}/${package.share.dir}/templates/conf/zoo.cfg" />
+      <replace file="${dist.dir}/${package.share.dir}/templates/conf/zoo.cfg">
+        <replacetoken>/tmp/zookeeper</replacetoken>
+        <replacevalue>${VAR_DIR}/data</replacevalue>
+      </replace>
   	  
       <chmod perm="ugo+x" type="file" parallel="false">
         <fileset dir="${dist.dir}/bin"/>
+        <fileset dir="${dist.dir}/sbin"/>
         <fileset dir="${dist.dir}/src/contrib/">
           <include name="*/bin/*" />
         </fileset>
@@ -756,6 +830,157 @@
       </macro_tar>
     </target>
 
+    <target name="package-native" depends="compile-native, package" description="Make C binding tarball">
+      <!-- For Unix platforms only, use OS native tar to preserve symlinks -->
+      <exec executable="tar" dir="${build.dir}/c/build">
+        <arg value="cfzv" />
+        <arg value="${build.dir}/${final.name}-lib.tar.gz" />
+        <arg value="." />
+      </exec>
+      <subant target="package">
+        <!--Pass down the version in case its needed again and the target
+            distribution directory so contribs know where to install to.-->
+        <property name="version" value="${version}"/>
+        <property name="dist.dir" value="${dist.dir}"/>
+        <fileset file="${contrib.dir}/build.xml"/>
+        <fileset file="${recipes.dir}/build.xml"/>
+      </subant>
+    </target>
+
+    <target name="rpm" depends="package-native, tar" description="Make rpm package">
+      <subant target="rpm">
+        <!--Pass down the version in case its needed again and the target
+            distribution directory so contribs know where to install to.-->
+        <property name="version" value="${version}"/>
+        <property name="dist.dir" value="${dist.dir}"/>
+        <fileset file="${contrib.dir}/build.xml"/>
+        <fileset file="${recipes.dir}/build.xml"/>
+      </subant>  	
+      <path id="c.lib">
+        <fileset dir="${build.dir}">
+          <include name="${final.name}-lib.tar.gz"/>
+        </fileset>
+      </path>
+      <property name="c.lib" refid="c.lib"/>
+      <mkdir dir="${package.buildroot}/BUILD" />
+      <mkdir dir="${package.buildroot}/RPMS" />
+      <mkdir dir="${package.buildroot}/SRPMS" />
+      <mkdir dir="${package.buildroot}/SOURCES" />
+      <mkdir dir="${package.buildroot}/SPECS" />
+      <copy todir="${package.buildroot}/SOURCES">
+        <fileset dir="${build.dir}">
+          <include name="${final.name}.tar.gz" />
+        </fileset>
+        <fileset file="${c.lib}" />
+      </copy>
+      <copy file="${src.dir}/packages/rpm/spec/zookeeper.spec" todir="${package.buildroot}/SPECS">
+        <filterchain>
+          <replacetokens>
+            <token key="final.name" value="${final.name}" />
+            <token key="version" value="${version}" />
+            <token key="package.release" value="${package.release}" />
+            <token key="package.build.dir" value="${package.build.dir}" />
+            <token key="package.prefix" value="${package.prefix}" />
+            <token key="package.conf.dir" value="${package.conf.dir}" />
+            <token key="package.log.dir" value="${package.log.dir}" />
+            <token key="package.pid.dir" value="${package.pid.dir}" />
+            <token key="package.var.dir" value="${package.var.dir}" />
+            <token key="c.lib" value="${c.lib}" />
+          </replacetokens>
+        </filterchain>
+      </copy>
+      <rpm specFile="zookeeper.spec" command="-ba" topDir="${package.buildroot}" cleanBuildDir="true" failOnError="true"
+/>
+      <copy todir="${build.dir}/" flatten="true">
+        <fileset dir="${package.buildroot}/RPMS">
+          <include name="**/${name}*.rpm" />
+        </fileset>
+        <fileset dir="${package.buildroot}/SRPMS">
+          <include name="**/${name}*.rpm" />
+        </fileset>
+      </copy>
+      <delete dir="${package.buildroot}" quiet="true" verbose="false"/>
+    </target>
+
+    <target name="deb" depends="ivy-retrieve-package, package-native, tar" description="Make deb package">
+      <subant target="deb">
+        <!--Pass down the version in case its needed again and the target
+            distribution directory so contribs know where to install to.-->
+        <property name="version" value="${version}"/>
+        <property name="dist.dir" value="${dist.dir}"/>
+        <fileset file="${contrib.dir}/build.xml"/>
+        <fileset file="${recipes.dir}/build.xml"/>
+      </subant>
+      <taskdef name="deb" classname="org.vafer.jdeb.ant.DebAntTask">
+        <classpath refid="java.classpath"/>
+        <classpath refid="package.classpath"/>
+      </taskdef>
+
+      <mkdir dir="${package.build.dir}/zookeeper.control" />
+      <copy todir="${package.buildroot}/${package.prefix}">
+        <fileset dir="${build.dir}/${final.name}">
+          <include name="bin/**" />
+          <include name="conf/**" />
+          <include name="sbin/**" />
+          <include name="share/**" />
+        </fileset>
+      </copy>
+      <copy todir="${package.build.dir}/zookeeper.control">
+        <fileset dir="${src.dir}/packages/deb/zookeeper.control">
+          <exclude name="control" />
+        </fileset>
+      </copy>
+      <copy file="${src.dir}/packages/deb/zookeeper.control/control" todir="${package.build.dir}/zookeeper.control">
+        <filterchain>
+          <replacetokens>
+            <token key="final.name" value="${final.name}" />
+            <token key="version" value="${version}" />
+            <token key="package.release" value="${package.release}" />
+            <token key="package.build.dir" value="${package.build.dir}" />
+            <token key="package.prefix" value="${package.prefix}" />
+            <token key="package.conf.dir" value="${package.conf.dir}" />
+            <token key="package.log.dir" value="${package.log.dir}" />
+            <token key="package.pid.dir" value="${package.pid.dir}" />
+            <token key="package.var.dir" value="${package.var.dir}" />
+          </replacetokens>
+        </filterchain>
+      </copy>
+      <deb destfile="${package.buildroot}/${name}_${version}-${package.release}_${os.arch}.deb" control="${package.build.dir}/zookeeper.control">
+        <tarfileset dir="${build.dir}/${final.name}/share/zookeeper" filemode="644" prefix="${package.prefix}/share/zookeeper">
+          <include name="**" />
+        </tarfileset>
+        <tarfileset dir="${build.dir}/${final.name}/bin" filemode="755" prefix="${package.prefix}/bin">
+          <include name="zkCli.sh" />
+        </tarfileset>
+        <tarfileset dir="${build.dir}/${final.name}/sbin" filemode="755" prefix="${package.prefix}/sbin">
+          <include name="**.sh" />
+        </tarfileset>
+        <tarfileset dir="${build.dir}/${final.name}/libexec" filemode="755" prefix="${package.prefix}/libexec">
+          <include name="zkEnv.sh" />
+        </tarfileset>
+        <tarfileset dir="${build.dir}/c/build/${package.prefix}/include" prefix="${package.prefix}/include">
+          <include name="**" />
+        </tarfileset> 
+        <tarfileset dir="${build.dir}/c/build/${package.prefix}/lib" filemode="755" prefix="${package.prefix}/lib">
+          <include name="**" />
+        </tarfileset> 
+        <tarfileset dir="${build.dir}/${final.name}/conf" filemode="644" prefix="${package.conf.dir}">
+          <include name="**" />
+        </tarfileset>
+        <tarfileset dir="${build.dir}/${final.name}/src/packages/deb/init.d" filemode="755" prefix="/etc/init.d">
+          <include name="**" />
+        </tarfileset>
+      </deb>
+
+      <copy todir="${build.dir}/" flatten="true">
+        <fileset dir="${package.buildroot}">
+          <include name="**/${name}*.deb" />
+        </fileset>
+      </copy>
+      <delete dir="${package.buildroot}" quiet="true" verbose="false"/>
+
+    </target>
+
     <!-- ====================================================== -->
     <!-- Clean.  Delete the build files, and their directories  -->
     <!-- ====================================================== -->
@@ -774,6 +999,7 @@
       <delete>
         <fileset dir="${basedir}" includes="*.jar,*.tar.gz"/>
       </delete>
+      <delete dir="${package.buildroot}" />
     </target>
 
     <target name="clean-contrib">
@@ -896,6 +1122,7 @@
       <exec executable="autoreconf" dir="${c.src.dir}" searchpath="yes"
             failonerror="yes">
         <arg value="-if"/>
+        <env key="ACLOCAL" value="aclocal -I ${cppunit.m4}"/>
       </exec>
     </target>
 
@@ -925,9 +1152,8 @@
             depends="compile_jute, jar, create-cppunit-makefile"
             if="cppunit"
 		description="to run cppunit test cases">
-        <property name="lib.cppunit" value="/usr/local/lib"/>
         <exec dir="${test.cppunit.dir}" executable="make" failonerror="true">
-		<env key="LD_LIBRARY_PATH" value="${lib.cppunit}"/>
+		<env key="LD_LIBRARY_PATH" value="${cppunit.lib}"/>
 		<env key="PATH" path="${env.PATH};${c.src.dir};"/>
                 <env key="CALLER" value="ANT"/>
                 <env key="CLOVER_HOME" value="${clover.home}"/>

Modified: zookeeper/trunk/ivy.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/ivy.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/ivy.xml (original)
+++ zookeeper/trunk/ivy.xml Thu Aug 11 19:18:45 2011
@@ -26,14 +26,16 @@
   </info>
 
   <configurations defaultconfmapping="default">
+    <conf name="master"/>
     <conf name="default"/>
     <conf name="test"/>
+    <conf name="package" extends="master"/>
     <conf name="jdiff" visibility="private"/>
     <conf name="releaseaudit" visibility="private" description="Artifacts required for releaseaudit target"/>
   </configurations>
 
   <publications>
-    <artifact name='org.jboss.netty' type='jar' ext='jar' />
+    <artifact name='org.apache.zookeeper' type='jar' ext='jar' />
   </publications>
 
   <dependencies>
@@ -48,6 +50,8 @@
       <artifact name="netty" type="jar" conf="default"/>
     </dependency>
 
+    <dependency org="org.vafer" name="jdeb" rev="0.8" conf="package->master"/>
+
     <dependency org="junit" name="junit" rev="4.8.1" conf="test->default"/>
     <dependency org="checkstyle" name="checkstyle" rev="5.0"
                 conf="test->default"/>

Modified: zookeeper/trunk/src/contrib/build-contrib.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/build-contrib.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/src/contrib/build-contrib.xml (original)
+++ zookeeper/trunk/src/contrib/build-contrib.xml Thu Aug 11 19:18:45 2011
@@ -153,6 +153,28 @@
     </copy>
   </target>
 
+  <!-- ====================================================== -->
+  <!-- Package a contrib's files                              -->
+  <!-- ====================================================== -->
+  <target name="package-native" depends="jar" unless="skip.contrib">
+    <echo message="contrib: ${name}"/>
+  </target>
+
+  <!-- ====================================================== -->
+  <!-- rpm a contrib's files                                  -->
+  <!-- ====================================================== -->
+  <target name="rpm" depends="jar" unless="skip.contrib"> 
+    <echo message="contrib: ${name}"/>
+
+  </target>
+
+  <!-- ====================================================== -->
+  <!-- deb a contrib's files                                  -->
+  <!-- ====================================================== -->
+  <target name="deb" depends="jar" unless="skip.contrib"> 
+    <echo message="contrib: ${name}"/>
+
+  </target>
   <!-- ================================================================== -->
   <!-- Clean.  Delete the build files, and their directories              -->
   <!-- ================================================================== -->

Modified: zookeeper/trunk/src/contrib/build.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/build.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/src/contrib/build.xml (original)
+++ zookeeper/trunk/src/contrib/build.xml Thu Aug 11 19:18:45 2011
@@ -48,7 +48,7 @@
       <fileset refid="contribfileset" />
     </subant>
   </target>
-  
+
   <!-- ====================================================== -->
   <!-- Test all the contribs.                               -->
   <!-- ====================================================== -->
@@ -68,4 +68,21 @@
     </subant>
   </target>
 
+  <!-- ====================================================== -->
+  <!-- rpm all the contribs.                                  -->
+  <!-- ====================================================== -->
+  <target name="rpm">
+    <subant target="rpm">
+      <fileset refid="contribfileset" />
+    </subant>
+  </target>
+
+  <!-- ====================================================== -->
+  <!-- deb all the contribs.                                  -->
+  <!-- ====================================================== -->
+  <target name="deb">
+    <subant target="deb">
+      <fileset refid="contribfileset" />
+    </subant>
+  </target>
 </project>

Modified: zookeeper/trunk/src/contrib/zkpython/build.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/build.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/src/contrib/zkpython/build.xml (original)
+++ zookeeper/trunk/src/contrib/zkpython/build.xml Thu Aug 11 19:18:45 2011
@@ -25,6 +25,10 @@
   <property name="test.log.dir" value="${build.test}/logs" />
   <property name="test.output" value="no" />
   <property name="test.timeout" value="900000" />
+  <property name="package.buildroot" value="/tmp/zkpython_build_${user.name}"/>
+  <property name="package.build.dir" value="/tmp/zkpython_build_${user.name}/BUILD"/>
+  <property name="package.release" value="1"/>
+  <property name="package.prefix" value="/usr"/>
 
   <target name="test"
           depends="compile,test-init,test-category,test-start,python-test,test-stop" />
@@ -57,7 +61,7 @@
       </exec>
     </target>
 
-    <target name="compile">
+    <target name="compile" depends="ivy-retrieve">
       <exec executable="python" failonerror="true">
         <arg value="${python.src.dir}/setup.py"/>
         <arg value="build"/>
@@ -74,7 +78,7 @@
       </exec>
     </target>
 
-    <target name="package" unless="skip.contrib">
+    <target name="package" depends="compile" unless="skip.contrib">
       <echo message="contrib: ${name}"/>
 
       <mkdir dir="${build.dir}"/>
@@ -94,5 +98,98 @@
         </fileset>
       </copy>
     </target>
+
+    <target name="tar-bin" depends="init, compile" unless="skip.contrib">
+      <exec executable="python" failonerror="true" dir="${build.dir}">
+        <arg value="${python.src.dir}/setup.py"/>
+        <arg value="build"/>
+        <arg value="--build-base=${build.dir}"/>
+        <arg value="bdist_dumb"/>
+      </exec>
+    </target>
+
+    <target name="rpm" depends="tar-bin" unless="skip.contrib">
+      <mkdir dir="${package.buildroot}/BUILD" />
+      <mkdir dir="${package.buildroot}/RPMS" />
+      <mkdir dir="${package.buildroot}/SRPMS" />
+      <mkdir dir="${package.buildroot}/SOURCES" />
+      <mkdir dir="${package.buildroot}/SPECS" />
+      <copy todir="${package.buildroot}/SOURCES">
+        <fileset dir="${build.dir}/dist">
+          <include name="*.tar.gz" />
+        </fileset>
+      </copy>
+      <path id="python.lib">
+        <fileset dir="${package.buildroot}/SOURCES">
+          <include name="*.tar.gz" />
+        </fileset>
+      </path>
+      <property name="python.lib" refid="python.lib" />
+      <copy file="${src.dir}/../packages/rpm/spec/${name}.spec" todir="${package.buildroot}/SPECS">
+        <filterchain>
+          <replacetokens>
+            <token key="final.name" value="${name}" />
+            <token key="version" value="${version}" />
+            <token key="package.release" value="${package.release}" />
+            <token key="package.build.dir" value="${package.build.dir}" />
+            <token key="package.prefix" value="${package.prefix}" />
+            <token key="python.lib" value="${python.lib}" />
+          </replacetokens>
+        </filterchain>
+      </copy>
+
+      <rpm specFile="${name}.spec" command="-ba" topDir="${package.buildroot}" cleanBuildDir="true" failOnError="true" />
+      <copy todir="${build.dir}/" flatten="true">
+        <fileset dir="${package.buildroot}/RPMS">
+          <include name="**/*.rpm" />
+        </fileset>
+      </copy>
+      <delete dir="${package.buildroot}" quiet="true" verbose="false" />
+    </target>
+
+    <target name="deb" depends="tar-bin" unless="skip.contrib">
+      <mkdir dir="${package.buildroot}" />
+      <mkdir dir="${package.buildroot}/BUILD" />
+      <mkdir dir="${package.buildroot}/SPECS" />
+      <copy todir="${package.buildroot}/SOURCES">
+        <fileset dir="${build.dir}/dist">
+          <include name="*.tar.gz" />
+        </fileset>
+      </copy>
+      <path id="python.lib">
+        <fileset dir="${package.buildroot}/SOURCES">
+          <include name="*.tar.gz" />
+        </fileset>
+      </path>
+      <property name="python.lib" refid="python.lib" />
+      <copy todir="${package.build.dir}/zkpython.control">
+        <fileset dir="${src.dir}/../packages/deb/zkpython.control">
+          <exclude name="control" />
+        </fileset>
+      </copy>
+      <copy file="${src.dir}/../packages/deb/zkpython.control/control" todir="${package.build.dir}/zkpython.control">
+        <filterchain>
+          <replacetokens>
+            <token key="final.name" value="${name}" />
+            <token key="version" value="${version}" />
+            <token key="package.release" value="${package.release}" />
+            <token key="package.build.dir" value="${package.build.dir}" />
+            <token key="package.prefix" value="${package.prefix}" />
+          </replacetokens>
+        </filterchain>
+      </copy>
+      <taskdef name="deb" classname="org.vafer.jdeb.ant.DebAntTask">
+        <classpath refid="classpath"/>
+      </taskdef>
+      <deb destfile="${package.buildroot}/${name}_${version}-${package.release}_${os.arch}.deb" control="${package.build.dir}/zkpython.control">
+        <data src="${python.lib}" />
+      </deb>
+      <copy todir="${build.dir}/" flatten="true">
+        <fileset dir="${package.buildroot}">
+          <include name="**/${name}_*.deb" />
+        </fileset>
+      </copy>
+      <delete dir="${package.buildroot}" quiet="true" verbose="false"/>
+    </target>
 </project>
 

Added: zookeeper/trunk/src/contrib/zkpython/ivy.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/ivy.xml?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/contrib/zkpython/ivy.xml (added)
+++ zookeeper/trunk/src/contrib/zkpython/ivy.xml Thu Aug 11 19:18:45 2011
@@ -0,0 +1,43 @@
+<!--
+   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.
+-->
+
+<ivy-module version="2.0"
+            xmlns:e="http://ant.apache.org/ivy/extra">
+
+  <info organisation="org.apache.zookeeper"
+        module="${name}" revision="${version}">
+    <license name="Apache 2.0"/>
+    <ivyauthor name="Apache ZooKeeper" url="http://zookeeper.apache.org"/>
+    <description>ZKPython</description>
+  </info>
+
+  <configurations defaultconfmapping="default">
+    <conf name="default"/>
+    <conf name="test"/>
+    <conf name="jdiff" visibility="private"/>
+    <conf name="releaseaudit" visibility="private" description="Artifacts required for releaseaudit target"/>
+  </configurations>
+
+  <dependencies>
+
+    <dependency org="org.vafer" name="jdeb" rev="0.8">
+      <artifact name="jdeb" type="jar" conf="default"/>
+    </dependency>
+
+  </dependencies>
+
+</ivy-module>

Added: zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control (added)
+++ zookeeper/trunk/src/contrib/zkpython/src/packages/deb/zkpython.control/control Thu Aug 11 19:18:45 2011
@@ -0,0 +1,23 @@
+# 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: zkpython
+Version: @version@
+Section: misc
+Priority: optional
+Architecture: all
+Depends: python
+Maintainer: Apache Software Foundation <de...@zookeeper.apache.org>
+Description: ZooKeeper python binding library
+Distribution: development

Added: zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec (added)
+++ zookeeper/trunk/src/contrib/zkpython/src/packages/rpm/spec/zkpython.spec Thu Aug 11 19:18:45 2011
@@ -0,0 +1,82 @@
+#   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.
+
+#
+# RPM Spec file for ZooKeeper version @version@
+#
+
+%define name         zkpython
+%define version      @version@
+%define release      @package.release@
+
+# Installation Locations
+%define _prefix      @package.prefix@
+
+# Build time settings
+%define _build_dir    @package.build.dir@
+%define _final_name   @final.name@
+%define _python_lib   @python.lib@
+%define debug_package %{nil}
+
+# Disable brp-java-repack-jars for aspect J
+%define __os_install_post    \
+    /usr/lib/rpm/redhat/brp-compress \
+    %{!?__debug_package:/usr/lib/rpm/redhat/brp-strip %{__strip}} \
+    /usr/lib/rpm/redhat/brp-strip-static-archive %{__strip} \
+    /usr/lib/rpm/redhat/brp-strip-comment-note %{__strip} %{__objdump} \
+    /usr/lib/rpm/brp-python-bytecompile %{nil}
+
+# RPM searches perl files for dependancies and this breaks for non packaged perl lib
+# like thrift so disable this
+%define _use_internal_dependency_generator 0
+
+Summary: ZooKeeper python binding library
+Group: Development/Libraries
+License: Apache License, Version 2.0
+URL: http://zookeeper.apache.org/
+Vendor: Apache Software Foundation
+Name: %{name}
+Version: %{version}
+Release: %{release} 
+Source0: %{_python_lib}
+Prefix: %{_prefix}
+Buildroot: %{_build_dir}
+Requires: zookeeper-lib == %{version}
+AutoReqProv: no
+Provides: zkpython
+
+%description
+ZooKeeper python binding library
+
+%prep
+tar fxz %{_python_lib} -C %{_build_dir}
+
+%build
+
+#########################
+#### INSTALL SECTION ####
+#########################
+%install
+
+%pre
+
+%post
+
+%preun
+
+%files 
+%defattr(-,root,root)
+%{_prefix}
+

Modified: zookeeper/trunk/src/contrib/zkpython/src/python/setup.py
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/contrib/zkpython/src/python/setup.py?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/src/contrib/zkpython/src/python/setup.py (original)
+++ zookeeper/trunk/src/contrib/zkpython/src/python/setup.py Thu Aug 11 19:18:45 2011
@@ -21,9 +21,11 @@ zookeeper_basedir = "../../../"
 zookeepermodule = Extension("zookeeper",
                             sources=["src/c/zookeeper.c"],
                             include_dirs=[zookeeper_basedir + "/src/c/include",
+                                          zookeeper_basedir + "/build/c",
                                           zookeeper_basedir + "/src/c/generated"],
                             libraries=["zookeeper_mt"],
                             library_dirs=[zookeeper_basedir + "/src/c/.libs/",
+                                          zookeeper_basedir + "/build/c/.libs/",
                                           zookeeper_basedir + "/build/test/test-cppunit/.libs",
                                           "/usr/local/lib"
                                           ])

Added: zookeeper/trunk/src/packages/deb/init.d/zookeeper
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/init.d/zookeeper?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/deb/init.d/zookeeper (added)
+++ zookeeper/trunk/src/packages/deb/init.d/zookeeper Thu Aug 11 19:18:45 2011
@@ -0,0 +1,129 @@
+#! /bin/sh
+
+# 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.
+
+### BEGIN INIT INFO
+# Provides:		zookeeper
+# Required-Start:	$remote_fs $syslog
+# Required-Stop:	$remote_fs $syslog
+# Default-Start:	2 3 4 5
+# Default-Stop:		
+# Short-Description:	Apache ZooKeeper server
+### END INIT INFO
+
+set -e
+
+# /etc/init.d/zookeeper: start and stop the Apache ZooKeeper daemon
+
+umask 022
+
+. /usr/libexec/zkEnv.sh
+
+. /lib/lsb/init-functions
+
+ZOOPIDFILE=/var/lib/zookeeper/data/zookeeper_server.pid
+
+# Are we running from init?
+run_by_init() {
+    ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
+}
+
+check_for_no_start() {
+    # forget it if we're trying to start, and /etc/zookeeper/zookeeper_not_to_be_run exists
+    if [ -e /etc/zookeeper/zookeeper_not_to_be_run ]; then 
+	if [ "$1" = log_end_msg ]; then
+	    log_end_msg 0
+	fi
+	if ! run_by_init; then
+	    log_action_msg "Apache ZooKeeper server not in use (/etc/zookeeper/zookeeper_not_to_be_run)"
+	fi
+	exit 0
+    fi
+}
+
+export PATH="${PATH:+$PATH:}/usr/sbin:/usr/bin"
+
+case "$1" in
+  start)
+	check_for_no_start
+	log_daemon_msg "Starting Apache ZooKeeper server" "zookeeper"
+	if start-stop-daemon --start --quiet --oknodo --pidfile ${ZOOPIDFILE} -c zookeeper -x ${ZOOKEEPER_PREFIX}/sbin/zkServer.sh start; then
+	    log_end_msg 0
+	else
+	    log_end_msg 1
+	fi
+	;;
+  stop)
+	log_daemon_msg "Stopping Apache ZooKeeper server" "zookeeper"
+	if start-stop-daemon --stop --quiet --oknodo --pidfile ${ZOOPIDFILE}; then
+	    log_end_msg 0
+	else
+	    log_end_msg 1
+	fi
+	;;
+
+  restart)
+	check_privsep_dir
+	log_daemon_msg "Restarting Apache ZooKeeper server" "zookeeper"
+	start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile ${ZOOPIDFILE}
+	check_for_no_start log_end_msg
+	if start-stop-daemon --start --quiet --oknodo --pidfile ${ZOOPIDFILE} -c zookeeper -x ${ZOOKEEPER_PREFIX}/bin/zkServer.sh start; then
+	    log_end_msg 0
+	else
+	    log_end_msg 1
+	fi
+	;;
+
+  try-restart)
+	check_privsep_dir
+	log_daemon_msg "Restarting Apache ZooKeeper server" "zookeeper"
+	set +e
+	start-stop-daemon --stop --quiet --retry 30 --pidfile ${ZOOPIDFILE}
+	RET="$?"
+	set -e
+	case $RET in
+	    0)
+		# old daemon stopped
+		check_for_no_start log_end_msg
+		if start-stop-daemon --start --quiet --oknodo --pidfile ${ZOOPIDFILE} -c zookeeper -x ${ZOOKEEPER_PREFIX}/bin/zkServer.sh start; then
+		    log_end_msg 0
+		else
+		    log_end_msg 1
+		fi
+		;;
+	    1)
+		# daemon not running
+		log_progress_msg "(not running)"
+		log_end_msg 0
+		;;
+	    *)
+		# failed to stop
+		log_progress_msg "(failed to stop)"
+		log_end_msg 1
+		;;
+	esac
+	;;
+
+  status)
+	status_of_proc -p ${ZOOPIDFILE} ${JAVA_HOME}/bin/java zookeeper && exit 0 || exit $?
+	;;
+
+  *)
+	log_action_msg "Usage: /etc/init.d/zookeeper {start|stop|restart|try-restart|status}"
+	exit 1
+esac
+
+exit 0

Added: zookeeper/trunk/src/packages/deb/zookeeper.control/conffile
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/conffile?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/deb/zookeeper.control/conffile (added)
+++ zookeeper/trunk/src/packages/deb/zookeeper.control/conffile Thu Aug 11 19:18:45 2011
@@ -0,0 +1,15 @@
+# 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.
+/etc/zookeeper

Added: zookeeper/trunk/src/packages/deb/zookeeper.control/control
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/control?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/deb/zookeeper.control/control (added)
+++ zookeeper/trunk/src/packages/deb/zookeeper.control/control Thu Aug 11 19:18:45 2011
@@ -0,0 +1,23 @@
+# 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: zookeeper
+Version: @version@
+Section: misc
+Priority: optional
+Architecture: all
+Depends: sun-java6-jre
+Maintainer: Apache Software Foundation <de...@zookeeper.apache.org>
+Description: ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services.
+Distribution: development

Added: zookeeper/trunk/src/packages/deb/zookeeper.control/postinst
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/postinst?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/deb/zookeeper.control/postinst (added)
+++ zookeeper/trunk/src/packages/deb/zookeeper.control/postinst Thu Aug 11 19:18:45 2011
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# 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.
+
+bash /usr/sbin/update-zookeeper-env.sh \
+  --prefix=/usr \
+  --conf-dir=/etc/zookeeper \
+  --log-dir=/var/log/zookeeper \
+  --pid-dir=/var/run/zookeeper \
+  --var-dir=/var/lib/zookeeper

Added: zookeeper/trunk/src/packages/deb/zookeeper.control/postrm
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/postrm?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/deb/zookeeper.control/postrm (added)
+++ zookeeper/trunk/src/packages/deb/zookeeper.control/postrm Thu Aug 11 19:18:45 2011
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# 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.
+
+/usr/sbin/userdel zookeeper 2> /dev/null >/dev/null
+exit 0

Added: zookeeper/trunk/src/packages/deb/zookeeper.control/preinst
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/preinst?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/deb/zookeeper.control/preinst (added)
+++ zookeeper/trunk/src/packages/deb/zookeeper.control/preinst Thu Aug 11 19:18:45 2011
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# 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.
+
+getent group hadoop 2>/dev/null >/dev/null || /usr/sbin/groupadd -r hadoop
+
+/usr/sbin/useradd --comment "ZooKeeper" --shell /bin/bash -M -r --groups hadoop --home /usr/share/zookeeper zookeeper 2> /dev/null || :

Added: zookeeper/trunk/src/packages/deb/zookeeper.control/prerm
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/deb/zookeeper.control/prerm?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/deb/zookeeper.control/prerm (added)
+++ zookeeper/trunk/src/packages/deb/zookeeper.control/prerm Thu Aug 11 19:18:45 2011
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# 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.
+
+/etc/init.d/zookeeper stop 2>/dev/null >/dev/null
+bash /usr/sbin/update-zookeeper-env.sh \
+  --prefix=/usr \
+  --conf-dir=/etc/zookeeper \
+  --log-dir=/var/log/zookeeper \
+  --pid-dir=/var/run/zookeeper \
+  --uninstal

Added: zookeeper/trunk/src/packages/rpm/init.d/zookeeper
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/rpm/init.d/zookeeper?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/rpm/init.d/zookeeper (added)
+++ zookeeper/trunk/src/packages/rpm/init.d/zookeeper Thu Aug 11 19:18:45 2011
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+# 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.
+
+# 
+# ZooKeeper
+# 
+# chkconfig: 2345 89 9 
+# description: zookeeper
+
+source /etc/rc.d/init.d/functions
+source /usr/libexec/zkEnv.sh
+
+RETVAL=0
+PIDFILE="${ZOOPIDFILE}"
+desc="ZooKeeper daemon"
+
+start() {
+  echo -n $"Starting $desc (zookeeper): "
+  daemon --user zookeeper zkServer.sh start
+  RETVAL=$?
+  echo
+  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zookeeper
+  return $RETVAL
+}
+
+stop() {
+  echo -n $"Stopping $desc (zookeeper): "
+  daemon --user zookeeper zkServer.sh stop
+  RETVAL=$?
+  sleep 5
+  echo
+  [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zookeeper $PIDFILE
+}
+
+restart() {
+  stop
+  start
+}
+
+checkstatus(){
+  status -p $PIDFILE ${JAVA_HOME}/bin/java
+  RETVAL=$?
+}
+
+condrestart(){
+  [ -e /var/lock/subsys/zookeeper ] && restart || :
+}
+
+case "$1" in
+  start)
+    start
+    ;;
+  stop)
+    stop
+    ;;
+  status)
+    checkstatus
+    ;;
+  restart)
+    restart
+    ;;
+  condrestart)
+    condrestart
+    ;;
+  *)
+    echo $"Usage: $0 {start|stop|status|restart|condrestart}"
+    exit 1
+esac
+
+exit $RETVAL

Added: zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec (added)
+++ zookeeper/trunk/src/packages/rpm/spec/zookeeper.spec Thu Aug 11 19:18:45 2011
@@ -0,0 +1,167 @@
+#   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.
+
+#
+# RPM Spec file for ZooKeeper version @version@
+#
+
+%define name         zookeeper
+%define version      @version@
+%define release      @package.release@
+
+# Installation Locations
+%define _prefix      @package.prefix@
+%define _bin_dir     %{_prefix}/bin
+%define _conf_dir    @package.conf.dir@
+%define _include_dir %{_prefix}/include
+%define _lib_dir     %{_prefix}/lib
+%define _lib64_dir   %{_prefix}/lib64
+%define _libexec_dir %{_prefix}/libexec
+%define _log_dir     @package.log.dir@
+%define _man_dir     %{_prefix}/man
+%define _pid_dir     @package.pid.dir@
+%define _sbin_dir    %{_prefix}/sbin
+%define _share_dir   %{_prefix}/share/zookeeper
+%define _src_dir     %{_prefix}/src
+%define _var_dir     @package.var.dir@
+
+# Build time settings
+%define _build_dir    @package.build.dir@
+%define _final_name   @final.name@
+%define _c_lib        @c.lib@
+%define debug_package %{nil}
+
+# Disable brp-java-repack-jars for aspect J
+%define __os_install_post    \
+    /usr/lib/rpm/redhat/brp-compress \
+    %{!?__debug_package:/usr/lib/rpm/redhat/brp-strip %{__strip}} \
+    /usr/lib/rpm/redhat/brp-strip-static-archive %{__strip} \
+    /usr/lib/rpm/redhat/brp-strip-comment-note %{__strip} %{__objdump} \
+    /usr/lib/rpm/brp-python-bytecompile %{nil}
+
+# RPM searches perl files for dependancies and this breaks for non packaged perl lib
+# like thrift so disable this
+%define _use_internal_dependency_generator 0
+
+Summary: ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services.
+License: Apache License, Version 2.0
+URL: http://zookeeper.apache.org/
+Vendor: Apache Software Foundation
+Group: Development/Libraries
+Name: %{name}
+Version: %{version}
+Release: %{release} 
+Source0: %{_final_name}.tar.gz
+Source1: %{_final_name}-lib.tar.gz
+Prefix: %{_prefix}
+Prefix: %{_conf_dir}
+Prefix: %{_log_dir}
+Prefix: %{_pid_dir}
+Prefix: %{_var_dir}
+Buildroot: %{_build_dir}
+Requires: sh-utils, textutils, /usr/sbin/useradd, /usr/sbin/usermod, /sbin/chkconfig, /sbin/service, jdk >= 1.6
+AutoReqProv: no
+Provides: zookeeper
+
+%description
+ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications. Each time they are implemented there is a lot of work that goes into fixing the bugs and race conditions that are inevitable. Because of the difficulty of implementing these kinds of services, applications initially usually skimp on them ,which make them brittle in the presence of change and difficult to manage. Even when done correctly, different implementations of these services lead to management complexity when the applications are deployed.
+
+%package lib
+Summary: ZooKeeper C binding library
+Group: System/Libraries
+#Requires: %{name} == %{version}
+Provides: zookeeper-lib
+
+%description lib
+ZooKeeper C client library for communicating with ZooKeeper Server.
+
+%prep
+%setup -D -b 1 -n %{_final_name}
+%setup -D -a 0 -n %{_final_name}
+
+%build
+mkdir -p ${RPM_BUILD_DIR}%{_prefix}
+mkdir -p ${RPM_BUILD_DIR}%{_bin_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_include_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_lib_dir}
+%ifarch amd64 x86_64
+mkdir -p ${RPM_BUILD_DIR}%{_lib64_dir}
+%endif
+mkdir -p ${RPM_BUILD_DIR}%{_libexec_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_log_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_conf_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_man_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_pid_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_sbin_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_share_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_var_dir}
+mkdir -p ${RPM_BUILD_DIR}/etc/init.d
+
+cp ${RPM_BUILD_DIR}/%{_final_name}/src/packages/rpm/init.d/zookeeper ${RPM_BUILD_DIR}/etc/init.d/zookeeper
+cp ${RPM_BUILD_DIR}/%{_final_name}/src/packages/update-zookeeper-env.sh ${RPM_BUILD_DIR}/%{_final_name}/sbin/update-zookeeper-env.sh
+chmod 0755 ${RPM_BUILD_DIR}/%{_final_name}/sbin/*
+chmod 0755 ${RPM_BUILD_DIR}/etc/init.d/zookeeper
+
+#########################
+#### INSTALL SECTION ####
+#########################
+%install
+pushd ${RPM_BUILD_DIR}
+mv ${RPM_BUILD_DIR}/%{_final_name}/bin/* ${RPM_BUILD_DIR}%{_bin_dir}
+mv ${RPM_BUILD_DIR}/%{_final_name}/libexec/* ${RPM_BUILD_DIR}%{_libexec_dir}
+mv ${RPM_BUILD_DIR}/%{_final_name}/share/zookeeper/* ${RPM_BUILD_DIR}%{_share_dir}
+mv ${RPM_BUILD_DIR}/%{_final_name}/conf/* ${RPM_BUILD_DIR}%{_conf_dir}
+mv ${RPM_BUILD_DIR}/%{_final_name}/sbin/* ${RPM_BUILD_DIR}%{_sbin_dir}
+cp -f ${RPM_BUILD_DIR}%{_conf_dir}/zoo_sample.cfg ${RPM_BUILD_DIR}%{_conf_dir}/zoo.cfg
+popd ${RPM_BUILD_DIR}
+rm -rf ${RPM_BUILD_DIR}/%{_final_name}
+
+%pre
+getent group hadoop 2>/dev/null >/dev/null || /usr/sbin/groupadd -r hadoop
+
+/usr/sbin/useradd --comment "ZooKeeper" --shell /bin/bash -M -r --groups hadoop --home %{_share_dir} zookeeper 2> /dev/null || :
+
+%post
+bash ${RPM_INSTALL_PREFIX0}/sbin/update-zookeeper-env.sh \
+       --prefix=${RPM_INSTALL_PREFIX0} \
+       --conf-dir=${RPM_INSTALL_PREFIX1} \
+       --log-dir=${RPM_INSTALL_PREFIX2} \
+       --pid-dir=${RPM_INSTALL_PREFIX3} \
+       --var-dir=${RPM_INSTALL_PREFIX4}
+
+%preun
+bash ${RPM_INSTALL_PREFIX0}/sbin/update-zookeeper-env.sh \
+       --prefix=${RPM_INSTALL_PREFIX0} \
+       --conf-dir=${RPM_INSTALL_PREFIX1} \
+       --log-dir=${RPM_INSTALL_PREFIX2} \
+       --pid-dir=${RPM_INSTALL_PREFIX3} \
+       --var-dir=${RPM_INSTALL_PREFIX4} \
+       --uninstall
+
+%files 
+%defattr(-,root,root)
+%attr(0755,root,hadoop) %{_log_dir}
+%attr(0775,root,hadoop) %{_pid_dir}
+%attr(0775,root,hadoop) /etc/init.d/zookeeper
+%config(noreplace) %{_conf_dir}/*
+%{_prefix}
+
+%post lib
+/sbin/ldconfig
+
+%files lib
+%defattr(-,root,root)
+%{_prefix}/lib/*
+%{_prefix}/bin

Added: zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh (added)
+++ zookeeper/trunk/src/packages/templates/conf/zookeeper-env.sh Thu Aug 11 19:18:45 2011
@@ -0,0 +1,16 @@
+# 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.
+export JAVA_HOME=${JAVA_HOME}
+export ZOO_LOG_DIR=${LOG_DIR}

Added: zookeeper/trunk/src/packages/update-zookeeper-env.sh
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/packages/update-zookeeper-env.sh?rev=1156752&view=auto
==============================================================================
--- zookeeper/trunk/src/packages/update-zookeeper-env.sh (added)
+++ zookeeper/trunk/src/packages/update-zookeeper-env.sh Thu Aug 11 19:18:45 2011
@@ -0,0 +1,163 @@
+#!/usr/bin/env bash
+
+# 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.
+
+# This script configures zookeeper-env.sh and zoo.cfg.
+
+usage() {
+  echo "
+usage: $0 <parameters>
+  Required parameters:
+     --prefix=PREFIX               path to install into
+
+  Optional parameters:
+     --arch=i386                   OS Architecture
+     --conf-dir=/etc/zookeeper     Configuration directory
+     --log-dir=/var/log/zookeeper  Log directory
+     --pid-dir=/var/run            PID file location
+  "
+  exit 1
+}
+
+template_generator() {
+  REGEX='(\$\{[a-zA-Z_][a-zA-Z_0-9]*\})'
+  cat $1 |
+  while read line ; do
+    while [[ "$line" =~ $REGEX ]] ; do
+      LHS=${BASH_REMATCH[1]}
+      RHS="$(eval echo "\"$LHS\"")"
+      line=${line//$LHS/$RHS}
+    done
+    echo $line >> $2
+  done
+}
+
+OPTS=$(getopt \
+  -n $0 \
+  -o '' \
+  -l 'arch:' \
+  -l 'prefix:' \
+  -l 'conf-dir:' \
+  -l 'log-dir:' \
+  -l 'pid-dir:' \
+  -l 'var-dir:' \
+  -l 'uninstall' \
+  -- "$@")
+
+if [ $? != 0 ] ; then
+    usage
+fi
+
+eval set -- "${OPTS}"
+while true ; do
+  case "$1" in
+    --arch)
+      ARCH=$2 ; shift 2
+      ;;
+    --prefix)
+      PREFIX=$2 ; shift 2
+      ;;
+    --log-dir)
+      LOG_DIR=$2 ; shift 2
+      ;;
+    --lib-dir)
+      LIB_DIR=$2 ; shift 2
+      ;;
+    --conf-dir)
+      CONF_DIR=$2 ; shift 2
+      ;;
+    --pid-dir)
+      PID_DIR=$2 ; shift 2
+      ;;
+    --uninstall)
+      UNINSTALL=1; shift
+      ;;
+    --var-dir)
+      VAR_DIR=$2 ; shift 2
+      ;;
+    --)
+      shift ; break
+      ;;
+    *)
+      echo "Unknown option: $1"
+      usage
+      exit 1
+      ;;
+  esac
+done
+
+for var in PREFIX; do
+  if [ -z "$(eval "echo \$$var")" ]; then
+    echo Missing param: $var
+    usage
+  fi
+done
+
+ARCH=${ARCH:-i386}
+CONF_DIR=${CONF_DIR:-$PREFIX/etc/zookeeper}
+LIB_DIR=${LIB_DIR:-$PREFIX/lib}
+LOG_DIR=${LOG_DIR:-$PREFIX/var/log}
+PID_DIR=${PID_DIR:-$PREFIX/var/run}
+VAR_DIR=${VAR_DIR:-$PREFIX/var/lib}
+UNINSTALL=${UNINSTALL:-0}
+
+if [ "${ARCH}" != "i386" ]; then
+  LIB_DIR=${LIB_DIR}64
+fi
+
+if [ "${UNINSTALL}" -eq "1" ]; then
+  # Remove symlinks
+  if [ -e ${PREFIX}/etc/zookeeper ]; then
+    rm -f ${PREFIX}/etc/zookeeper
+  fi
+else
+  # Create symlinks
+  if [ ${CONF_DIR} != ${PREFIX}/etc/zookeeper ]; then
+    mkdir -p ${PREFIX}/etc
+    ln -sf ${CONF_DIR} ${PREFIX}/etc/zookeeper
+  fi
+
+  mkdir -p ${LOG_DIR}
+  chown zookeeper:hadoop ${LOG_DIR}
+  chmod 755 ${LOG_DIR}
+
+  if [ ! -d ${PID_DIR} ]; then
+    mkdir -p ${PID_DIR}
+    chown zookeeper:hadoop ${PID_DIR}
+    chmod 755 ${PID_DIR}
+  fi
+
+  if [ ! -d ${VAR_DIR} ]; then
+    mkdir -p ${VAR_DIR}/data
+    chown -R zookeeper:hadoop ${VAR_DIR}
+    chmod -R 755 ${VAR_DIR}
+  fi
+
+  TFILE="/tmp/$(basename $0).$$.tmp"
+  if [ -z "${JAVA_HOME}" ]; then
+    if [ -e /etc/debian_version ]; then
+      JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
+    else
+      JAVA_HOME=/usr/java/default
+    fi
+  fi
+  template_generator ${PREFIX}/share/zookeeper/templates/conf/zookeeper-env.sh $TFILE
+  cp ${TFILE} ${CONF_DIR}/zookeeper-env.sh
+  rm -f ${TFILE}
+  template_generator ${PREFIX}/share/zookeeper/templates/conf/zoo.cfg $TFILE
+  cp ${TFILE} ${CONF_DIR}/zoo.cfg
+  rm -f ${TFILE}
+fi

Modified: zookeeper/trunk/src/recipes/build-recipes.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/recipes/build-recipes.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/src/recipes/build-recipes.xml (original)
+++ zookeeper/trunk/src/recipes/build-recipes.xml Thu Aug 11 19:18:45 2011
@@ -122,8 +122,8 @@
   <target name="package" depends="jar" unless="skip.recipes"> 
     <echo message="recipes: ${name}"/>
 
-    <mkdir dir="${dist.dir}/recipes/${name}"/>
-    <copy todir="${dist.dir}/recipes/${name}" includeEmptyDirs="false"
+    <mkdir dir="${dist.dir}/share/zookeeper/recipes/${name}"/>
+    <copy todir="${dist.dir}/share/zookeeper/recipes/${name}" includeEmptyDirs="false"
           flatten="true">
       <fileset dir="${build.dir}">
         <include name="zookeeper-${version}-${name}.jar" />
@@ -139,6 +139,21 @@
     <delete dir="${build.dir}"/>
   </target>
 
+  <!-- ====================================================== -->
+  <!-- rpm a contrib's files                                  -->
+  <!-- ====================================================== -->
+  <target name="rpm" depends="jar" unless="skip.contrib">
+    <echo message="recipes: ${name}"/>
+
+  </target>
+
+  <!-- ====================================================== -->
+  <!-- deb a contrib's files                                  -->
+  <!-- ====================================================== -->
+  <target name="deb" depends="jar" unless="skip.contrib">
+    <echo message="recipes: ${name}"/>
+
+  </target>
 
   <!-- ================================================================== -->
   <!-- Utility features                                                   -->

Modified: zookeeper/trunk/src/recipes/build.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/recipes/build.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/src/recipes/build.xml (original)
+++ zookeeper/trunk/src/recipes/build.xml Thu Aug 11 19:18:45 2011
@@ -59,4 +59,21 @@
     </subant>
   </target>
 
+  <!-- ====================================================== -->
+  <!-- rpm all the contribs.                                  -->
+  <!-- ====================================================== -->
+  <target name="rpm">
+    <subant target="rpm">
+      <fileset dir="." includes="*/build.xml"/>
+    </subant>
+  </target>
+
+  <!-- ====================================================== -->
+  <!-- deb all the contribs.                                  -->
+  <!-- ====================================================== -->
+  <target name="deb">
+    <subant target="deb">
+      <fileset dir="." includes="*/build.xml"/>
+    </subant>
+  </target>
 </project>

Modified: zookeeper/trunk/src/recipes/lock/build.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/recipes/lock/build.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/src/recipes/lock/build.xml (original)
+++ zookeeper/trunk/src/recipes/lock/build.xml Thu Aug 11 19:18:45 2011
@@ -112,14 +112,14 @@
   <target name="package" depends="jar, zookeeperbuildrecipes.package"
           unless="skip.recipes">
 
-    <copy file="${basedir}/build.xml" todir="${dist.dir}/recipes/${name}"/>
+    <copy file="${basedir}/build.xml" todir="${dist.dir}/share/zookeeper/recipes/${name}"/>
 
-    <mkdir dir="${dist.dir}/recipes/${name}/test"/>
-    <copy todir="${dist.dir}/recipes/${name}/test">
+    <mkdir dir="${dist.dir}/share/zookeeper/recipes/${name}/test"/>
+    <copy todir="${dist.dir}/share/zookeeper/recipes/${name}/test">
       <fileset dir="${basedir}/test"/>
     </copy>
-    <mkdir dir="${dist.dir}/recipes/${name}/src"/>
-    <copy todir="${dist.dir}/recipes/${name}/src">
+    <mkdir dir="${dist.dir}/share/zookeeper/recipes/${name}/src"/>
+    <copy todir="${dist.dir}/share/zookeeper/recipes/${name}/src">
       <fileset dir="${basedir}/src"/>
     </copy>
   </target>

Modified: zookeeper/trunk/src/recipes/queue/build.xml
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/recipes/queue/build.xml?rev=1156752&r1=1156751&r2=1156752&view=diff
==============================================================================
--- zookeeper/trunk/src/recipes/queue/build.xml (original)
+++ zookeeper/trunk/src/recipes/queue/build.xml Thu Aug 11 19:18:45 2011
@@ -112,14 +112,14 @@
   <target name="package" depends="jar, zookeeperbuildrecipes.package"
           unless="skip.recipes">
 
-    <copy file="${basedir}/build.xml" todir="${dist.dir}/recipes/${name}"/>
+    <copy file="${basedir}/build.xml" todir="${dist.dir}/share/zookeeper/recipes/${name}"/>
 
-    <mkdir dir="${dist.dir}/recipes/${name}/test"/>
-    <copy todir="${dist.dir}/recipes/${name}/test">
+    <mkdir dir="${dist.dir}/share/zookeeper/recipes/${name}/test"/>
+    <copy todir="${dist.dir}/share/zookeeper/recipes/${name}/test">
       <fileset dir="${basedir}/test"/>
     </copy>
-    <mkdir dir="${dist.dir}/recipes/${name}/src"/>
-    <copy todir="${dist.dir}/recipes/${name}/src">
+    <mkdir dir="${dist.dir}/share/zookeeper/recipes/${name}/src"/>
+    <copy todir="${dist.dir}/share/zookeeper/recipes/${name}/src">
       <fileset dir="${basedir}/src"/>
     </copy>
   </target>