scripts/setup.sh: check java version
PATCH 1/1 scripts/setup.sh: check java version
Make it obvious when run on autobuilder if java version is too low. While we are at it, check that java is present.
[YOCTO #10156]
Borrowing heavily from:
http://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script
--- scripts/setup.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
scripts/setup.sh +23 -0
@@ -67,6 +67,29 @@ if [ "x$url" != "x" ]; then [ "x$port" != "x" ] && PROXY_PARAM="${PROXY_PARAM} -Dhttp.proxyPort=$port" fi +echo "#### Checking that Java is available ####" +if type -p java; then + echo java found in PATH + _java=java +elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then + echo java found in JAVA_HOME + _java="$JAVA_HOME/bin/java" +else + err_exit 2 "no java" +fi +echo "#### Checking that the appropriate Java version is available ####" +JAVA_VER_STRING=1.8 +JAVA_VER_INT=001008 +if [[ "$_java" ]]; then + version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}') + echo java version as string = $version + version_int=$(echo "$version" | awk -F. '{printf("%03d%03d",$1,$2);}') + echo java version as integer = $version_int + if [ $version_int -lt $JAVA_VER_INT ]; then + err_exit 1 "Java version must be $JAVA_VER_STRING+" + fi +fi + # prepare the base Eclipse installation in folder "eclipse" ep_rel="R-" ep_ver="4.6"
Signature · 1 line
2.7.4
On Wed, 2016-08-24 at 15:22 -0700, Tim Orling wrote:
Make it obvious when run on autobuilder if java version is too low. While we are at it, check that java is present.
[YOCTO #10156]
Borrowing heavily from:
http://stackoverflow.com/questions/7334754/correct-way-to-check-java-version-from-bash-script
--- scripts/setup.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
scripts/setup.sh +23 -0
@@ -67,6 +67,29 @@ if [ "x$url" != "x" ]; then [ "x$port" != "x" ] && PROXY_PARAM="${PROXY_PARAM} -Dhttp.proxyPort=$port" fi +echo "#### Checking that Java is available ####" +if type -p java; then + echo java found in PATH + _java=java +elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then + echo java found in JAVA_HOME + _java="$JAVA_HOME/bin/java" +else + err_exit 2 "no java" +fi +echo "#### Checking that the appropriate Java version is available ####" +JAVA_VER_STRING=1.8 +JAVA_VER_INT=001008 +if [[ "$_java" ]]; then + version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}') + echo java version as string = $version + version_int=$(echo "$version" | awk -F. '{printf("%03d%03d",$1,$2);}') + echo java version as integer = $version_int + if [ $version_int -lt $JAVA_VER_INT ]; then + err_exit 1 "Java version must be $JAVA_VER_STRING+" + fi +fi + # prepare the base Eclipse installation in folder "eclipse" ep_rel="R-" ep_ver="4.6"
--
2.7.4
Tim,
FYI, the dash shell used on Ubuntu does not recognize the "[[" construct, because it's a bash extension and not POSIX. I suggest you replace it with something POSIX compliant.
-Bill
On Wed, 2016-08-24 at 22:59 +0000, Randle, William C wrote:
Quoted 1 line · Tim Orling
Quoted 1 line
Make it obvious when run on autobuilder if java version is too low.
While we are at it, check that java is present.
[YOCTO #10156]
Borrowing heavily from:
http://stackoverflow.com/questions/7334754/correct-way-to-check-java-version
Quoted 1 line
Quoted 1 line
-from-bash-script
--- scripts/setup.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
scripts/setup.sh +0 -0
@@ -67,6 +67,29 @@ if [ "x$url" != "x" ]; then [ "x$port" != "x" ] && PROXY_PARAM="${PROXY_PARAM}
Quoted 1 line
Quoted 1 line
-Dhttp.proxyPort=$port"
fi
+echo "#### Checking that Java is available ####"
+if type -p java; then
+ echo java found in PATH
+ _java=java
+elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; thennightly-
Quoted 1 line
Quoted 1 line
multilib.conf
+ echo java found in JAVA_HOME
+ _java="$JAVA_HOME/bin/java"
+else
+ err_exit 2 "no java"
+fi
+echo "#### Checking that the appropriate Java version is available ####" +JAVA_VER_STRING=1.8
+JAVA_VER_INT=001008
+if [[ "$_java" ]]; then
+ version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
+ echo java version as string = $version
+ version_int=$(echo "$version" | awk -F. '{printf("%03d%03d",$1,$2);}')
+ echo java version as integer = $version_int
+ if [ $version_int -lt $JAVA_VER_INT ]; then+ err_exit 1 "Java version must be $JAVA_VER_STRING+"
+ fi
+fi
+
# prepare the base Eclipse installation in folder "eclipse" ep_rel="R-" ep_ver="4.6" -- 2.7.4
Tim,
FYI, the dash shell used on Ubuntu does not recognize the "[[" construct, because it's a bash extension and not POSIX. I suggest you replace it with something POSIX compliant.
-Bill
--
Never mind. I checked the full setup.sh script and it explicitly invokes /bin/bash, so you're ok as is.
-Bill