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
This commit is contained in:
parent
fca4b20cca
commit
0580bbe7d7
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 <<EOF
|
||||
# Custom Java install
|
||||
export JAVA_HOME=/usr/java/$JAVA_NAME
|
||||
export PATH=\$PATH:/usr/java/$JAVA_NAME/bin
|
||||
export JAVA_HOME=$JAVA_TARGET_LOCATION/$JAVA_NAME
|
||||
export PATH=\$PATH:$JAVA_TARGET_LOCATION/$JAVA_NAME/bin
|
||||
EOF
|
||||
case "$distro" in
|
||||
Ubuntu )
|
||||
echo "Setting up alternatives for Java"
|
||||
update-alternatives --install "/usr/bin/java" "java" "/usr/java/$JAVA_NAME/bin/java" 1
|
||||
update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/$JAVA_NAME/bin/javac" 1
|
||||
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/java/$JAVA_NAME/bin/javaws" 1
|
||||
update-alternatives --install "/usr/bin/java" "java" "$JAVA_TARGET_LOCATION/$JAVA_NAME/bin/java" 1
|
||||
update-alternatives --install "/usr/bin/javac" "javac" "$JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javac" 1
|
||||
update-alternatives --install "/usr/bin/javaws" "javaws" "$JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javaws" 1
|
||||
|
||||
update-alternatives --set java /usr/java/$JAVA_NAME/bin/java
|
||||
update-alternatives --set javac /usr/java/$JAVA_NAME/bin/javac
|
||||
update-alternatives --set javaws /usr/java/$JAVA_NAME/bin/javaws
|
||||
update-alternatives --set java $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/java
|
||||
update-alternatives --set javac $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javac
|
||||
update-alternatives --set javaws $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javaws
|
||||
;;
|
||||
Fedora | RedHatEnterpriseServer | CentOS )
|
||||
alternatives --install /usr/bin/java java /usr/java/$JAVA_NAME/bin/java 200000
|
||||
alternatives --install /usr/bin/javaws javaws /usr/java/$JAVA_NAME/bin/javaws 200000
|
||||
alternatives --install /usr/bin/javac javac /usr/java/$JAVA_NAME/bin/javac 200000
|
||||
alternatives --install /usr/bin/jar jar /usr/java/$JAVA_NAME/bin/jar 200000
|
||||
alternatives --install /usr/bin/java java $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/java 200000
|
||||
alternatives --install /usr/bin/javaws javaws $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javaws 200000
|
||||
alternatives --install /usr/bin/javac javac $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/javac 200000
|
||||
alternatives --install /usr/bin/jar jar $JAVA_TARGET_LOCATION/$JAVA_NAME/bin/jar 200000
|
||||
;;
|
||||
esac
|
||||
elif [[ $JAVA_FILE == *.bin ]]; then
|
||||
|
|
Loading…
Reference in New Issue