This file is indexed.

/usr/bin/tos-locate-jre is in tinyos-tools 1.4.2-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/sh
# This script attempts to locate the jre directory of the current
# Java installation, even when java is not in the path
# It works with  the following rpm files:
#       Sun's Java Software Development Kit (Linux/Windows)
#       Sun's Java Runtime Environment (Linux)
#       IBM's Java Software Development Kit (linux)

# We require an option to specify which directory is desired:
# --java: directory with java executable
# --javac: directory with javac executable
# --jni: directory where JNI code is placed

if [ "$1" = "--jni" ]; then
    jni=yes
elif [ "$1" = "--java" ]; then
    java=yes
elif [ "$1" = "--javac" ]; then
    javac=yes
else
    echo "Usage: tos-locate-jre --java|--javac|--jni" >&2
    exit 2
fi

rpmlocate () {
    javarpm=$1
    javapath=`rpm -ql $1 2>/dev/null | grep "bin/$2$"`
}

pathlocate () {
    javapath=`which $1 2>/dev/null`
    while [ -n "$javapath" -a -h "$javapath" ]; do
	javapath=`readlink -q $javapath`
    done
    test -n "$javapath"
}

case `uname` in
    CYGWIN*)
    # Hopefully this will always work on cygwin with Sun's Java
    if [ "$javac" != "yes" ]; then #first try the public jre
        jversion=`regtool -q get '\\HKLM\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\CurrentVersion'`
        jhome=`regtool -q get '\\HKLM\SOFTWARE\\JavaSoft\\Java Runtime Environment\\'$jversion'\\JavaHome'`
    fi
    if [ "$jhome" == "" ]; then
        jversion=`regtool -q get '\\HKLM\\SOFTWARE\\JavaSoft\\Java Development Kit\\CurrentVersion'`
        if [ $? != 0 ]; then
            exit 1
        fi
        jhome=`regtool -q get '\\HKLM\SOFTWARE\\JavaSoft\\Java Development Kit\\'$jversion'\\JavaHome'`
    fi
    if [ $? != 0 ]; then
	exit 1
    fi
    jhome=`cygpath -u "$jhome"`
    ;;

    Darwin)
    ## This should work bu the symlinks are broken. Apple bug, I suppose :)
    #jhome=/System/Library/Frameworks/JavaVM.framework/Versions/Current
    ## The real location is under /Developer/SDKs/MacOSX*.sdk/
    ## but now how do we determin the version correctly ?
    ## I have 10.6.6 but we need to drop the last digit
    ## `uname -r` returns 10.6.0 for some reason, and
    ## it appears that `basename `uname -r` .0` works
    ## it's not very certain if it will later.

    pn=`sw_vers -productName | sed 's/ //g'`
    pv=`sw_vers -productVersion | awk -F. '{ print $1 "." $2 }'`
    ## Since we only want to modify this one script for now, stick the
    ## extra subdir at the end, beceuase that's what the reset of scripts
    ## presume. This is a work-around and should be eliminated eventually.
    xcode_jdk=/Developer/SDKs/${pn}${pv}.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers
    jhome=/Library/Java/Home
    ;;

    Linux)
    # Check gentoo java configuration
    javapath=`java-config -c 2>/dev/null`
    # We check the path first, on the assumption that that's the preferred
    # version.
    if [ -z "$javapath" ]; then
        pathlocate javac || { test -z "$javac" && pathlocate java; }
    fi
    if [ -z "$javapath" ]; then
	# We try a bunch of standard names, before resorting to rpm -qa
	rpmlocate IBMJava2-SDK javac || \
	    rpmlocate IBMJava2-142-ia32-SDK javac || \
	    rpmlocate j2sdk javac || \
	    rpmlocate jdk javac || \
	    { test -z "$javac" && rpmlocate j2re java; } || \
	    { test -z "$javac" && rpmlocate jre java; }

	if [ -z "$javapath" ]; then
	    # lastly, check for a weirdly named IBMJava2
	    name=`rpm -qa | grep IBMJava2 | head -1`
	    if [ -n "$name" ]; then
		rpmlocate $name javac
	    fi
	fi
    fi
    if [ -z "$javapath" ]; then
	exit 1
    fi
    jbin=`dirname "$javapath"`
    jhome=`dirname "$jbin"`
    ;;

    FreeBSD)
    # We check the path first, on the assumption that that's the preferred
    # version.
    pathlocate javac || { test -z "$javac" && pathlocate java; }
    if [ -n "$javapath" ]; then
	jbin=`dirname "$javapath"`
    else
	if [ -f /usr/local/jdk1.4*/bin/java ]; then
	    jbin=/usr/local/jdk1.4*/bin
	else
	    exit 1
	fi
    fi
    jhome=`dirname $jbin`
    ;;
esac

# These are correct for Sun and IBM's x86 Java versions
if [ "$jni" = "yes" ]; then
    jnilocate () {
	dir="$1"
	test -d "$1"
    }

    # Look for a likely JNI directory
    # Windows, and IBM Java: in jre/bin
    # Sun Java on Linux: in jre/lib/i386
    if [ `uname` = "Darwin" ]; then 
	jnilocate "/Library/Java/Extensions"
    elif "$jhome/bin/java" -version 2>&1 | grep -q IBM || cygpath -w / >/dev/null 2>/dev/null; then
	jnilocate "$jhome/jre/bin" || jnilocate "$jhome/bin"
    else
	arch=`uname -m`
	jnilocate "$jhome/jre/lib/$arch" || \
	    jnilocate "$jhome/jre/lib/i386" || \
	    jnilocate "$jhome/jre/lib/amd64" || \
	    jnilocate "$jhome/lib/$arch" || \
	    jnilocate "$jhome/lib/i386" || \
	    jnilocate "$jhome/lib/amd64"
    fi
elif [ "$javac" = "yes" ]; then
 if [ `uname` = "Darwin" ];  then
  dir="$xcode_jdk"
 else
  dir="$jhome/bin"
 fi
elif [ "$java" = "yes" ]; then
 dir="$jhome/bin"
fi

# Check that what we found actually exists
if [ -d "$dir" ]; then
 echo $dir
else
 exit 1
fi