From: Anil Belur Date: Fri, 15 Mar 2019 02:05:10 +0000 (+1000) Subject: Extract version number passed set '{java-version}' X-Git-Tag: v0.34.0~4^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=c0b4bc95a6d160f6fd3edc095f9fd277c80769d0;p=releng%2Fglobal-jjb.git Extract version number passed set '{java-version}' When the version number string is multi-digits ex: openjdk11 "${SET_JDK_VERSION: -1}" returns '1' which is incorrect. The change fixes version number extraction for the string passed to env variable $SET_JDK_VERSION. Also update the regex to handle values with special chars. Issue: RELENG-1853 Change-Id: I52c49fec007bad70d4a42d4c20a45b35fec3997c Signed-off-by: Anil Belur --- diff --git a/shell/update-java-alternatives.sh b/shell/update-java-alternatives.sh index a53cc0ad..f85e2018 100644 --- a/shell/update-java-alternatives.sh +++ b/shell/update-java-alternatives.sh @@ -20,7 +20,7 @@ update-java-redhat() { elif [[ "${SET_JDK_VERSION//[a-zA-Z]/}" = "10" ]]; then export JAVA_HOME="/opt/jdk-10.0.2" else - export JAVA_HOME="/usr/lib/jvm/java-1.${SET_JDK_VERSION//[a-zA-Z]/}.0-openjdk" + export JAVA_HOME="/usr/lib/jvm/java-1.${SET_JDK_VERSION//[a-zA-Z:-]/}.0-openjdk" fi sudo /usr/sbin/alternatives --install /usr/bin/java java "${JAVA_HOME}/bin/java" 1 sudo /usr/sbin/alternatives --install /usr/bin/javac javac "${JAVA_HOME}/bin/javac" 1 @@ -32,7 +32,7 @@ update-java-redhat() { } update-java-ubuntu() { - export JAVA_HOME="/usr/lib/jvm/java-${SET_JDK_VERSION: -1}-openjdk-amd64" + export JAVA_HOME="/usr/lib/jvm/java-${SET_JDK_VERSION//[a-zA-Z:-]/}-openjdk-amd64" sudo /usr/bin/update-alternatives --install /usr/bin/java java "${JAVA_HOME}/bin/java" 1 sudo /usr/bin/update-alternatives --install /usr/bin/javac javac "${JAVA_HOME}/bin/javac" 1 sudo /usr/bin/update-alternatives --install /usr/lib/jvm/java-openjdk java_sdk_openjdk "${JAVA_HOME}" 1