Migrate to openjdk - part 2
Add ability to support various jdk distros Changes: * rename java element to oracle-java * use java element for check java distribution partial-bug: #1204957 Change-Id: Ife4daebdabd5f79affe550f04256dfa5b0e9a7cc
This commit is contained in:
parent
db50f5ba97
commit
61c2c5b879
@ -292,16 +292,15 @@ fi
|
||||
#############################
|
||||
|
||||
if [ -z "$PLUGIN" -o "$PLUGIN" = "vanilla" ]; then
|
||||
export JAVA_DOWNLOAD_URL=${JAVA_DOWNLOAD_URL:-"http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz"}
|
||||
export OOZIE_HADOOP_V1_DOWNLOAD_URL=${OOZIE_HADOOP_V1_DOWNLOAD_URL:-"http://sahara-files.mirantis.com/oozie-4.0.0.tar.gz"}
|
||||
export OOZIE_HADOOP_V2_6_DOWNLOAD_URL=${OOZIE_HADOOP_V2_6_DOWNLOAD_URL:-"http://sahara-files.mirantis.com/oozie-4.0.1-hadoop-2.6.0.tar.gz"}
|
||||
export HADOOP_V2_6_NATIVE_LIBS_DOWNLOAD_URL=${HADOOP_V2_6_NATIVE_LIBS_DOWNLOAD_URL:-"http://sahara-files.mirantis.com/hadoop-native-libs-2.6.0.tar.gz"}
|
||||
export EXTJS_DOWNLOAD_URL=${EXTJS_DOWNLOAD_URL:-"http://extjs.com/deploy/ext-2.2.zip"}
|
||||
export HIVE_VERSION=${HIVE_VERSION:-"0.11.0"}
|
||||
|
||||
ubuntu_elements_sequence="base vm ubuntu hadoop oozie mysql hive"
|
||||
fedora_elements_sequence="base vm fedora redhat-lsb hadoop oozie mysql disable-firewall hive updater"
|
||||
centos_elements_sequence="vm rhel hadoop oozie mysql redhat-lsb disable-firewall hive updater"
|
||||
ubuntu_elements_sequence="base vm ubuntu hadoop oozie mysql hive oracle-java"
|
||||
fedora_elements_sequence="base vm fedora redhat-lsb hadoop oozie mysql disable-firewall hive oracle-java updater"
|
||||
centos_elements_sequence="vm rhel hadoop oozie mysql redhat-lsb disable-firewall hive oracle-java updater"
|
||||
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
ubuntu_elements_sequence="$ubuntu_elements_sequence root-passwd"
|
||||
@ -404,11 +403,10 @@ if [ -z "$PLUGIN" -o "$PLUGIN" = "spark" ]; then
|
||||
# Ignoring image type and hadoop version options
|
||||
echo "For spark plugin options -i and -v are ignored"
|
||||
|
||||
export JAVA_DOWNLOAD_URL=${JAVA_DOWNLOAD_URL:-"http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz"}
|
||||
export DIB_HADOOP_VERSION="CDH4"
|
||||
export ubuntu_image_name=${ubuntu_spark_image_name:-"ubuntu_sahara_spark_latest"}
|
||||
|
||||
ubuntu_elements_sequence="base vm ubuntu java hadoop-cdh swift_hadoop spark"
|
||||
ubuntu_elements_sequence="base vm ubuntu oracle-java hadoop-cdh swift_hadoop spark"
|
||||
|
||||
if [ -n "$USE_MIRRORS" ]; then
|
||||
[ -n "$UBUNTU_MIRROR" ] && ubuntu_elements_sequence="$ubuntu_elements_sequence apt-mirror"
|
||||
@ -432,11 +430,10 @@ if [ -z "$PLUGIN" -o "$PLUGIN" = "storm" ]; then
|
||||
# Ignoring image type and hadoop version options
|
||||
echo "For storm plugin options -i and -v are ignored"
|
||||
|
||||
export JAVA_DOWNLOAD_URL=${JAVA_DOWNLOAD_URL:-"http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz"}
|
||||
export DIB_STORM_VERSION=${DIB_STORM_VERSION:-0.9.1}
|
||||
export ubuntu_image_name=${ubuntu_storm_image_name:-"ubuntu_sahara_storm_latest_$DIB_STORM_VERSION"}
|
||||
|
||||
ubuntu_elements_sequence="base vm ubuntu java zookeeper storm"
|
||||
ubuntu_elements_sequence="base vm ubuntu oracle-java zookeeper storm"
|
||||
|
||||
if [ -n "$USE_MIRRORS" ]; then
|
||||
[ -n "$UBUNTU_MIRROR" ] && ubuntu_elements_sequence="$ubuntu_elements_sequence apt-mirror"
|
||||
@ -465,10 +462,6 @@ if [ -z "$PLUGIN" -o "$PLUGIN" = "hdp" ]; then
|
||||
export BASE_IMAGE_FILE="CentOS-6.6-cloud-init-20141118.qcow2"
|
||||
export DIB_CLOUD_IMAGES="http://sahara-files.mirantis.com"
|
||||
|
||||
# Setup Java Install configuration for the HDP images
|
||||
export JAVA_TARGET_LOCATION=/opt
|
||||
export JAVA_DOWNLOAD_URL=https://s3.amazonaws.com/public-repo-1.hortonworks.com/ARTIFACTS/jdk-6u31-linux-x64.bin
|
||||
|
||||
# No registration for RHEL-based distros
|
||||
export REG_METHOD=disable
|
||||
# Workaround for https://review.openstack.org/#/c/162239/
|
||||
@ -478,7 +471,7 @@ if [ -z "$PLUGIN" -o "$PLUGIN" = "hdp" ]; then
|
||||
if [ -z "$HADOOP_VERSION" -o "$HADOOP_VERSION" = "1" ]; then
|
||||
export centos_image_name_hdp_1_3=${centos_hdp_hadoop_1_image_name:-"centos-6_5-64-hdp-1-3"}
|
||||
# Elements to include in an HDP-based image
|
||||
centos_elements_sequence="vm rhel hadoop-hdp redhat-lsb yum updater"
|
||||
centos_elements_sequence="vm rhel hadoop-hdp redhat-lsb yum oracle-java updater"
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
# enable the root-pwd element, for simpler local debugging of images
|
||||
centos_elements_sequence=$centos_elements_sequence" root-passwd"
|
||||
@ -497,7 +490,7 @@ if [ -z "$PLUGIN" -o "$PLUGIN" = "hdp" ]; then
|
||||
if [ -z "$HADOOP_VERSION" -o "$HADOOP_VERSION" = "2" ]; then
|
||||
export centos_image_name_hdp_2_0=${centos_hdp_hadoop_2_image_name:-"centos-6_5-64-hdp-2-0"}
|
||||
# Elements to include in an HDP-based image
|
||||
centos_elements_sequence="vm rhel hadoop-hdp redhat-lsb yum updater"
|
||||
centos_elements_sequence="vm rhel hadoop-hdp redhat-lsb yum oracle-java updater"
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
# enable the root-pwd element, for simpler local debugging of images
|
||||
centos_elements_sequence=$centos_elements_sequence" root-passwd"
|
||||
@ -516,7 +509,7 @@ if [ -z "$PLUGIN" -o "$PLUGIN" = "hdp" ]; then
|
||||
if [ -z "$HADOOP_VERSION" -o "$HADOOP_VERSION" = "plain" ]; then
|
||||
export centos_image_name_plain=${centos_hdp_plain_image_name:-"centos-6_5-64-plain"}
|
||||
# Elements for a plain CentOS image that does not contain HDP or Apache Hadoop
|
||||
centos_plain_elements_sequence="vm rhel redhat-lsb disable-firewall disable-selinux ssh sahara-version yum"
|
||||
centos_plain_elements_sequence="vm rhel redhat-lsb disable-firewall disable-selinux ssh sahara-version yum oracle-java"
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
# enable the root-pwd element, for simpler local debugging of images
|
||||
centos_plain_elements_sequence=$centos_plain_elements_sequence" root-passwd"
|
||||
@ -635,10 +628,8 @@ if [ -z "$PLUGIN" -o "$PLUGIN" = "mapr" ]; then
|
||||
#MapR repository requires additional space
|
||||
export DIB_MIN_TMPFS=10
|
||||
|
||||
export JAVA_DOWNLOAD_URL=${JAVA_DOWNLOAD_URL:-"http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz"}
|
||||
|
||||
mapr_ubuntu_elements_sequence="base vm ssh ubuntu hadoop-mapr"
|
||||
mapr_centos_elements_sequence="base vm rhel ssh hadoop-mapr redhat-lsb selinux-permissive updater disable-firewall"
|
||||
mapr_ubuntu_elements_sequence="base vm ssh ubuntu hadoop-mapr oracle-java"
|
||||
mapr_centos_elements_sequence="base vm rhel ssh hadoop-mapr redhat-lsb selinux-permissive oracle-java updater disable-firewall"
|
||||
|
||||
if [ "$DEBUG_MODE" = "true" ]; then
|
||||
mapr_ubuntu_elements_sequence="$mapr_ubuntu_elements_sequence root-passwd"
|
||||
|
@ -55,24 +55,10 @@ rm -r $tmp_dir
|
||||
|
||||
echo "Pre-configuring Hadoop"
|
||||
|
||||
: ${JAVA_TARGET_LOCATION:="/usr/java"}
|
||||
# Find JAVA_HOME...
|
||||
JAVA_HOME=$(find $TARGET_ROOT$JAVA_TARGET_LOCATION/ -maxdepth 1 -name "jdk*")
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu)
|
||||
JAVA_HOME=$(readlink -e /usr/bin/java | sed "s:bin/java::")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
cat >> /home/hadoop/.bashrc <<EOF
|
||||
PATH=$PATH:/usr/sbin:$JAVA_HOME/bin
|
||||
JAVA_HOME=$JAVA_HOME
|
||||
PATH=$PATH:/usr/sbin
|
||||
EOF
|
||||
cat >> /etc/hadoop/hadoop-env.sh <<EOF
|
||||
export JAVA_HOME=$JAVA_HOME
|
||||
export HADOOP_LOG_DIR=/mnt/log/hadoop/\$USER
|
||||
export HADOOP_SECURE_DN_LOG_DIR=/mnt/log/hadoop/hdfs
|
||||
EOF
|
||||
|
@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
|
||||
echo "/etc/profile.d/java.sh" >> /etc/ssh/sshrc
|
||||
chmod 775 /etc/profile.d/java.sh
|
@ -21,21 +21,6 @@ function download_hadoop_package {
|
||||
fi
|
||||
}
|
||||
|
||||
function find_java_home {
|
||||
JAVA_HOME=$(find $TARGET_ROOT$JAVA_TARGET_LOCATION/ -maxdepth 1 -name "jdk*")
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu )
|
||||
JAVA_HOME=$(readlink -e /usr/bin/java | sed "s:bin/java::")
|
||||
;;
|
||||
fedora | rhel | centos )
|
||||
JAVA_HOME=$(rpm --eval '%{?java_home}')
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
function install_hadoop_v1 {
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu )
|
||||
@ -67,19 +52,18 @@ function install_hadoop_v1 {
|
||||
rm -r $tmp_dir
|
||||
|
||||
echo "Pre-configuring Hadoop"
|
||||
find_java_home
|
||||
|
||||
cat >> /home/hadoop/.bashrc <<EOF
|
||||
PATH=\$PATH:/usr/sbin:$JAVA_HOME/bin
|
||||
JAVA_HOME=$JAVA_HOME
|
||||
PATH=\$PATH:/usr/sbin
|
||||
HADOOP_HOME=/usr/share/hadoop/
|
||||
EOF
|
||||
|
||||
sed -i -e "s,export JAVA_HOME=.*,export JAVA_HOME=$JAVA_HOME," \
|
||||
-e "s,export HADOOP_LOG_DIR=.*,export HADOOP_LOG_DIR=/mnt/log/hadoop/\$USER," \
|
||||
sed -i -e "s,export HADOOP_LOG_DIR=.*,export HADOOP_LOG_DIR=/mnt/log/hadoop/\$USER," \
|
||||
-e "s,export HADOOP_SECURE_DN_LOG_DIR=.*,export HADOOP_SECURE_DN_LOG_DIR=/mnt/log/hadoop/hdfs," \
|
||||
-e "s,HADOOP_DATANODE_OPTS=\"-Dhadoop.security.logger=ERROR\,DRFAS \$HADOOP_DATANODE_OPTS\",HADOOP_DATANODE_OPTS=\"-Djava.security.egd=file:/dev/./urandom -Dhadoop.security.logger=ERROR\,DRFAS \$HADOOP_DATANODE_OPTS\"," \
|
||||
/etc/hadoop/hadoop-env.sh
|
||||
|
||||
echo "source $JAVA_RC" >> /etc/hadoop/hadoop-env.sh
|
||||
}
|
||||
|
||||
|
||||
@ -117,16 +101,14 @@ function install_hadoop_v2 {
|
||||
rm "$native_libs_filename"
|
||||
|
||||
echo "Pre-configuring Hadoop"
|
||||
find_java_home
|
||||
|
||||
HADOOP_PID_DIR="/var/run/hadoop"
|
||||
mkdir $HADOOP_PID_DIR
|
||||
chown hadoop:hadoop $HADOOP_PID_DIR
|
||||
|
||||
cat >> /etc/profile.d/hadoop.sh <<EOF
|
||||
export JAVA_HOME=$JAVA_HOME
|
||||
export HADOOP_COMMON_HOME=$HADOOP_HOME
|
||||
export PATH=\$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
|
||||
export PATH=\$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
|
||||
export HADOOP_HDFS_HOME=\$HADOOP_COMMON_HOME
|
||||
export HADOOP_YARN_HOME=\$HADOOP_COMMON_HOME
|
||||
export HADOOP_MAPRED_HOME=\$HADOOP_COMMON_HOME
|
||||
@ -135,14 +117,14 @@ export YARN_PID_DIR=$HADOOP_PID_DIR
|
||||
export HADOOP_MAPRED_PID_DIR=$HADOOP_PID_DIR
|
||||
EOF
|
||||
|
||||
sed -i -e "s,export JAVA_HOME=.*,export JAVA_HOME=$JAVA_HOME," \
|
||||
-e "s,\#export HADOOP_LOG_DIR=.*,export HADOOP_LOG_DIR=/mnt/log/hadoop/\$USER," \
|
||||
sed -i -e "s,\#export HADOOP_LOG_DIR=.*,export HADOOP_LOG_DIR=/mnt/log/hadoop/\$USER," \
|
||||
-e "s,export HADOOP_SECURE_DN_LOG_DIR=.*,export HADOOP_SECURE_DN_LOG_DIR=/mnt/log/hadoop/hdfs," \
|
||||
$HADOOP_HOME/etc/hadoop/hadoop-env.sh
|
||||
echo "source $JAVA_RC" >> $HADOOP_HOME/etc/hadoop/hadoop-env.sh
|
||||
|
||||
sed -i -e "s,\# export JAVA_HOME=.*,export JAVA_HOME=$JAVA_HOME," \
|
||||
-e "s,YARN_LOG_DIR=.*,YARN_LOG_DIR=/mnt/log/hadoop/yarn," \
|
||||
sed -i -e "s,YARN_LOG_DIR=.*,YARN_LOG_DIR=/mnt/log/hadoop/yarn," \
|
||||
$HADOOP_HOME/etc/hadoop/yarn-env.sh
|
||||
echo "source $JAVA_RC" >> $HADOOP_HOME/etc/hadoop/yarn-env.sh
|
||||
|
||||
# enable swiftfs
|
||||
ln -s ${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-openstack-${DIB_HADOOP_VERSION}.jar ${HADOOP_HOME}/share/hadoop/common/lib/
|
||||
@ -168,8 +150,6 @@ case "$DISTRO_NAME" in
|
||||
;;
|
||||
esac
|
||||
|
||||
: ${JAVA_TARGET_LOCATION:="/usr/java"}
|
||||
|
||||
if [[ "$DIB_HADOOP_VERSION" < "2.0.0" ]]; then
|
||||
install_hadoop_v1
|
||||
else
|
||||
|
39
elements/java/bin/setup-java-home
Executable file
39
elements/java/bin/setup-java-home
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
SCRIPTNAME=$(basename $0)
|
||||
function usage {
|
||||
echo "Usage: $SCRIPTNAME <jre_home> <jdk_home>"
|
||||
}
|
||||
|
||||
if [[ $# != 2 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JRE_HOME=$1
|
||||
JDK_HOME=$2
|
||||
|
||||
echo "JAVA_HOME=$JRE_HOME" >> $JAVA_RC
|
||||
chmod +x $JAVA_RC
|
||||
|
||||
echo "Setting up alternatives for Java"
|
||||
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu )
|
||||
update-alternatives --install "/usr/bin/java" "java" "$JRE_HOME/bin/java" 1
|
||||
update-alternatives --install "/usr/bin/javac" "javac" "$JDK_HOME/bin/javac" 1
|
||||
|
||||
update-alternatives --set java $JRE_HOME/bin/java
|
||||
update-alternatives --set javac $JDK_HOME/bin/javac
|
||||
;;
|
||||
fedora | rhel | centos )
|
||||
alternatives --install /usr/bin/java java $JRE_HOME/bin/java 200000
|
||||
alternatives --install /usr/bin/javac javac $JDK_HOME/bin/javac 200000
|
||||
;;
|
||||
esac
|
9
elements/java/cleanup.d/00-clean-java-vars
Executable file
9
elements/java/cleanup.d/00-clean-java-vars
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
|
||||
unset DIB_JAVA_DISTRO
|
||||
unset JAVA_RC
|
8
elements/java/environment.d/00-java-rc
Normal file
8
elements/java/environment.d/00-java-rc
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
|
||||
export JAVA_RC="/etc/profile.d/99-java.sh"
|
@ -1,73 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Begin: installation of Java"
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -e
|
||||
|
||||
: ${JAVA_TARGET_LOCATION:="/usr/java"}
|
||||
|
||||
# NOTE: $(dirname $0) is read-only, use space under $TARGET_ROOT
|
||||
JAVA_HOME=$TARGET_ROOT$JAVA_TARGET_LOCATION
|
||||
mkdir -p $JAVA_HOME
|
||||
|
||||
if [ -n "$JAVA_DOWNLOAD_URL" ]; then
|
||||
install-packages wget
|
||||
JAVA_FILE=$(basename $JAVA_DOWNLOAD_URL)
|
||||
wget --no-check-certificate --no-cookies -c \
|
||||
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
|
||||
-O $JAVA_HOME/$JAVA_FILE $JAVA_DOWNLOAD_URL
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Java download successful"
|
||||
else
|
||||
echo "Error downloading $JAVA_DOWNLOAD_URL, exiting"
|
||||
exit 1
|
||||
fi
|
||||
elif [ -n "$JAVA_FILE" ]; then
|
||||
install -D -g root -o root -m 0755 $(dirname $0)/$JAVA_FILE $JAVA_HOME
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_FILE" ]; then
|
||||
install-packages default-jre
|
||||
else
|
||||
cd $JAVA_HOME
|
||||
if [[ $JAVA_FILE == *.tar.gz ]]; then
|
||||
echo "Decompressing Java archive"
|
||||
echo -e "\n" | tar -zxf $JAVA_FILE
|
||||
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=$JAVA_TARGET_LOCATION/$JAVA_NAME
|
||||
export PATH=\$PATH:$JAVA_TARGET_LOCATION/$JAVA_NAME/bin
|
||||
EOF
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu )
|
||||
echo "Setting up alternatives for Java"
|
||||
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 $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 | rhel | centos )
|
||||
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
|
||||
echo -e "\n" | sh $JAVA_FILE
|
||||
else
|
||||
echo "Unknown file type: $JAVA_FILE, exiting"
|
||||
exit 1
|
||||
fi
|
||||
rm $JAVA_FILE
|
||||
fi
|
||||
|
||||
echo "End: installation of Java"
|
12
elements/java/pre-install.d/00-check-java
Normal file
12
elements/java/pre-install.d/00-check-java
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
if [[ -z $DIB_JAVA_DISTRO ]]; then
|
||||
echo "Java distribution is not selected."
|
||||
exit 1
|
||||
fi
|
2
elements/openjdk/element-deps
Normal file
2
elements/openjdk/element-deps
Normal file
@ -0,0 +1,2 @@
|
||||
java
|
||||
package-installs
|
8
elements/openjdk/environment.d/00-set-java-distro
Executable file
8
elements/openjdk/environment.d/00-set-java-distro
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
|
||||
export DIB_JAVA_DISTRO="openjdk"
|
@ -3,22 +3,26 @@
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -e
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
echo "Installing OpenJDK"
|
||||
|
||||
case "$DISTRO_NAME" in
|
||||
ubuntu )
|
||||
install-packages openjdk-7-jdk
|
||||
JAVA_PATH=$(update-alternatives --list java)
|
||||
JAVA_HOME=${JAVA_PATH%/bin/java}
|
||||
JRE_PATH=$(update-alternatives --list java)
|
||||
JRE_HOME=${JRE_PATH%/bin/java}
|
||||
JDK_PATH=$(update-alternatives --list javac)
|
||||
JDK_HOME=${JDK_PATH%/bin/javac}
|
||||
;;
|
||||
fedora | rhel | centos )
|
||||
install-packages java-1.7.0-openjdk-devel
|
||||
JAVA_HOME=$(rpm -E "%{java_home}")
|
||||
# NOTE: rpm -E "%{java_home}" command returns wrong java home
|
||||
# on CentOS, Fedora and RHEL
|
||||
JRE_HOME="/usr/lib/jvm/java-openjdk"
|
||||
JDK_HOME="$JRE_HOME"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "JAVA_HOME=$JAVA_HOME" >> $TARGET_ROOT/etc/environment
|
||||
setup-java-home $JRE_HOME $JDK_HOME
|
||||
|
||||
echo "OpenJDK has been installed"
|
||||
|
1
elements/openjdk/package-installs.yaml
Normal file
1
elements/openjdk/package-installs.yaml
Normal file
@ -0,0 +1 @@
|
||||
openjdk-7:
|
10
elements/openjdk/pkg-map
Normal file
10
elements/openjdk/pkg-map
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"family": {
|
||||
"debian": {
|
||||
"openjdk-7": "openjdk-7-jdk"
|
||||
},
|
||||
"redhat": {
|
||||
"openjdk-7": "java-1.7.0-openjdk-devel"
|
||||
}
|
||||
}
|
||||
}
|
1
elements/oracle-java/element-deps
Normal file
1
elements/oracle-java/element-deps
Normal file
@ -0,0 +1 @@
|
||||
java
|
8
elements/oracle-java/environment.d/00-set-java-distro
Executable file
8
elements/oracle-java/environment.d/00-set-java-distro
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -eu
|
||||
|
||||
export DIB_JAVA_DISTRO="oracle-java"
|
41
elements/oracle-java/install.d/33-java
Executable file
41
elements/oracle-java/install.d/33-java
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
||||
set -x
|
||||
fi
|
||||
set -e
|
||||
|
||||
echo "Begin: installation of Java"
|
||||
|
||||
# NOTE: $(dirname $0) is read-only, use space under $TARGET_ROOT
|
||||
JAVA_LOCATION=${JAVA_TARGET_LOCATION:-"/usr/java"}
|
||||
JAVA_NAME="oracle-jdk"
|
||||
JAVA_HOME=$JAVA_LOCATION/$JAVA_NAME
|
||||
JAVA_DOWNLOAD_URL=${JAVA_DOWNLOAD_URL:-"http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz"}
|
||||
|
||||
mkdir -p $JAVA_LOCATION
|
||||
|
||||
if [ -n "$JAVA_DOWNLOAD_URL" ]; then
|
||||
install-packages wget
|
||||
JAVA_FILE=$(basename $JAVA_DOWNLOAD_URL)
|
||||
wget --no-check-certificate --no-cookies -c \
|
||||
--header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
|
||||
-O $JAVA_LOCATION/$JAVA_FILE $JAVA_DOWNLOAD_URL
|
||||
elif [ -n "$JAVA_FILE" ]; then
|
||||
install -D -g root -o root -m 0755 $(dirname $0)/$JAVA_FILE $JAVA_LOCATION
|
||||
fi
|
||||
|
||||
cd $JAVA_LOCATION
|
||||
|
||||
echo "Decompressing Java archive"
|
||||
echo -e "\n" | tar -zxf $JAVA_FILE
|
||||
echo "Setting up $JAVA_NAME"
|
||||
chown -R root:root $JAVA_LOCATION
|
||||
JAVA_DIR=`ls -1 $JAVA_LOCATION | grep -v tar.gz`
|
||||
ln -s $JAVA_LOCATION/$JAVA_DIR $JAVA_HOME
|
||||
|
||||
setup-java-home $JAVA_HOME $JAVA_HOME
|
||||
|
||||
rm $JAVA_FILE
|
||||
|
||||
echo "End: installation of Java"
|
Loading…
Reference in New Issue
Block a user