incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1171212 - in /incubator/hcatalog/trunk: ./ bin/ conf/ ivy/ src/packages/ src/packages/deb/ src/packages/deb/hcatalog.control/ src/packages/deb/init.d/ src/packages/rpm/ src/packages/rpm/init.d/ src/packages/rpm/spec/ src/packages/templates...
Date Thu, 15 Sep 2011 18:25:52 GMT
Author: hashutosh
Date: Thu Sep 15 18:25:51 2011
New Revision: 1171212

URL: http://svn.apache.org/viewvc?rev=1171212&view=rev
Log:
HCATALOG-63: RPM package integration with Hadoop

Added:
    incubator/hcatalog/trunk/bin/hcat-config.sh
    incubator/hcatalog/trunk/bin/hcat_server.sh
    incubator/hcatalog/trunk/bin/hive-config.sh
    incubator/hcatalog/trunk/src/packages/
    incubator/hcatalog/trunk/src/packages/deb/
    incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/
    incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/conffile
    incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/control
    incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postinst
    incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postrm
    incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/preinst
    incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/prerm
    incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/server.control
    incubator/hcatalog/trunk/src/packages/deb/init.d/
    incubator/hcatalog/trunk/src/packages/deb/init.d/hcatalog-server
    incubator/hcatalog/trunk/src/packages/rpm/
    incubator/hcatalog/trunk/src/packages/rpm/init.d/
    incubator/hcatalog/trunk/src/packages/rpm/init.d/hcatalog-server
    incubator/hcatalog/trunk/src/packages/rpm/spec/
    incubator/hcatalog/trunk/src/packages/rpm/spec/hcatalog.spec
    incubator/hcatalog/trunk/src/packages/templates/
    incubator/hcatalog/trunk/src/packages/templates/conf/
    incubator/hcatalog/trunk/src/packages/templates/conf/hcat-env.sh.template
    incubator/hcatalog/trunk/src/packages/update-hcatalog-env.sh
Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    incubator/hcatalog/trunk/bin/hcat
    incubator/hcatalog/trunk/build.xml
    incubator/hcatalog/trunk/conf/proto-hive-site.xml
    incubator/hcatalog/trunk/ivy.xml
    incubator/hcatalog/trunk/ivy/libraries.properties

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1171212&r1=1171211&r2=1171212&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Thu Sep 15 18:25:51 2011
@@ -23,6 +23,7 @@ Trunk (unreleased changes)
   INCOMPATIBLE CHANGES
 
   NEW FEATURES
+  HCAT-63. RPM package integration with Hadoop (khorgath via hashutosh)
 
   IMPROVEMENTS
   HCAT-97. Make test harness work with secure cluster (hashutosh)

Modified: incubator/hcatalog/trunk/bin/hcat
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/bin/hcat?rev=1171212&r1=1171211&r2=1171212&view=diff
==============================================================================
--- incubator/hcatalog/trunk/bin/hcat (original)
+++ incubator/hcatalog/trunk/bin/hcat Thu Sep 15 18:25:51 2011
@@ -34,9 +34,13 @@ bin=`dirname "$this"`                   
 script=`basename "$this"`                                                        
 bin=`unset CDPATH; cd "$bin"; pwd`                                               
 this="$bin/$script"                                                              
-                                                                                 
-# the root of the HCatalog installation                                          
-export HCAT_HOME=`dirname "$this"`/..                                            
+
+
+if [ -e "$bin/../libexec/hcat-config.sh" ]; then
+  . "$bin"/../libexec/hcat-config.sh
+else
+  . "$bin"/hcat-config.sh
+fi
 
 # filter debug command line parameter
 debug=false
@@ -51,25 +55,25 @@ done
 
 # Find our hcatalog jar
 shopt -s extglob
-HCAT_JAR=$HCAT_HOME/lib/hcatalog-!(*server-extensions*).jar
+HCAT_JAR=$HCAT_PREFIX/share/hcatalog/hcatalog-!(*server-extensions*).jar
 
 # Add all of the other jars to our classpath
-for jar in $HCAT_HOME/lib/*.jar ; do
+for jar in $HCAT_PREFIX/share/hcatalog/lib/*.jar ; do
 	HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$jar
 done
 
 # Put our config file in the classpath
-HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:${HCAT_HOME}/conf
+HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:${HCAT_PREFIX}/etc/hcatalog
 
 export HADOOP_CLASSPATH=$HADOOP_CLASSPATH
-
+export HADOOP_OPTS=$HADOOP_OPTS
 # run it
 if [ "$debug" == "true" ]; then
 	echo "Would run:"
-	echo "exec $HADOOP_HOME/bin/hadoop jar $HCAT_JAR org.apache.hcatalog.cli.HCatCli $remaining"
+	echo "exec $HADOOP_PREFIX/bin/hadoop jar $HCAT_JAR org.apache.hcatalog.cli.HCatCli $remaining"
 	echo "with HADOOP_CLASSPATH set to ($HADOOP_CLASSPATH)"
 	echo "and HADOOP_OPTS set to ($HADOOP_OPTS)"
 else
-	exec $HADOOP_HOME/bin/hadoop jar  $HCAT_JAR org.apache.hcatalog.cli.HCatCli "$@"
+	exec $HADOOP_PREFIX/bin/hadoop jar  $HCAT_JAR org.apache.hcatalog.cli.HCatCli "$@"
 fi
 

Added: incubator/hcatalog/trunk/bin/hcat-config.sh
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/bin/hcat-config.sh?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/bin/hcat-config.sh (added)
+++ incubator/hcatalog/trunk/bin/hcat-config.sh Thu Sep 15 18:25:51 2011
@@ -0,0 +1,67 @@
+# 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.
+
+# included in all the hadoop scripts with source command
+# should not be executable directly
+# also should not be passed any arguments, since we need original $*
+
+# resolve links - $0 may be a softlink
+
+this="${BASH_SOURCE-$0}"
+common_bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
+script="$(basename -- "$this")"
+this="$common_bin/$script"
+
+# convert relative path to absolute path
+config_bin=`dirname "$this"`
+script=`basename "$this"`
+config_bin=`cd "$config_bin"; pwd`
+this="$config_bin/$script"
+
+# the root of the HCATALOG installation
+export HCAT_PREFIX=`dirname "$this"`/..
+
+#check to see if the conf dir is given as an optional argument
+if [ $# -gt 1 ]
+then
+    if [ "--config" = "$1" ]
+	  then
+	      shift
+	      confdir=$1
+	      shift
+	      HCAT_CONF_DIR=$confdir
+    fi
+fi
+ 
+# Allow alternate conf dir location.
+if [ -e "${HCAT_PREFIX}/conf/hcat-env.sh" ]; then
+  DEFAULT_CONF_DIR="conf"
+else
+  DEFAULT_CONF_DIR="etc/hcatalog"
+fi
+HCAT_CONF_DIR="${HCAT_CONF_DIR:-$HCAT_PREFIX/$DEFAULT_CONF_DIR}"
+
+if [ -e $HCAT_PREFIX/bin/hadoop ]; then
+  HADOOP_PREFIX=$HCAT_PREFIX
+elif [ -e $HADOOP_HOME/bin/hadoop ]; then
+  HADOOP_PREFIX=$HADOOP_HOME
+else
+  echo "Hadoop not found."
+  exit 1
+fi
+
+if [ -f "${HCAT_CONF_DIR}/hcat-env.sh" ]; then
+  . "${HCAT_CONF_DIR}/hcat-env.sh"
+fi

Added: incubator/hcatalog/trunk/bin/hcat_server.sh
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/bin/hcat_server.sh?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/bin/hcat_server.sh (added)
+++ incubator/hcatalog/trunk/bin/hcat_server.sh Thu Sep 15 18:25:51 2011
@@ -0,0 +1,147 @@
+#!/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. 
+
+bin=`which $0`
+bin=`dirname ${bin}`
+bin=`cd "$bin"; pwd`
+
+if [ -e "$bin/../libexec/hcat-config.sh" ]; then
+  . "$bin"/../libexec/hcat-config.sh
+else
+  . "$bin"/hcat-config.sh
+fi
+
+function print_usage() {
+  echo "Usage: $0 [--config confdir] COMMAND"
+  echo "  start  Start HCatalog Server"
+  echo "  stop   Stop HCatalog Server"
+}
+
+function start_hcat() {
+  # back ground the metastore service and record the pid
+  PID_FILE=${HCAT_PID_DIR}/hcat.pid
+  SLEEP_TIME_AFTER_START=15
+
+  # check if service is already running, if so exit
+  if [ -s "$PID_FILE" ]
+  then
+    echo "HCatalog server appears to be running.  If you are SURE it is not" \
+         " remove $PID_FILE and re-run this script."
+    exit 1
+  fi
+
+  HIVE_SITE_XML=${HCAT_PREFIX}/etc/hcatalog/hive-site.xml
+  if [ ! -e $HIVE_SITE_XML ]
+  then
+    echo "Missing hive-site.xml, expected at [$HIVE_SITE_XML]";
+    exit 1
+  fi
+
+  # Find our Warehouse dir from the config file
+#  WAREHOUSE_DIR=`sed -n '/<name>hive.metastore.warehouse.dir<\/name>/ {
+#      n
+#      s/.*<value>\(.*\)<\/value>.*/\1/p
+#      }' $HIVE_SITE_XML`
+#  HADOOP_OPTS="$HADOOP_OPTS -Dhive.metastore.warehouse.dir=$WAREHOUSE_DIR " 
+
+  # add in hive-site.xml to classpath
+  AUX_CLASSPATH=${AUX_CLASSPATH}:`dirname ${HIVE_SITE_XML}`
+
+  # add jars from db connectivity dir - be careful to not point to something like /lib
+  for f in ${DBROOT}/*.jar; do
+    AUX_CLASSPATH=${AUX_CLASSPATH}:$f
+  done
+
+  # add jars from lib dir
+  for f in ${HCAT_PREFIX}/share/hcatalog/lib/*.jar ; do
+    AUX_CLASSPATH=${AUX_CLASSPATH}:$f
+  done
+
+  # echo AUX_CLASSPATH = ${AUX_CLASSPATH}
+  export AUX_CLASSPATH=${AUX_CLASSPATH}
+
+  export HADOOP_HOME=$HADOOP_HOME
+  #export HADOOP_OPTS="-Dlog4j.configuration=file://${HCAT_PREFIX}/conf/log4j.properties"
+  export HADOOP_OPTS="${HADOOP_OPTS} -server -XX:+UseConcMarkSweepGC -XX:ErrorFile=${HCAT_LOG_DIR}/hcat_err_pid%p.log -Xloggc:${HCAT_LOG_DIR}/hcat_gc.log-`date +'%Y%m%d%H%M'` -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps"
+  export HADOOP_HEAPSIZE=2048 # 8G is better if you have it
+  export METASTORE_PORT=${METASTORE_PORT}
+  nohup ${HCAT_PREFIX}/bin/hive --service metastore >${HCAT_LOG_DIR}/hcat.out 2>${HCAT_LOG_DIR}/hcat.err &
+
+  PID=$!
+
+  if [ "${PID}x" == "x" ] ; then # we failed right off
+    echo "Metastore startup failed, see ${HCAT_LOG_DIR}/hcat.err"
+    exit 1
+  fi
+
+  echo Started metastore server init, testing if initialized correctly...
+  sleep $SLEEP_TIME_AFTER_START
+
+  if ps -p $PID > /dev/null 
+  then
+    echo $PID > $PID_FILE
+    echo "Metastore initialized successfully on port[${METASTORE_PORT}]."
+  else
+    echo "Metastore startup failed, see ${HCAT_LOG_DIR}/hcat.err"
+    exit 1
+  fi
+}
+
+function stop_hcat() {
+  SLEEP_TIME_AFTER_KILL=30
+
+  PID_FILE=${HCAT_PID_DIR}/hcat.pid
+  echo looking for $PID_FILE
+
+  # check if service is already running, if so exit
+  if [ -s "$PID_FILE" ] ; then
+    PID=`cat $PID_FILE`
+    echo "Found metastore server process $PID, killing..."
+    kill $PID
+    sleep $SLEEP_TIME_AFTER_KILL
+
+    # if process is still around, use kill -9
+    if ps -p $PID > /dev/null ; then
+        echo "Initial kill failed, getting serious now..."
+        kill -9 $PID
+    fi
+    if ps -p $PID > /dev/null ; then
+        echo "Wow, even kill -9 failed, giving up; sorry"
+        exit 1
+    else
+        rm -rf $PID_FILE
+        echo "Successfully shutdown metastore"
+    fi
+  fi
+}
+
+if [ $# = 0 ]; then
+  print_usage
+  exit
+fi
+
+COMMAND=$1
+case $COMMAND in
+  start)
+    start_hcat
+    ;;
+  stop)
+    stop_hcat
+    ;;
+esac
+

Added: incubator/hcatalog/trunk/bin/hive-config.sh
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/bin/hive-config.sh?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/bin/hive-config.sh (added)
+++ incubator/hcatalog/trunk/bin/hive-config.sh Thu Sep 15 18:25:51 2011
@@ -0,0 +1,70 @@
+# 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.
+
+#
+# processes --config option from command line
+#
+
+this="$0"
+while [ -h "$this" ]; do
+  ls=`ls -ld "$this"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '.*/.*' > /dev/null; then
+    this="$link"
+  else
+    this=`dirname "$this"`/"$link"
+  fi
+done
+
+# convert relative path to absolute path
+bin=`dirname "$this"`
+script=`basename "$this"`
+bin=`cd "$bin"; pwd`
+this="$bin/$script"
+
+# the root of the hcatalog-hive installation
+export HIVE_HOME=`dirname "$bin"`/share/hcatalog
+
+#check to see if the conf dir is given as an optional argument
+while [ $# -gt 0 ]; do    # Until you run out of parameters . . .
+  case "$1" in
+    --config)
+        shift
+        confdir=$1
+        shift
+        HIVE_CONF_DIR=$confdir
+        ;;
+    --auxpath)
+        shift
+        HIVE_AUX_JARS_PATH=$1
+        shift
+        ;;
+    *)
+        break;
+        ;;
+  esac
+done
+
+
+# Allow alternate conf dir location.
+HIVE_CONF_DIR="${HIVE_CONF_DIR:-$HIVE_HOME/conf}"
+
+export HIVE_CONF_DIR=$HIVE_CONF_DIR
+export HIVE_AUX_JARS_PATH=$HIVE_AUX_JARS_PATH
+
+# Default to use 256MB 
+export HADOOP_HEAPSIZE=${HADOOP_HEAPSIZE:-256}
+
+

Modified: incubator/hcatalog/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/build.xml?rev=1171212&r1=1171211&r2=1171212&view=diff
==============================================================================
--- incubator/hcatalog/trunk/build.xml (original)
+++ incubator/hcatalog/trunk/build.xml Thu Sep 15 18:25:51 2011
@@ -26,9 +26,12 @@
   ================================================================================
   -->
   <!-- name and version -->
-  <property name="hcatalog.version" value="0.3.0-dev"/>
+  <property name="_version" value="0.3.0"/>
+  <property name="_vtype" value="-dev"/> 
+  <property name="hcatalog.version" value="${_version}${_vtype}"/>
   <property name="hcatalog.jar" value="${ant.project.name}-${hcatalog.version}.jar"/>
-    <property name="final.name" value="${ant.project.name}-${hcatalog.version}" />
+  <property name="final.name" value="${ant.project.name}-${hcatalog.version}" />
+  <property name="package.release" value="1"/>
 
   <!-- hive properties -->
   <property name="hive.root" value="${basedir}/hive/external"/>
@@ -36,6 +39,7 @@
   <!-- build properties -->
   <property name="lib.dir" value="${basedir}/lib/" />
   <property name="src.dir"  location="${basedir}/src/java"/>
+  <property name="package.dir"  location="${basedir}/src/packages"/>
   <property name="docs.src" value="${basedir}/src/docs"/>
   <property name="build.dir" value="${basedir}/build"/>
   <property name="build.classes" value="${build.dir}/classes" />
@@ -84,6 +88,17 @@
   <property name="ivy.lib.dir" location="${build.ivy.lib.dir}/${ant.project.name}"/>
   <property name="build.ivy.report.dir" location="${build.ivy.dir}/report" />
 
+  <!-- packaging properties -->
+  <property name="package.prefix" value="/usr"/>
+  <property name="package.conf.dir" value="/etc/hcatalog"/>
+  <property name="package.log.dir" value="/var/log/hcatalog"/>
+  <property name="package.pid.dir" value="/var/run/hcatalog"/>
+  <property name="package.var.dir" value="/var/lib/hcatalog"/>
+  <property name="package.share.dir" value="/share/hcatalog/${module}"/>
+  <!-- Use fixed path to build rpm for avoiding rpmbuild conflict with dash path names -->
+  <property name="package.buildroot" value="/tmp/hcatalog_package_build_${user.name}"/>
+  <property name="package.build.dir" value="/tmp/hcatalog_package_build_${user.name}/BUILD"/>
+
   <!-- rats properties -->
   <property name="rat.reporting.classname" value="rat.Report"/>
 
@@ -198,6 +213,14 @@
     <ivy:cachepath pathid="compile.classpath" conf="common"/>     
   </target>
 
+  <target name="ivy-package" depends="ivy-init"
+    description="Retrieve Ivy-managed artifacts for the package configurations">
+    <ivy:resolve settingsRef="${ant.project.name}.ivy.settings" conf="package"/>
+    <ivy:retrieve settingsRef="${ant.project.name}.ivy.settings"
+      pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" conf="package"/>
+    <ivy:cachepath pathid="package.classpath" conf="package"/>
+  </target>
+
   <target name="ivy-releaseaudit" depends="ivy-init" description="Resolve, Retrieve Ivy-managed artifacts for releaseaudit configuration">
     <ivy:resolve settingsRef="${ant.project.name}.ivy.settings" conf="releaseaudit"/>
     <ivy:retrieve settingsRef="${ant.project.name}.ivy.settings"
@@ -205,7 +228,7 @@
     <ivy:cachepath pathid="releaseaudit.classpath" conf="releaseaudit"/>
   </target>
 
-  <target name="init" depends="ivy-compile" >
+  <target name="init" depends="ivy-compile, ivy-package" >
     <mkdir dir="${dist.dir}" />
     <mkdir dir="${build.classes}" />
     <mkdir dir="${test.build.classes}" />
@@ -247,7 +270,7 @@
   -->
   <!-- Build the server side jar -->
   <target name="server-extensions" depends="compile-src">
-     <jar jarfile="${build.dir}/${ant.project.name}/${final.name}-server-extensions.jar" basedir="${build.classes}"
+     <jar jarfile="${build.dir}/${ant.project.name}/${ant.project.name}-server-extensions-${hcatalog.version}.jar" basedir="${build.classes}"
  	  includes="org/apache/hcatalog/listener/**,org/apache/hcatalog/metadata/**">
   </jar>
   </target>
@@ -372,25 +395,29 @@
   -->
   <target name="package" depends="jar, docs" description="Create an HCatalog release">
     <mkdir dir="${dist.dir}" />
-    <mkdir dir="${dist.dir}/lib" />
-    <mkdir dir="${dist.dir}/conf" />
+    <mkdir dir="${dist.dir}/share/${ant.project.name}/lib" />
+    <mkdir dir="${dist.dir}/etc/hcatalog" />
     <mkdir dir="${dist.dir}/bin" />
     <mkdir dir="${dist.dir}/bin/ext" />
     <mkdir dir="${dist.dir}/bin/ext/util" />
-    <mkdir dir="${dist.dir}/scripts" />
-    <mkdir dir="${dist.dir}/docs" />
-    <mkdir dir="${dist.dir}/docs/api" />
-    <mkdir dir="${dist.dir}/docs/jdiff"/>
-    <mkdir dir="${dist.dir}/license" />
-    <mkdir dir="${dist.dir}/hive" />
-    <mkdir dir="${dist.dir}/hive/external" />
-
-    <copy todir="${dist.dir}/lib" includeEmptyDirs="false">
-      <fileset dir="${lib.dir}"/>
+    <mkdir dir="${dist.dir}/sbin" />
+    <mkdir dir="${dist.dir}/share/${ant.project.name}/scripts" />
+    <mkdir dir="${dist.dir}/share/${ant.project.name}/templates/conf" />
+    <mkdir dir="${dist.dir}/share/doc/${ant.project.name}" />
+    <mkdir dir="${dist.dir}/share/doc/${ant.project.name}/api" />
+    <mkdir dir="${dist.dir}/share/doc/${ant.project.name}/jdiff"/>
+    <mkdir dir="${dist.dir}/share/doc/${ant.project.name}/license" />
+    <mkdir dir="${dist.dir}/share/${ant.project.name}/hive" />
+    <mkdir dir="${dist.dir}/share/${ant.project.name}/hive/external" />
 
+    <copy todir="${dist.dir}/share/${ant.project.name}" includeEmptyDirs="false">
       <fileset dir="${build.dir}/${ant.project.name}/">
         <include name="hcatalog-*.jar"/>
       </fileset>
+    </copy>
+
+    <copy todir="${dist.dir}/share/${ant.project.name}/lib" includeEmptyDirs="false">
+      <fileset dir="${lib.dir}"/>
 
       <fileset dir="hive/external/build/ivy/lib/default">
         <include name="jdo2-api-*.jar"/>
@@ -453,43 +480,65 @@
       </fileset>
     </copy>
 
-    <copy todir="${dist.dir}/ivy">
-      <fileset dir="ivy" />
-    </copy>
-
     <copy todir="${dist.dir}/bin">
       <fileset dir="bin/">
-	  	<include name="*.sh"/>
-	  </fileset>
+        <include name="hcat"/>
+      </fileset>
       <fileset file="hive/external/bin/hive"/>
-      <fileset file="hive/external/bin/hive-config.sh"/>
+      <fileset dir="bin">
+        <include name="hive-config.sh"/>
+      </fileset>
+    </copy>
+
+    <copy todir="${dist.dir}/libexec">
+      <fileset dir="bin">
+        <include name="hcat-config.sh"/>
+      </fileset>
+      <!-- fileset file="hive/external/bin/hive-config.sh" /-->
+    </copy>
+
+    <copy todir="${dist.dir}/sbin">
+      <fileset dir="${package.dir}">
+  	<include name="*.sh"/>
+      </fileset>
+      <fileset dir="bin">
+        <include name="hcat_server.sh"/>
+      </fileset>
     </copy>
 
     <copy todir="${dist.dir}/bin/ext">
       <fileset file="hive/external/bin/ext/metastore.sh"/>
+      <fileset file="hive/external/bin/ext/cli.sh"/>
+      <fileset file="hive/external/bin/ext/help.sh"/>
     </copy>
 
     <copy todir="${dist.dir}/bin/ext/util">
       <fileset file="hive/external/bin/ext/util/execHiveCmd.sh"/>
     </copy>
 
-    <copy todir="${dist.dir}/docs">
+    <copy todir="${dist.dir}/share/doc/${ant.project.name}">
       <fileset dir="${build.docs}" />
     </copy>
 
-    <copy todir="${dist.dir}/conf">
+    <copy todir="${dist.dir}/etc/${ant.project.name}">
       <fileset dir="conf" />
       <fileset file="hive/external/conf/hive-default.xml"/>
     </copy>
 
-    <copy todir="${dist.dir}/scripts">
+    <copy todir="${dist.dir}/share/${ant.project.name}/templates/conf">
+      <fileset dir="src/packages/templates/conf">
+        <include name="*"/>
+      </fileset>
+    </copy>
+
+    <copy todir="${dist.dir}/share/${ant.project.name}/scripts">
       <fileset file="hive/external/metastore/scripts/upgrade/mysql/hive-schema-0.7.0.mysql.sql"/>
       <fileset dir="scripts">
 	  	<include name="*.sh"/>
       </fileset>
     </copy>
 
-	<!-- Copy source files so the tar ball can build -->
+	<!-- Copy source files for reference -->
     <copy todir="${dist.dir}/src/java" includeEmptyDirs="true">
       <fileset dir="${src.dir}" />
     </copy>
@@ -502,28 +551,30 @@
       <fileset dir="${docs.src}" />
     </copy>
 
-    <copy todir="${dist.dir}/" file="build.xml" />
-    <copy todir="${dist.dir}/" file="ivy.xml" />
+    <copy todir="${dist.dir}/src/packages" includeEmptyDirs="true">
+      <fileset dir="${package.dir}" />
+    </copy>
 
-	<copy todir="${dist.dir}/hive/external" includeEmptyDirs="true">
+	<copy todir="${dist.dir}/share/${ant.project.name}/hive/external" includeEmptyDirs="true">
 		<fileset dir="${hive.root}">
 			<exclude name="build/**"/>
 		</fileset>
 	</copy>
 
 	<!-- Copy the licenses and such -->
-    <copy todir="${dist.dir}">
+    <copy todir="${dist.dir}/share/doc/${ant.project.name}">
       <fileset dir=".">
         <include name="*.txt" />
       </fileset>
     </copy>
 
-    <copy todir="${dist.dir}/license">
+    <copy todir="${dist.dir}/share/doc/${ant.project.name}/license">
       <fileset dir="license" />
     </copy>
 
     <chmod perm="ugo+x" type="file">
       <fileset dir="${dist.dir}/bin" />
+      <fileset dir="${dist.dir}/sbin" />
     </chmod>
 
     </target>
@@ -538,6 +589,31 @@
     <!-- ================================================================== -->
     <!-- Make release tarball                                               -->
     <!-- ================================================================== -->
+    <target name="source" description="Source distribution">
+        <mkdir dir="${build.dir}"/>
+        <tar compression="gzip" longfile="gnu" destfile="${build.dir}/${ant.project.name}-source-${hcatalog.version}.tar.gz">
+            <tarfileset dir="${basedir}" mode="644">
+                <exclude name="bin"/>
+                <exclude name="bin/*"/>
+                <exclude name="build"/>
+                <exclude name="build/*"/>
+                <include name="conf/**"/>
+                <include name="ivy/**"/>
+                <include name="lib/*i*"/>
+                <include name="src/**"/>
+                <include name="*.txt"/>
+                <include name="*.xml"/>
+                <include name="**"/>
+            </tarfileset>
+            <tarfileset dir="" mode="755">
+                <include name="bin/**"/>
+            </tarfileset>
+        </tar>
+    </target> 
+
+    <!-- ================================================================== -->
+    <!-- Make release binary packages                                       -->
+    <!-- ================================================================== -->
     <target name="tar" depends="package" description="Create release tarball">
         <tar compression="gzip" longfile="gnu" destfile="${build.dir}/${final.name}.tar.gz">
             <tarfileset dir="${build.dir}" mode="664">
@@ -546,11 +622,134 @@
             </tarfileset>
             <tarfileset dir="${build.dir}" mode="755">
                 <include name="${final.name}/bin/*" />
-            </tarfileset>
-            <tarfileset dir="${build.dir}" mode="755">
-                <include name="${final.name}/scripts/*" />
+                <include name="${final.name}/sbin/*" />
             </tarfileset>
         </tar>
     </target>
- 
+
+    <target name="rpm" depends="tar" description="Create rpm package">
+        <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>
+        </copy>
+        <copy file="${package.dir}/rpm/spec/hcatalog.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}" />
+                </replacetokens>
+            </filterchain>
+        </copy>
+        <rpm specFile="hcatalog.spec" command="-bb --target ${os.arch}" 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" description="Create debian package">
+        <taskdef name="deb" classname="org.vafer.jdeb.ant.DebAntTask">
+            <classpath refid="package.classpath" />
+        </taskdef>
+        <mkdir dir="${package.build.dir}/hcatalog.control" />
+        <mkdir dir="${package.build.dir}/hcatalog-server.control" />
+        <mkdir dir="${package.buildroot}/${package.prefix}" />
+        <copy todir="${package.buildroot}/${package.prefix}">
+            <fileset dir="${build.dir}/${final.name}">
+                <include name="**" />
+            </fileset>
+        </copy>
+        <copy todir="${package.build.dir}/hcatalog.control">
+            <fileset dir="${package.dir}/deb/hcatalog.control">
+                <exclude name="control" />
+                <exclude name="server.control" />
+            </fileset>
+        </copy>
+        <copy file="${package.dir}/deb/hcatalog.control/control" todir="${package.build.dir}/hcatalog.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}" />
+                </replacetokens>
+            </filterchain>
+        </copy>
+        <copy file="${package.dir}/deb/hcatalog.control/server.control" tofile="${package.build.dir}/hcatalog-server.control/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}" />
+                </replacetokens>
+            </filterchain>
+        </copy>
+        <deb destfile="${package.buildroot}/${ant.project.name}_${_version}-${package.release}_${os.arch}.deb" control="${package.build.dir}/hcatalog.control">
+            <tarfileset dir="${build.dir}/${final.name}" filemode="644" prefix="${package.prefix}">
+                <exclude name="bin" />
+                <exclude name="etc" />
+                <exclude name="etc/**" />
+                <exclude name="sbin" />
+                <exclude name="sbin/**" />
+                <exclude name="share/hcatalog/hcatalog-server*" />
+                <include name="**" />
+            </tarfileset>
+            <tarfileset dir="${build.dir}/${final.name}/etc/hcatalog" filemode="644" prefix="${package.conf.dir}">
+                <include name="**" />
+            </tarfileset>
+            <tarfileset dir="${build.dir}/${final.name}/bin" filemode="755" prefix="${package.prefix}/bin">
+                <include name="**" />
+            </tarfileset>
+            <tarfileset dir="${build.dir}/${final.name}/sbin" filemode="755" prefix="${package.prefix}/sbin">
+                <include name="update-hcatalog-env.sh" />
+            </tarfileset>
+        </deb>
+        <copy todir="${build.dir}/" flatten="true">
+            <fileset dir="${package.buildroot}">
+                <include name="**/hcatalog*.deb" />
+            </fileset>
+        </copy>
+        <deb destfile="${package.buildroot}/${ant.project.name}-server_${_version}-${package.release}_${os.arch}.deb" control="${package.build.dir}/hcatalog-server.control">
+            <tarfileset dir="${build.dir}/${final.name}" filemode="644" prefix="${package.prefix}">
+                <include name="share/hcatalog/hcatalog-server*" />
+            </tarfileset>
+            <tarfileset dir="${build.dir}/${final.name}/sbin" filemode="755" prefix="${package.prefix}/sbin">
+                <include name="hcat_server.sh" />
+            </tarfileset>
+            <tarfileset dir="${basedir}/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="**/hcatalog*.deb" />
+            </fileset>
+        </copy>
+        <delete dir="${package.buildroot}" quiet="true" verbose="false"/>
+    </target>
 </project>

Modified: incubator/hcatalog/trunk/conf/proto-hive-site.xml
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/conf/proto-hive-site.xml?rev=1171212&r1=1171211&r2=1171212&view=diff
==============================================================================
--- incubator/hcatalog/trunk/conf/proto-hive-site.xml (original)
+++ incubator/hcatalog/trunk/conf/proto-hive-site.xml Thu Sep 15 18:25:51 2011
@@ -81,7 +81,7 @@
 
 <property>
   <name>hive.metastore.uris</name>
-  <value>thrift://SVRHOST:9080</value>
+  <value>thrift://SVRHOST:9933</value>
   <description>URI for client to contact metastore server</description>
 </property>
 

Modified: incubator/hcatalog/trunk/ivy.xml
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/ivy.xml?rev=1171212&r1=1171211&r2=1171212&view=diff
==============================================================================
--- incubator/hcatalog/trunk/ivy.xml (original)
+++ incubator/hcatalog/trunk/ivy.xml Thu Sep 15 18:25:51 2011
@@ -33,6 +33,7 @@
             extends="runtime"
             description="artifacts needed to compile/test the application"/>
         <conf name="test" visibility="private" extends="runtime"/>
+        <conf name="package" visibility="private" extends="master"/>
         <conf name="releaseaudit" visibility="private"/>
     </configurations>
     <dependencies>
@@ -48,5 +49,6 @@
         <dependency org="org.apache.activemq" name="activemq-all" rev="${activemq.version}" conf="common->master" />
         <dependency org="javax.management.j2ee" name="management-api" rev="${javax-mgmt.version}" conf="common->master" /> 
         <dependency org="com.google.code.p.arat" name="rat-lib" rev="${rats-lib.version}" conf="releaseaudit->default"/>
-</dependencies>
+        <dependency org="org.vafer" name="jdeb" rev="${jdeb.version}" conf="package->master"/>
+    </dependencies>
 </ivy-module>

Modified: incubator/hcatalog/trunk/ivy/libraries.properties
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/ivy/libraries.properties?rev=1171212&r1=1171211&r2=1171212&view=diff
==============================================================================
--- incubator/hcatalog/trunk/ivy/libraries.properties (original)
+++ incubator/hcatalog/trunk/ivy/libraries.properties Thu Sep 15 18:25:51 2011
@@ -22,3 +22,4 @@ jms.version=1.1
 activemq.version=5.5.0
 javax-mgmt.version=1.1-rev-1
 rats-lib.version=0.5.1
+jdeb.version=0.8

Added: incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/conffile
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/conffile?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/conffile (added)
+++ incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/conffile Thu Sep 15 18:25:51 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/hcatalog

Added: incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/control
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/control?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/control (added)
+++ incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/control Thu Sep 15 18:25:51 2011
@@ -0,0 +1,24 @@
+# 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: hcatalog
+Version: @version@
+Section: misc
+Priority: optional
+Provides: hcatalog
+Architecture: all
+Depends: sun-java6-jre, hadoop, mysql-client
+Maintainer: Apache Software Foundation <general@hadoop.apache.org>
+Description: The Apache HCatalog is a table and storage management service for data created using Apache Hadoop.
+Distribution: development

Added: incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postinst
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postinst?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postinst (added)
+++ incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postinst Thu Sep 15 18:25:51 2011
@@ -0,0 +1,25 @@
+#!/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-hcatalog-env.sh \
+  --prefix=/usr \
+  --bin-dir=/usr/bin \
+  --sbin-dir=/usr/sbin \
+  --conf-dir=/etc/hcatalog \
+  --log-dir=/var/log/hcatalog \
+  --pid-dir=/var/run/hcatalog \
+  --mysql-dir=/usr/share/java

Added: incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postrm
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postrm?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postrm (added)
+++ incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/postrm Thu Sep 15 18:25:51 2011
@@ -0,0 +1,18 @@
+#!/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.
+
+exit 0

Added: incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/preinst
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/preinst?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/preinst (added)
+++ incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/preinst Thu Sep 15 18:25:51 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 "HCatalog" --shell /bin/bash -M -r -g hadoop --home /usr/share/hcatalog hcat 2> /dev/null || :

Added: incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/prerm
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/prerm?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/prerm (added)
+++ incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/prerm Thu Sep 15 18:25:51 2011
@@ -0,0 +1,25 @@
+#!/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-hcatalog-env.sh \
+  --prefix=/usr \
+  --bin-dir=/usr/bin \
+  --sbin-dir=/usr/sbin \
+  --conf-dir=/etc/hcatalog \
+  --log-dir=/var/log/hcatalog \
+  --pid-dir=/var/run/hcatalog \
+  --uninstal

Added: incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/server.control
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/server.control?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/server.control (added)
+++ incubator/hcatalog/trunk/src/packages/deb/hcatalog.control/server.control Thu Sep 15 18:25:51 2011
@@ -0,0 +1,24 @@
+# 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: hcatalog-server
+Version: @version@
+Section: misc
+Priority: optional
+Provides: hcatalog-server
+Architecture: all
+Depends: hadoop, mysql-server, libmysql-java, hcatalog
+Maintainer: Apache Software Foundation <general@hadoop.apache.org>
+Description: The Apache HCatalog Metadata Store for data created using Apache Hadoop.
+Distribution: development

Added: incubator/hcatalog/trunk/src/packages/deb/init.d/hcatalog-server
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/deb/init.d/hcatalog-server?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/deb/init.d/hcatalog-server (added)
+++ incubator/hcatalog/trunk/src/packages/deb/init.d/hcatalog-server Thu Sep 15 18:25:51 2011
@@ -0,0 +1,139 @@
+#! /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:		hcatalog-server	
+# Required-Start:	$remote_fs $syslog
+# Required-Stop:	$remote_fs $syslog
+# Default-Start:	2 3 4 5
+# Default-Stop:		
+# Short-Description:	Apache HCatalog Server
+### END INIT INFO
+
+set -e
+
+# /etc/init.d/hcatalog-server: start and stop the Apache HCatalog Server daemon
+
+test -x /usr/sbin/hcat_server.sh || exit 0
+( /usr/bin/hcat.sh 2>&1 | grep -q hcat ) 2>/dev/null || exit 0
+
+umask 022
+
+. /lib/lsb/init-functions
+. /etc/hcatalog/hcat-env.sh
+
+# 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/hcatalog/hcatalog-server_not_to_be_run exists
+    if [ -e /etc/hcatalog/hcatalog-server_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 HCatalog server not in use (/etc/hcatalog/hcatalog-server_not_to_be_run)"
+	fi
+	exit 0
+    fi
+}
+
+check_privsep_dir() {
+    # Create the PrivSep empty dir if necessary
+    if [ ! -d ${HCAT_PID_DIR} ]; then
+	mkdir -p ${HCAT_PID_DIR}
+        chown root:hadoop ${HCAT_PID_DIR}
+	chmod 0775 ${HCAT_PID_DIR} 
+    fi
+}
+
+export PATH="${PATH:+$PATH:}/usr/sbin:/usr/bin"
+
+case "$1" in
+  start)
+	check_privsep_dir
+	check_for_no_start
+	log_daemon_msg "Starting Apache HCatalog Server" "hcatalog-server"
+	if start-stop-daemon --start --quiet --oknodo --pidfile ${HCAT_PID_DIR}/hcat.pid -c hcat -x /usr/sbin/hcat_server.sh -- --config ${HCAT_CONF_DIR} start; then
+	    log_end_msg 0
+	else
+	    log_end_msg 1
+	fi
+	;;
+  stop)
+	log_daemon_msg "Stopping Apache HCatalog Server" "hcatalog-server"
+	if start-stop-daemon --stop --quiet --oknodo --pidfile ${HCAT_PID_DIR}/hcat.pid; then
+	    log_end_msg 0
+	else
+	    log_end_msg 1
+	fi
+	;;
+
+  restart)
+	check_privsep_dir
+	log_daemon_msg "Restarting Apache HCatalog Server" "hcatalog-server"
+	start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile ${HCAT_PID_DIR}/hcat.pid
+	check_for_no_start log_end_msg
+	if start-stop-daemon --start --quiet --oknodo --pidfile ${HCAT_PID_DIR}/hcat.pid -c hcat -x /usr/sbin/hcat_server.sh -- --config ${HCAT_CONF_DIR} start; then
+	    log_end_msg 0
+	else
+	    log_end_msg 1
+	fi
+	;;
+
+  try-restart)
+	check_privsep_dir
+	log_daemon_msg "Restarting Apache HCatalog Server" "hcatalog-server"
+	set +e
+	start-stop-daemon --stop --quiet --retry 30 --pidfile ${HCAT_PID_DIR}/hcat.pid
+	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 ${HCAT_PID_DIR}/hcat.pid -c hcat -x /usr/sbin/hcat_server.sh -- --config ${HADOOP_CONF_DIR} 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 ${HCAT_PID_DIR}/hcat.pid ${JAVA_HOME}/bin/java hcat-server && exit 0 || exit $?
+	;;
+
+  *)
+	log_action_msg "Usage: /etc/init.d/hcatalog-server {start|stop|restart|try-restart|status}"
+	exit 1
+esac
+
+exit 0

Added: incubator/hcatalog/trunk/src/packages/rpm/init.d/hcatalog-server
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/rpm/init.d/hcatalog-server?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/rpm/init.d/hcatalog-server (added)
+++ incubator/hcatalog/trunk/src/packages/rpm/init.d/hcatalog-server Thu Sep 15 18:25:51 2011
@@ -0,0 +1,86 @@
+#!/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.
+
+# 
+# Starts a HCatalog Server
+# 
+# chkconfig: 2345 95 10
+# description: HCatalog Server
+
+source /etc/rc.d/init.d/functions
+source /etc/hcatalog/hcat-env.sh
+
+HCAT_PREFIX=/usr
+
+RETVAL=0
+PIDFILE="${HCAT_PID_DIR}/hcat.pid"
+desc="HCatalog Server daemon"
+
+start() {
+  echo -n $"Starting $desc (hcatalog-server): "
+  daemon --user hcat ${HCAT_PREFIX}/sbin/hcat_server.sh --config "${HCAT_CONF_DIR}" start
+  RETVAL=$?
+  echo
+  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/hcatalog-server
+  return $RETVAL
+}
+
+stop() {
+  echo -n $"Stopping $desc (hcatalog-server): "
+  daemon --user hcat ${HCAT_PREFIX}/sbin/hcat_server.sh --config "${HCAT_CONF_DIR}" stop
+  RETVAL=$?
+  sleep 5
+  echo
+  [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hcatalog-server $PIDFILE
+}
+
+restart() {
+  stop
+  start
+}
+
+checkstatus(){
+  status -p $PIDFILE ${JAVA_HOME}/bin/java
+  RETVAL=$?
+}
+
+condrestart(){
+  [ -e /var/lock/subsys/hcatalog-server ] && 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: incubator/hcatalog/trunk/src/packages/rpm/spec/hcatalog.spec
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/rpm/spec/hcatalog.spec?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/rpm/spec/hcatalog.spec (added)
+++ incubator/hcatalog/trunk/src/packages/rpm/spec/hcatalog.spec Thu Sep 15 18:25:51 2011
@@ -0,0 +1,173 @@
+#   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 Hcatalog version @version@
+#
+
+%define name         hcatalog
+%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 _lib_dir     %{_prefix}/lib
+%define _lib64_dir   %{_prefix}/lib64
+%define _libexec_dir %{_prefix}/libexec
+%define _log_dir     @package.log.dir@
+%define _pid_dir     @package.pid.dir@
+%define _sbin_dir    %{_prefix}/sbin
+%define _share_dir   %{_prefix}/share
+%define _var_dir     @package.var.dir@
+
+# Build time settings
+%define _build_dir  @package.build.dir@
+%define _final_name @final.name@
+%define debug_package %{nil}
+
+# Disable brp-java-repack-jars
+%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: Apache HCatalog is a table and storage management service for data created using Apache Hadoop.
+License: Apache License, Version 2.0
+URL: http://incubator.apache.org/hcatalog
+Vendor: Apache Software Foundation
+Group: Development/Libraries
+Name: %{name}
+Version: %{version}
+Release: %{release} 
+Source0: %{_final_name}.tar.gz
+Prefix: %{_prefix}
+Prefix: %{_conf_dir}
+Prefix: %{_log_dir}
+Prefix: %{_pid_dir}
+Buildroot: %{_build_dir}
+Requires: sh-utils, textutils, /usr/sbin/useradd, /usr/sbin/usermod, /sbin/chkconfig, /sbin/service
+AutoReqProv: no
+Provides: hcatalog
+
+%description
+The Apache HCatalog is a table and storage management service for data created using Apache Hadoop.
+
+%prep
+%setup -n %{_final_name}
+
+%build
+if [ -d ${RPM_BUILD_DIR}%{_prefix} ]; then
+  rm -rf ${RPM_BUILD_DIR}%{_prefix}
+fi
+
+if [ -d ${RPM_BUILD_DIR}%{_log_dir} ]; then
+  rm -rf ${RPM_BUILD_DIR}%{_log_dir}
+fi
+
+if [ -d ${RPM_BUILD_DIR}%{_conf_dir} ]; then
+  rm -rf ${RPM_BUILD_DIR}%{_conf_dir}
+fi
+
+if [ -d ${RPM_BUILD_DIR}%{_pid_dir} ]; then
+  rm -rf ${RPM_BUILD_DIR}%{_pid_dir}
+fi
+
+mkdir -p ${RPM_BUILD_DIR}%{_prefix}
+mkdir -p ${RPM_BUILD_DIR}%{_bin_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}%{_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/hcatalog-server ${RPM_BUILD_DIR}/etc/init.d/hcatalog-server
+chmod 0755 ${RPM_BUILD_DIR}/etc/init.d/hcatalog-server
+
+#########################
+#### INSTALL SECTION ####
+#########################
+%install
+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}/sbin/* ${RPM_BUILD_DIR}%{_sbin_dir}
+mv ${RPM_BUILD_DIR}/%{_final_name}/etc/hcatalog/* ${RPM_BUILD_DIR}%{_conf_dir}
+mv ${RPM_BUILD_DIR}/%{_final_name}/share/* ${RPM_BUILD_DIR}%{_share_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 "HCatalog" --shell /bin/bash -M -r -g hadoop --home /usr/share/hcatalog hcat 2> /dev/null || :
+
+%post
+bash ${RPM_INSTALL_PREFIX0}/sbin/update-hcatalog-env.sh \
+       --prefix=${RPM_INSTALL_PREFIX0} \
+       --bin-dir=${RPM_INSTALL_PREFIX0}/bin \
+       --sbin-dir=${RPM_INSTALL_PREFIX0}/sbin \
+       --conf-dir=${RPM_INSTALL_PREFIX1} \
+       --log-dir=${RPM_INSTALL_PREFIX2} \
+       --pid-dir=${RPM_INSTALL_PREFIX3} \
+       --mysql-dir=/usr/share/java
+
+if [ ! -f ${RPM_INSTALL_PREFIX1}/hive-site.xml ]; then
+	cp ${RPM_INSTALL_PREFIX1}/proto-hive-site.xml ${RPM_INSTALL_PREFIX1}/hive-site.xml
+fi
+
+echo HCatalog installed, please take a moment to verify config in ${RPM_INSTALL_PREFIX1}/hcat-env.sh and ${RPM_INSTALL_PREFIX1}/hive-site.xml
+%preun
+bash ${RPM_INSTALL_PREFIX0}/sbin/update-hcatalog-env.sh \
+       --prefix=${RPM_INSTALL_PREFIX0} \
+       --bin-dir=${RPM_INSTALL_PREFIX0}/bin \
+       --sbin-dir=${RPM_INSTALL_PREFIX0}/sbin \
+       --conf-dir=${RPM_INSTALL_PREFIX1} \
+       --log-dir=${RPM_INSTALL_PREFIX2} \
+       --pid-dir=${RPM_INSTALL_PREFIX3} \
+       --uninstall
+
+%files 
+%defattr(-,hcat,hadoop)
+%attr(0755,hcat,hadoop) %{_log_dir}
+%attr(0775,hcat,hadoop) %{_pid_dir}
+%config(noreplace) %{_conf_dir}
+%{_prefix}
+%exclude %{_prefix}/sbin/hcat_server.sh
+%exclude %{_prefix}/share/hcatalog/hcatalog-server-extensions*
+
+%package server
+Summary: HCatalog Server
+Group: System/Daemons
+Requires: hcatalog
+
+%description server
+HCatalog Metadata Store Server
+
+%files server
+%attr(0775,root,hadoop) /etc/init.d/hcatalog-server
+%{_prefix}/sbin/hcat_server.sh
+%{_prefix}/share/hcatalog/hcatalog-server-extensions*

Added: incubator/hcatalog/trunk/src/packages/templates/conf/hcat-env.sh.template
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/templates/conf/hcat-env.sh.template?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/templates/conf/hcat-env.sh.template (added)
+++ incubator/hcatalog/trunk/src/packages/templates/conf/hcat-env.sh.template Thu Sep 15 18:25:51 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.
+
+JAVA_HOME=${JAVA_HOME}
+HCAT_PID_DIR=${HCAT_PID_DIR}
+HCAT_LOG_DIR=${HCAT_LOG_DIR}
+HCAT_CONF_DIR=${HCAT_CONF_DIR}
+DBROOT=${DBROOT}
+USER=hcat
+METASTORE_PORT=9933

Added: incubator/hcatalog/trunk/src/packages/update-hcatalog-env.sh
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/packages/update-hcatalog-env.sh?rev=1171212&view=auto
==============================================================================
--- incubator/hcatalog/trunk/src/packages/update-hcatalog-env.sh (added)
+++ incubator/hcatalog/trunk/src/packages/update-hcatalog-env.sh Thu Sep 15 18:25:51 2011
@@ -0,0 +1,180 @@
+#!/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 hcat-env.sh and symlinkis directories for 
+# relocating RPM locations.
+
+usage() {
+  echo "
+usage: $0 <parameters>
+  Required parameters:
+     --prefix=PREFIX             path to install into
+
+  Optional parameters:
+     --arch=i386                 OS Architecture
+     --bin-dir=PREFIX/bin        Executable directory
+     --conf-dir=/etc/hcatalog    Configuration directory
+     --log-dir=/var/log/hcatalog Log directory
+     --mysql-dir=/usr/share/java MySQL connector directory
+     --pid-dir=/var/run          PID file location
+     --sbin-dir=PREFIX/sbin      System executable directory
+  "
+  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 'bin-dir:' \
+  -l 'conf-dir:' \
+  -l 'lib-dir:' \
+  -l 'log-dir:' \
+  -l 'pid-dir:' \
+  -l 'mysql-dir:' \
+  -l 'sbin-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
+      ;;
+    --bin-dir)
+      BIN_DIR=$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
+      ;;
+    --mysql-dir)
+      MYSQL_DIR=$2 ; shift 2
+      ;;
+    --sbin-dir)
+      SBIN_DIR=$2 ; shift 2
+      ;;
+    --uninstall)
+      UNINSTALL=1; shift
+      ;;
+    --)
+      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}
+HCAT_PREFIX=$PREFIX
+HCAT_BIN_DIR=${BIN_DIR:-$PREFIX/bin}
+HCAT_CONF_DIR=${CONF_DIR:-$PREFIX/etc/hcatalog}
+HCAT_LIB_DIR=${LIB_DIR:-$PREFIX/lib}
+HCAT_LOG_DIR=${LOG_DIR:-$PREFIX/var/log}
+HCAT_PID_DIR=${PID_DIR:-$PREFIX/var/run}
+HCAT_SBIN_DIR=${SBIN_DIR:-$PREFIX/sbin}
+DBROOT=${MYSQL_DIR:-/usr/sharejava}
+UNINSTALL=${UNINSTALL:-0}
+
+if [ "${ARCH}" != "i386" ]; then
+  HCAT_LIB_DIR=${HCAT_LIB_DIR}64
+fi
+
+if [ "${UNINSTALL}" -eq "1" ]; then
+  # Remove symlinks
+  if [ "${HCAT_CONF_DIR}" != "${HCAT_PREFIX}/etc/hcatalog" ]; then
+    rm -rf ${HCAT_PREFIX}/etc/hcatalog
+  fi
+  rm -f /etc/default/hcat-env.sh
+  rm -f /etc/profile.d/hcat-env.sh
+else
+  # Create symlinks
+  if [ "${HCAT_CONF_DIR}" != "${HCAT_PREFIX}/etc/hcatalog" ]; then
+    mkdir -p ${HCAT_PREFIX}/etc
+    ln -sf ${HCAT_CONF_DIR} ${HCAT_PREFIX}/etc/hcatalog
+  fi
+  ln -sf ${HCAT_CONF_DIR}/hcat-env.sh /etc/default/hcat-env.sh
+  ln -sf ${HCAT_CONF_DIR}/hcat-env.sh /etc/profile.d/hcat-env.sh
+
+  if [ ! -e "${HCAT_CONF_DIR}/proto-hive-site.xml" ]; then
+    cp ${HCAT_CONF_DIR}/proto-hive-site.xml ${HCAT_CONF_DIR}/hive-site.xml
+    chown hcat:hadoop ${HCAT_CONF_DIR}/hive-site.xml
+    chmod 700 ${HCAT_CONF_DIR}/hive-site.xml
+  fi
+
+  mkdir -p ${HCAT_LOG_DIR}
+  chown hcat:hadoop ${HCAT_LOG_DIR}
+  chmod 775 ${HCAT_LOG_DIR}
+
+  if [ ! -d ${HCAT_PID_DIR} ]; then
+    mkdir -p ${HCAT_PID_DIR}
+    chown hcat:hadoop ${HCAT_PID_DIR}
+    chmod 775 ${HCAT_PID_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 ${HCAT_PREFIX}/share/hcatalog/templates/conf/hcat-env.sh.template $TFILE
+  cp ${TFILE} ${HCAT_CONF_DIR}/hcat-env.sh
+  rm -f ${TFILE}
+fi



Mime
View raw message