You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hcatalog-commits@incubator.apache.org by ha...@apache.org on 2011/06/01 16:23:30 UTC

svn commit: r1130208 - in /incubator/hcatalog/trunk: bin/hcat.sh build.xml

Author: hashutosh
Date: Wed Jun  1 16:23:29 2011
New Revision: 1130208

URL: http://svn.apache.org/viewvc?rev=1130208&view=rev
Log:
HCATALOG-20: Create a package target

Modified:
    incubator/hcatalog/trunk/bin/hcat.sh
    incubator/hcatalog/trunk/build.xml

Modified: incubator/hcatalog/trunk/bin/hcat.sh
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/bin/hcat.sh?rev=1130208&r1=1130207&r2=1130208&view=diff
==============================================================================
--- incubator/hcatalog/trunk/bin/hcat.sh (original)
+++ incubator/hcatalog/trunk/bin/hcat.sh Wed Jun  1 16:23:29 2011
@@ -16,23 +16,78 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-HCAT_DIR=`dirname "$0"`
+# Resolve our absolute path                                                      
+# resolve links - $0 may be a softlink                                           
+this="${BASH_SOURCE-$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=`unset CDPATH; cd "$bin"; pwd`                                               
+this="$bin/$script"                                                              
+                                                                                 
+# the root of the HCatalog installation                                          
+export HCAT_HOME=`dirname "$this"`/..                                            
+
+# filter debug command line parameter
+debug=false
+
+for f in $@; do
+     if [[ $f = "-secretDebugCmd" ]]; then
+        debug=true
+     else
+        remaining="${remaining} $f"
+     fi
+done
+
+# Find our hcatalog jar
+HCAT_JAR=$HCAT_HOME/lib/hcatalog-*.jar
 
-HCAT_JAR_LOC=`find . -name "hcatalog*.jar"`
+# Add all of the other jars to our classpath
+for jar in $HCAT_HOME/lib/*.jar ; do
+	HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$jar
+done
 
-HADOOP_CLASSPATH=$HADOOP_CLASSPATH:${HCAT_JAR_LOC}:../lib/commons-cli-2.0-SNAPSHOT.jar:../build/cli/hive-cli-0.7.0.jar:../ql/lib/antlr-runtime-3.0.1.jar
+# Put our config file in the classpath
+HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:${HCAT_HOME}/conf/hive-site.xml
 
 export HADOOP_CLASSPATH=$HADOOP_CLASSPATH
 
-for f in `ls ../build/dist/lib/*.jar`; do 
-  HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$f 
-done
+# Find our Thrift address from the config file
+THRIFT=`sed -n '/<name>hive.metastore.uris<\/name>/ {
+      n
+      s/.*<value>\(.*\)<\/value>.*/\1/p
+      }' $HCAT_HOME/conf/hive-site.xml`
+HADOOP_OPTS="$HADOOP_OPTS -Dhive.metastore.uris=$THRIFT " 
+
+# Find our Warehouse dir from the config file
+WAREHOUSE_DIR=`sed -n '/<name>hive.metastore.warehouse.dir<\/name>/ {
+      n
+      s/.*<value>\(.*\)<\/value>.*/\1/p
+      }' $HCAT_HOME/conf/hive-site.xml`
+HADOOP_OPTS="$HADOOP_OPTS -Dhive.metastore.warehouse.dir=$WAREHOUSE_DIR " 
 
-HADOOP_OPTS="$HADOOP_OPTS -Dhive.metastore.uris=thrift://localhost:9083 " 
 
 export HADOOP_OPTS=$HADOOP_OPTS
 
-exec $HADOOP_HOME/bin/hadoop jar  ${HCAT_JAR_LOC} org.apache.hcatalog.cli.HCatCli "$@"
+# 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 "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 $remaining
+fi
 
 # Above is the recommended way to launch hcatalog cli. If it doesnt work, you can try the following:
 # java -Dhive.metastore.uris=thrift://localhost:9083 -cp ../lib/commons-logging-1.0.4.jar:../build/hadoopcore/hadoop-0.20.0/hadoop-0.20.0-core.jar:../lib/commons-cli-2.0-SNAPSHOT.jar:../build/cli/hive-cli-0.7.0.jar:../ql/lib/antlr-runtime-3.0.1.jar:$HCAT_JAR_LOC org.apache.hcatalog.cli.HCatCli "$@"

Modified: incubator/hcatalog/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/build.xml?rev=1130208&r1=1130207&r2=1130208&view=diff
==============================================================================
--- incubator/hcatalog/trunk/build.xml (original)
+++ incubator/hcatalog/trunk/build.xml Wed Jun  1 16:23:29 2011
@@ -32,8 +32,10 @@
 
   <!-- hive properties -->
   <property name="hive.root" value="${basedir}/hive/external"/>
+  <property name="hive.version" value="0.8.0"/>
 
   <!-- build properties -->
+  <property name="lib.dir" value="${basedir}/lib/" />
   <property name="src.dir"  location="${basedir}/src/java"/>
   <property name="docs.src" value="${basedir}/src/docs"/>
   <property name="build.dir" value="${basedir}/build"/>
@@ -353,4 +355,154 @@
     <fail message="'forrest.home' is not defined. Please pass -Dforrest.home=&lt;base of Apache Forrest installation&gt; to Ant on the command-line." />
   </target>
 
+  <!--
+  ===============================================================================
+  Distribution Section
+  ===============================================================================
+  -->
+  <target name="package" depends="fatjar, docs" description="Create an HCatalog release">
+    <mkdir dir="${dist.dir}" />
+    <mkdir dir="${dist.dir}/lib" />
+    <mkdir dir="${dist.dir}/conf" />
+    <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" />
+
+    <copy todir="${dist.dir}/lib" includeEmptyDirs="false">
+      <fileset dir="${lib.dir}"/>
+
+      <fileset file="hcatalog-*.jar"/>
+
+      <fileset dir="hive/external/build/ivy/lib/default">
+        <include name="jdo2-api-*.jar"/>
+        <include name="log4j-*.jar"/>
+        <include name="datanucleus-connectionpool-*.jar"/>
+        <include name="datanucleus-core-*.jar"/>
+        <include name="datanucleus-rdbms-*.jar"/>
+        <include name="datanucleus-enhancer-*.jar"/>
+        <include name="commons-cli-*.jar"/>
+        <include name="commons-pool-*.jar"/>
+        <include name="commons-dbcp-*.jar"/>
+        <include name="guava-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/build/common">
+        <include name="hive-common-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/build/cli">
+        <include name="hive-cli-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/build/service">
+        <include name="hive-service-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/build/serde">
+        <include name="hive-serde-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/build/ql">
+        <include name="hive-exec-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/build/metastore">
+        <include name="hive-metastore-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/lib">
+        <include name="commons-collections-*.jar"/>
+        <include name="commons-logging-*.jar"/>
+        <include name="commons-logging-api-*.jar"/>
+        <include name="commons-lang-*.jar"/>
+        <include name="asm-api-*.jar"/>
+        <include name="derby-*.jar"/>
+        <include name="thrift-fb303-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/cli/lib">
+        <include name="jline-*.jar"/>
+      </fileset>
+
+      <fileset dir="hive/external/ql/lib">
+        <include name="antlr-runtime-*.jar"/>
+      </fileset>
+    </copy>
+
+    <copy todir="${dist.dir}/ivy">
+      <fileset dir="ivy" />
+    </copy>
+
+    <copy todir="${dist.dir}/bin">
+      <fileset file="bin/hcat.sh"/>
+      <fileset file="hive/external/bin/hive"/>
+      <fileset file="hive/external/bin/hive-config.sh"/>
+    </copy>
+
+    <copy todir="${dist.dir}/bin/ext">
+      <fileset file="hive/external/bin/ext/metastore.sh"/>
+    </copy>
+
+    <copy todir="${dist.dir}/bin/ext/util">
+      <fileset file="hive/external/bin/ext/util/execHiveCmd.sh"/>
+    </copy>
+
+    <copy todir="${dist.dir}/docs">
+      <fileset dir="${build.docs}" />
+    </copy>
+
+    <copy todir="${dist.dir}/conf">
+      <fileset dir="conf" />
+      <fileset file="hive/external/conf/hive-default.xml"/>
+    </copy>
+    <copy todir="${dist.dir}/scripts"
+      file="hive/external/metastore/scripts/upgrade/mysql/hive-schema-0.7.0.mysql.sql"/>
+
+    <copy todir="${dist.dir}/src" includeEmptyDirs="true">
+      <fileset dir="${src.dir}" />
+    </copy>
+
+    <copy todir="${dist.dir}/test" includeEmptyDirs="true">
+      <fileset dir="${test.src.dir}" />
+    </copy>
+
+    <copy todir="${dist.dir}/" file="build.xml" />
+    <copy todir="${dist.dir}/" file="ivy.xml" />
+
+    <copy todir="${dist.dir}">
+      <fileset dir=".">
+        <include name="*.txt" />
+      </fileset>
+    </copy>
+
+    <copy todir="${dist.dir}/license">
+      <fileset dir="license" />
+    </copy>
+
+    <chmod perm="ugo+x" type="file">
+      <fileset dir="${dist.dir}/bin" />
+    </chmod>
+
+    </target>
+
+    <!-- ================================================================== -->
+    <!-- Make release tarball                                               -->
+    <!-- ================================================================== -->
+    <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">
+                <exclude name="${final.name}/bin/*" />
+                <include name="${final.name}/**" />
+            </tarfileset>
+            <tarfileset dir="${build.dir}" mode="755">
+                <include name="${final.name}/bin/*" />
+            </tarfileset>
+        </tar>
+    </target>
+ 
 </project>