From 0580bbe7d71c36676441e27766fb519df198b52c Mon Sep 17 00:00:00 2001 From: iberezovskiy Date: Tue, 13 May 2014 18:36:00 +0400 Subject: [PATCH] Modify whole java element to support JAVA_TARGET_LOCATION This patch modifies the common "java" element in order to allow users to specify the directory that will contain the JDK install and this support is for all install types now. Change-Id: I5ba04ba5e22c7f5f5a6455669bbe8509c042a893 --- diskimage-create/README.rst | 2 +- .../hadoop-cdh/post-install.d/40-setup-hadoop | 3 ++- .../hadoop/post-install.d/40-setup-hadoop | 4 ++- elements/java/README.md | 2 -- elements/java/install.d/33-java | 26 +++++++++---------- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/diskimage-create/README.rst b/diskimage-create/README.rst index 0af6b0f4..29f8f2a2 100644 --- a/diskimage-create/README.rst +++ b/diskimage-create/README.rst @@ -7,7 +7,7 @@ NOTE: You should use Ubuntu or Fedora host OS for building images, CentOS as a h For users: -1. Use your environment (export / setenv) to alter the scripts behavior. Environment variables the script accepts are 'DIB_HADOOP_VERSION_1' and 'DIB_HADOOP_VERSION_2', 'JAVA_DOWNLOAD_URL', 'OOZIE_DOWNLOAD_URL', 'HIVE_VERSION', 'ubuntu_[vanilla|spark]_hadoop_[1|2]_image_name', 'fedora_vanilla_hadoop_[1|2]_image_name', 'centos_[vanilla|hdp]_[hadoop_1|hadoop_2|plain]_image_name'. +1. Use your environment (export / setenv) to alter the scripts behavior. Environment variables the script accepts are 'DIB_HADOOP_VERSION_1' and 'DIB_HADOOP_VERSION_2', 'JAVA_DOWNLOAD_URL', 'JAVA_TARGET_LOCATION', 'OOZIE_DOWNLOAD_URL', 'HIVE_VERSION', 'ubuntu_[vanilla|spark]_hadoop_[1|2]_image_name', 'fedora_vanilla_hadoop_[1|2]_image_name', 'centos_[vanilla|hdp]_[hadoop_1|hadoop_2|plain]_image_name'. 2. For creating all images just clone this repository and run script. diff --git a/elements/hadoop-cdh/post-install.d/40-setup-hadoop b/elements/hadoop-cdh/post-install.d/40-setup-hadoop index e174d456..154d2036 100755 --- a/elements/hadoop-cdh/post-install.d/40-setup-hadoop +++ b/elements/hadoop-cdh/post-install.d/40-setup-hadoop @@ -52,8 +52,9 @@ rm -r $tmp_dir echo "Pre-configuring Hadoop" +: ${JAVA_TARGET_LOCATION:="/usr/java"} # Find JAVA_HOME... -JAVA_HOME=$(find $TARGET_ROOT/usr/java/ -maxdepth 1 -name "jdk*") +JAVA_HOME=$(find $TARGET_ROOT$JAVA_TARGET_LOCATION/ -maxdepth 1 -name "jdk*") if [ -z "$JAVA_HOME" ]; then case "$distro" in diff --git a/elements/hadoop/post-install.d/40-setup-hadoop b/elements/hadoop/post-install.d/40-setup-hadoop index fd2ec005..ffbab828 100755 --- a/elements/hadoop/post-install.d/40-setup-hadoop +++ b/elements/hadoop/post-install.d/40-setup-hadoop @@ -20,7 +20,7 @@ function download_hadoop_package() function find_java_home() { - JAVA_HOME=$(find $TARGET_ROOT/usr/java/ -maxdepth 1 -name "jdk*") + JAVA_HOME=$(find $TARGET_ROOT$JAVA_TARGET_LOCATION/ -maxdepth 1 -name "jdk*") if [ -z "$JAVA_HOME" ]; then case "$distro" in @@ -151,6 +151,8 @@ case "$distro" in ;; esac +: ${JAVA_TARGET_LOCATION:="/usr/java"} + if [[ "$DIB_HADOOP_VERSION" < "2.0.0" ]]; then install_hadoop_v1 else diff --git a/elements/java/README.md b/elements/java/README.md index 8a66009f..a322e124 100644 --- a/elements/java/README.md +++ b/elements/java/README.md @@ -17,5 +17,3 @@ pointing to a file that will be placed in JAVA_FILE (see 1.) configured to install to a specific location. Set the JAVA_TARGET_LOCATION variable in order to customize the top-level directory that will contain the JDK install. By default, this variable is set to "/usr/java". - -Note: setting the install location will currently only work for .bin install types. diff --git a/elements/java/install.d/33-java b/elements/java/install.d/33-java index d778e4b4..2ed92231 100755 --- a/elements/java/install.d/33-java +++ b/elements/java/install.d/33-java @@ -34,30 +34,30 @@ else if [[ $JAVA_FILE == *.tar.gz ]]; then echo "Decompressing Java archive" echo -e "\n" | tar -zxf $JAVA_FILE - JAVA_NAME=`ls -1 /usr/java/ | grep -v tar.gz` + JAVA_NAME=`ls -1 $JAVA_TARGET_LOCATION | grep -v tar.gz` echo "Setting up $JAVA_NAME" chown -R root:root $JAVA_HOME cat >> /etc/profile.d/java.sh <