summaryrefslogtreecommitdiffstats
path: root/scripts/find-version
blob: 55fbc5810424e6326bd3577f740879a822f41768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh

help ()
{
  echo "Find the installed plugin/feature version of a eclipse build environment"
  echo "Usage: $0 [pluginId1/featureId1[,pluginId2/featureId2]...]";
  echo ""
  echo "Options:"
  echo "pluginId/featureId - comma seperated plugin or feature ids, empty for all"
  echo ""
  echo "Example: $0 org.eclipse.tcf.feature.group";
  exit 1;
}

fail ()
{
  local retval=$1
  shift $1
  echo "[Fail $retval]: $*"
  echo "BUILD_TOP=${BUILD_TOP}"
  cd ${TOP}
  exit ${retval}
}

find_eclipse_base ()
{
  [ -d ${ECLIPSE_HOME}/plugins ] &&  ECLIPSE_BASE=`readlink -f ${ECLIPSE_HOME}`
}

find_launcher ()
{
  local list="`ls ${ECLIPSE_BASE}/plugins/org.eclipse.equinox.launcher_*.jar`"
  for launcher in $list; do
    [ -f $launcher ] && LAUNCHER=${launcher}
  done
}

check_env ()
{
  find_eclipse_base
  find_launcher
  
  local err=0
  [ "x${ECLIPSE_BASE}" = "x" -o "x${LAUNCHER}" = "x" ] && err=1
  if [ $err -eq 0 ]; then
    [ ! -d ${ECLIPSE_BASE} ] && err=1
    [ ! -f ${LAUNCHER} ] && err=1
  fi
  
  if [ $err -ne 0 ]; then
    echo "Please set env variable ECLIPSE_HOME to the eclipse installation directory!" 
    exit 1
  fi 
}

if [ $# -ne 0 ] && [ $# -ne 1 ]; then 
   help
fi

check_env

java -jar ${LAUNCHER} -application org.eclipse.equinox.p2.director -destination ${ECLIPSE_BASE} -profile SDKProfile -repository file:///${ECLIPSE_BASE}/p2/org.eclipse.equinox.p2.engine/profileRegistry/SDKProfile.profile -list $@