All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Randle, William C" <william.c.randle@intel.com>
To: "timothy.t.orling@linux.intel.com"
	<timothy.t.orling@linux.intel.com>,
	"yocto@yoctoproject.org" <yocto@yoctoproject.org>
Subject: Re: [eclipse-poky][PATCH] scripts/setup.sh: check java version
Date: Wed, 24 Aug 2016 22:59:57 +0000	[thread overview]
Message-ID: <1472079597.11000.13.camel@intel.com> (raw)
In-Reply-To: <1472077365-2634-1-git-send-email-timothy.t.orling@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1901 bytes --]

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

Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com<mailto:timothy.t.orling@linux.intel.com>>
---
 scripts/setup.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/scripts/setup.sh b/scripts/setup.sh
index 75310ab..c2b32a4 100755
--- a/scripts/setup.sh
+++ b/scripts/setup.sh
@@ -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

[-- Attachment #2: Type: text/html, Size: 2806 bytes --]

  reply	other threads:[~2016-08-24 23:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 22:22 [eclipse-poky][PATCH] scripts/setup.sh: check java version Tim Orling
2016-08-24 22:59 ` Randle, William C [this message]
2016-08-24 23:07   ` Randle, William C

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472079597.11000.13.camel@intel.com \
    --to=william.c.randle@intel.com \
    --cc=timothy.t.orling@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.