Author: daijy
Date: Tue Jul 26 01:39:02 2011
New Revision: 1150968
URL: http://svn.apache.org/viewvc?rev=1150968&view=rev
Log:
PIG-1857: Create an package integration project
Added:
pig/trunk/src/packages/
pig/trunk/src/packages/deb/
pig/trunk/src/packages/deb/pig.control/
pig/trunk/src/packages/deb/pig.control/conffile
pig/trunk/src/packages/deb/pig.control/control
pig/trunk/src/packages/deb/pig.control/postinst
pig/trunk/src/packages/deb/pig.control/postrm
pig/trunk/src/packages/deb/pig.control/preinst
pig/trunk/src/packages/deb/pig.control/prerm
pig/trunk/src/packages/rpm/
pig/trunk/src/packages/rpm/spec/
pig/trunk/src/packages/rpm/spec/pig.spec
pig/trunk/src/packages/templates/
pig/trunk/src/packages/templates/conf/
pig/trunk/src/packages/templates/conf/pig-env.sh
pig/trunk/src/packages/update-pig-env.sh
Modified:
pig/trunk/CHANGES.txt
pig/trunk/bin/pig
pig/trunk/build.xml
pig/trunk/ivy.xml
pig/trunk/ivy/libraries.properties
Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1150968&r1=1150967&r2=1150968&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Tue Jul 26 01:39:02 2011
@@ -24,6 +24,8 @@ INCOMPATIBLE CHANGES
IMPROVEMENTS
+PIG-1857: Create an package integration project (eyang via daijy)
+
PIG-1904: Default split destination (azaroth via thejas)
PIG-2125: Make Pig work with hadoop .NEXT (daijy)
Modified: pig/trunk/bin/pig
URL: http://svn.apache.org/viewvc/pig/trunk/bin/pig?rev=1150968&r1=1150967&r2=1150968&view=diff
==============================================================================
--- pig/trunk/bin/pig (original)
+++ pig/trunk/bin/pig Tue Jul 26 01:39:02 2011
@@ -57,20 +57,10 @@ done
# 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`
+bin=$(cd -P -- "$(dirname -- "$this")" && pwd -P)
+script="$(basename -- "$this")"
this="$bin/$script"
# the root of the Pig installation
@@ -87,9 +77,9 @@ then
PIG_CONF_DIR=$confdir
fi
fi
-
+
# Allow alternate conf dir location.
-PIG_CONF_DIR="${PIG_CONF_DIR:-$PIG_HOME/conf}"
+PIG_CONF_DIR="${PIG_CONF_DIR:-$PIG_HOME/etc/pig}"
if [ -f "${PIG_CONF_DIR}/pig-env.sh" ]; then
. "${PIG_CONF_DIR}/pig-env.sh"
@@ -118,6 +108,11 @@ fi
CLASSPATH="${PIG_CONF_DIR}"
CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar
+# add user-specified CLASSPATH
+if [ "$PIG_CLASSPATH" != "" ]; then
+ CLASSPATH=${CLASSPATH}:${PIG_CLASSPATH}
+fi
+
# for developers, add Pig classes to CLASSPATH
if [ -d "$PIG_HOME/build/classes" ]; then
CLASSPATH=${CLASSPATH}:$PIG_HOME/build/classes
@@ -130,7 +125,7 @@ fi
IFS=
# for releases, add core pig to CLASSPATH
-for f in $PIG_HOME/pig-*-core.jar; do
+for f in $PIG_HOME/share/pig/pig-*-core.jar; do
CLASSPATH=${CLASSPATH}:$f;
done
@@ -139,7 +134,58 @@ for f in $PIG_HOME/build/pig-*-SNAPSHOT.
CLASSPATH=${CLASSPATH}:$f;
done
-# Set the version for Hadoop, default to 17
+# locate Hadoop
+# For Hadoop 0.20.203+
+#
+if [ -d "${PIG_HOME}/share/hadoop" ]; then
+ for f in ${PIG_HOME}/share/hadoop/hadoop*.jar; do
+ CLASSPATH=${CLASSPATH}:$f;
+ done
+ for f in ${PIG_HOME}/share/hadoop/lib/*.jar; do
+ CLASSPATH=${CLASSPATH}:$f;
+ done
+fi
+
+
+# For Hadoop 0.23.0+
+#
+#if [ -d "${PIG_HOME}/share/hadoop/common" ]; then
+# for f in ${PIG_HOME}/share/hadoop/common/hadoop*.jar; do
+# CLASSPATH=${CLASSPATH}:$f;
+# done
+#fi
+#
+#if [ -d "${PIG_HOME}/share/hadoop/hdfs" ]; then
+# for f in ${PIG_HOME}/share/hadoop/hdfs/hadoop*.jar; do
+# CLASSPATH=${CLASSPATH}:$f;
+# done
+#fi
+#
+#if [ -d "${PIG_HOME}/share/hadoop/mapreduce" ]; then
+# for f in ${PIG_HOME}/share/hadoop/mapreduce/hadoop*.jar; do
+# CLASSPATH=${CLASSPATH}:$f;
+# done
+#fi
+
+if [ -d "${PIG_HOME}/etc/hadoop" ]; then
+ CLASSPATH=${CLASSPATH}:${PIG_HOME}/etc/hadoop;
+fi
+
+# locate ZooKeeper
+if [ -d "${PIG_HOME}/share/zookeeper" ]; then
+ for f in ${PIG_HOME}/share/zookeeper/zookeeper-*.jar; do
+ CLASSPATH=${CLASSPATH}:$f
+ done
+fi
+
+# locate HBase
+if [ -d "${PIG_HOME}/share/hbase" ]; then
+ for f in ${PIG_HOME}/share/hbase/hbase-*.jar; do
+ CLASSPATH=${CLASSPATH}:$f
+ done
+fi
+
+# Set the version for Hadoop, default to 20
PIG_HADOOP_VERSION="${PIG_HADOOP_VERSION:-20}"
# add libs to CLASSPATH. There can be more than one version of the hadoop
# libraries in the lib dir, so don't blindly add them all. Only add the one
@@ -160,12 +206,7 @@ done
# if using HBase, likely want to include HBase config
HBASE_CONF_DIR=${HBASE_CONF_DIR:-/etc/hbase}
if [ -n "$HBASE_CONF_DIR" ] && [ -d "$HBASE_CONF_DIR" ]; then
- CLASSPATH=$HBASE_CONF_DIR:$CLASSPATH
-fi
-
-# add user-specified CLASSPATH last
-if [ "$PIG_CLASSPATH" != "" ]; then
- CLASSPATH=${CLASSPATH}:${PIG_CLASSPATH}
+ CLASSPATH=$HBASE_CONF_DIR:$CLASSPATH
fi
# default log directory & file
Modified: pig/trunk/build.xml
URL: http://svn.apache.org/viewvc/pig/trunk/build.xml?rev=1150968&r1=1150967&r2=1150968&view=diff
==============================================================================
--- pig/trunk/build.xml (original)
+++ pig/trunk/build.xml Tue Jul 26 01:39:02 2011
@@ -28,11 +28,12 @@
-
-
-
-
-
+
+
+
+
+
+
@@ -200,6 +201,14 @@
+
+
+
+
+
+
+
+
@@ -426,7 +435,7 @@
-
+
@@ -759,78 +768,83 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
-
-
+
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -842,7 +856,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Modified: pig/trunk/ivy.xml
URL: http://svn.apache.org/viewvc/pig/trunk/ivy.xml?rev=1150968&r1=1150967&r2=1150968&view=diff
==============================================================================
--- pig/trunk/ivy.xml (original)
+++ pig/trunk/ivy.xml Tue Jul 26 01:39:02 2011
@@ -126,5 +126,8 @@
+
+
Modified: pig/trunk/ivy/libraries.properties
URL: http://svn.apache.org/viewvc/pig/trunk/ivy/libraries.properties?rev=1150968&r1=1150967&r2=1150968&view=diff
==============================================================================
--- pig/trunk/ivy/libraries.properties (original)
+++ pig/trunk/ivy/libraries.properties Tue Jul 26 01:39:02 2011
@@ -16,7 +16,7 @@
#These are the versions of our dependencies (in alphabetical order)
apacheant.version=1.7.1
antlr.version=2.7.6
-pig.version=0.8.0
+pig.version=0.9.0
avro.version=1.4.1
commons-beanutils.version=1.7.0
@@ -33,6 +33,7 @@ hbase.version=0.90.0
hsqldb.version=1.8.0.10
jackson.version=1.6.0
javacc.version=4.2
+jdeb.version=0.8
jdiff.version=1.0.9
jetty-util.version=6.1.14
jline.version=0.9.94
Added: pig/trunk/src/packages/deb/pig.control/conffile
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/deb/pig.control/conffile?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/deb/pig.control/conffile (added)
+++ pig/trunk/src/packages/deb/pig.control/conffile Tue Jul 26 01:39:02 2011
@@ -0,0 +1 @@
+/etc/pig
Added: pig/trunk/src/packages/deb/pig.control/control
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/deb/pig.control/control?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/deb/pig.control/control (added)
+++ pig/trunk/src/packages/deb/pig.control/control Tue Jul 26 01:39:02 2011
@@ -0,0 +1,9 @@
+Package: pig
+Version: @version@
+Section: misc
+Priority: optional
+Architecture: all
+Depends: sun-java6-jre, hadoop
+Maintainer: Apache Software Foundation
+Description: Apache Pig is a platform for analyzing large data sets that consists of a high-level language for expressing data analysis programs, coupled with infrastructure for evaluating these programs. The salient property of Pig programs is that their structure is amenable to substantial parallelization, which in turns enables them to handle very large data sets.
+Distribution: development
Added: pig/trunk/src/packages/deb/pig.control/postinst
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/deb/pig.control/postinst?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/deb/pig.control/postinst (added)
+++ pig/trunk/src/packages/deb/pig.control/postinst Tue Jul 26 01:39:02 2011
@@ -0,0 +1,22 @@
+#!/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-pig-env.sh \
+ --prefix=/usr \
+ --bin-dir=/usr/bin \
+ --conf-dir=/etc/pig \
+ --log-dir=/var/log/pig
Added: pig/trunk/src/packages/deb/pig.control/postrm
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/deb/pig.control/postrm?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/deb/pig.control/postrm (added)
+++ pig/trunk/src/packages/deb/pig.control/postrm Tue Jul 26 01:39:02 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: pig/trunk/src/packages/deb/pig.control/preinst
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/deb/pig.control/preinst?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/deb/pig.control/preinst (added)
+++ pig/trunk/src/packages/deb/pig.control/preinst Tue Jul 26 01:39:02 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.
+
+getent group hadoop 2>/dev/null >/dev/null || /usr/sbin/groupadd -r hadoop
Added: pig/trunk/src/packages/deb/pig.control/prerm
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/deb/pig.control/prerm?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/deb/pig.control/prerm (added)
+++ pig/trunk/src/packages/deb/pig.control/prerm Tue Jul 26 01:39:02 2011
@@ -0,0 +1,22 @@
+#!/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-pig-env.sh \
+ --prefix=/usr \
+ --bin-dir=/usr/bin \
+ --conf-dir=/etc/pig \
+ --log-dir=/var/log/pig \
+ --uninstal
Added: pig/trunk/src/packages/rpm/spec/pig.spec
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/rpm/spec/pig.spec?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/rpm/spec/pig.spec (added)
+++ pig/trunk/src/packages/rpm/spec/pig.spec Tue Jul 26 01:39:02 2011
@@ -0,0 +1,138 @@
+# 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 Pig version @version@
+#
+
+%define name pig
+%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/pig
+%define _src_dir %{_prefix}/src
+%define _var_dir %{_prefix}/var/lib
+
+# 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}
+
+Summary: Apache Pig is a platform for analyzing large data sets that consists of a high-level language for expressing data analysis programs.
+License: Apache License, Version 2.0
+URL: http://pig.apache.org/
+Vendor: Apache Software Foundation
+Group: Development/Libraries
+Name: %{name}
+Version: %{version}
+Release: %{release}
+Source0: %{_final_name}.tar.gz
+Source1: %{_final_name}-withouthadoop.jar
+Prefix: %{_prefix}
+Prefix: %{_conf_dir}
+Prefix: %{_log_dir}
+Buildroot: %{_build_dir}
+Requires: hadoop, sh-utils, textutils
+AutoReqProv: no
+Provides: pig
+
+%description
+Apache Pig is a platform for analyzing large data sets that consists of a high-level language for expressing data analysis programs, coupled with infrastructure for evaluating these programs. The salient property of Pig programs is that their structure is amenable to substantial parallelization, which in turns enables them to handle very large data sets.
+
+#%package conf-pseudo
+#Summary: Default Hadoop configuration templates
+#Group: System/Daemons
+#Requires: %{name} == %{version}
+#
+#%description conf-pseudo
+#Installation of this RPM will setup your machine to run in pseudo-distributed mode
+#where each Hadoop daemon runs in a separate Java process.
+
+%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}%{_log_dir}
+mkdir -p ${RPM_BUILD_DIR}%{_conf_dir}
+
+#########################
+#### INSTALL SECTION ####
+#########################
+%install
+mv ${RPM_BUILD_DIR}/%{_final_name}/etc/pig/* ${RPM_BUILD_DIR}%{_conf_dir}
+rm -rf ${RPM_BUILD_DIR}/%{_final_name}/etc/pig
+mv ${RPM_BUILD_DIR}/%{_final_name}/* ${RPM_BUILD_DIR}%{_prefix}
+cp -f ${RPM_BUILD_DIR}/../SOURCES/%{_final_name}-withouthadoop.jar ${RPM_BUILD_DIR}%{_share_dir}/%{_final_name}-core.jar
+
+%pre
+
+%post
+bash ${RPM_INSTALL_PREFIX0}/sbin/update-pig-env.sh \
+ --prefix=${RPM_INSTALL_PREFIX0} \
+ --bin-dir=${RPM_INSTALL_PREFIX0}/bin \
+ --conf-dir=${RPM_INSTALL_PREFIX1} \
+ --log-dir=${RPM_INSTALL_PREFIX2}
+
+%preun
+bash ${RPM_INSTALL_PREFIX0}/sbin/update-pig-env.sh \
+ --prefix=${RPM_INSTALL_PREFIX0} \
+ --bin-dir=${RPM_INSTALL_PREFIX0}/bin \
+ --conf-dir=${RPM_INSTALL_PREFIX1} \
+ --log-dir=${RPM_INSTALL_PREFIX2} \
+ --uninstall
+
+%files
+%defattr(-,root,root)
+%attr(0755,root,hadoop) %{_log_dir}
+%config %{_conf_dir}
+%{_prefix}
+
Added: pig/trunk/src/packages/templates/conf/pig-env.sh
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/templates/conf/pig-env.sh?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/templates/conf/pig-env.sh (added)
+++ pig/trunk/src/packages/templates/conf/pig-env.sh Tue Jul 26 01:39:02 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}
Added: pig/trunk/src/packages/update-pig-env.sh
URL: http://svn.apache.org/viewvc/pig/trunk/src/packages/update-pig-env.sh?rev=1150968&view=auto
==============================================================================
--- pig/trunk/src/packages/update-pig-env.sh (added)
+++ pig/trunk/src/packages/update-pig-env.sh Tue Jul 26 01:39:02 2011
@@ -0,0 +1,153 @@
+#!/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 pig-env.sh and symlinkis directories for
+# relocating package locations.
+
+usage() {
+ echo "
+usage: $0
+ Required parameters:
+ --prefix=PREFIX path to install into
+
+ Optional parameters:
+ --arch=i386 OS Architecture
+ --bin-dir=PREFIX/bin Executable directory
+ --conf-dir=/etc/pig Configuration directory
+ --log-dir=/var/log/pig Log 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 '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
+ ;;
+ --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}
+BIN_DIR=${BIN_DIR:-$PREFIX/bin}
+CONF_DIR=${CONF_DIR:-$PREFIX/etc/pig}
+LIB_DIR=${LIB_DIR:-$PREFIX/share/pig}
+LOG_DIR=${LOG_DIR:-$PREFIX/var/log}
+UNINSTALL=${UNINSTALL:-0}
+PIG_HOME=${PREFIX}
+
+if [ "${ARCH}" != "i386" ]; then
+ LIB_DIR=${LIB_DIR}64
+fi
+
+. /etc/default/hadoop-env.sh
+
+if [ -e /etc/default/hbase-env.sh ]; then
+ . /etc/default/hbase-env.sh
+fi
+
+if [ "${UNINSTALL}" -eq "1" ]; then
+ # Remove symlinks
+ if [ "${CONF_DIR}" != "${PREFIX}/etc/pig" ]; then
+ rm -f ${PREFIX}/etc/pig
+ fi
+else
+ # Create symlinks
+ if [ "${CONF_DIR}" != "${PREFIX}/etc/pig" ]; then
+ if [ ! -e ${PREFIX}/etc/pig ]; then
+ ln -sf ${CONF_DIR} ${PREFIX}/etc/pig
+ fi
+ fi
+
+ mkdir -p ${LOG_DIR}
+ chown root:hadoop ${LOG_DIR}
+ chmod 777 ${LOG_DIR}
+
+ TFILE="/tmp/$(basename $0).$$.tmp"
+ if [ -z "${JAVA_HOME}" ]; then
+ if [ -e /etc/lsb-release ]; then
+ JAVA_HOME=`update-alternatives --config java | grep java | cut -f2 -d':' | cut -f2 -d' ' | sed -e 's/\/bin\/java//'`
+ else
+ JAVA_HOME=/usr/java/default
+ fi
+ fi
+ template_generator ${PREFIX}/share/pig/templates/conf/pig-env.sh $TFILE
+ cp ${TFILE} ${CONF_DIR}/pig-env.sh
+ rm -f ${TFILE}
+fi