summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Trygve Kalleberg <karltk@gentoo.org>2004-07-28 00:39:27 +0000
committerKarl Trygve Kalleberg <karltk@gentoo.org>2004-07-28 00:39:27 +0000
commit3f107cf66316651acb0206aabfd875c3c0730530 (patch)
tree1dd04ad409eca961d74b237bd6206f35005cc41c /eclass/java-utils.eclass
parentInitial import. Works on my box;) (Manifest recommit) (diff)
downloadgentoo-2-3f107cf66316651acb0206aabfd875c3c0730530.tar.gz
gentoo-2-3f107cf66316651acb0206aabfd875c3c0730530.tar.bz2
gentoo-2-3f107cf66316651acb0206aabfd875c3c0730530.zip
Initial import. Excpect bugs.
Diffstat (limited to 'eclass/java-utils.eclass')
-rw-r--r--eclass/java-utils.eclass95
1 files changed, 95 insertions, 0 deletions
diff --git a/eclass/java-utils.eclass b/eclass/java-utils.eclass
new file mode 100644
index 000000000000..748966cf116e
--- /dev/null
+++ b/eclass/java-utils.eclass
@@ -0,0 +1,95 @@
+#
+# Helper class for all Java packages
+#
+# Copyright (c) 2004, Thomas Matthijs <axxo@keanu.be>
+# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
+# Copyright (c) 2004, Gentoo Foundation
+#
+# Licensed under the GNU General Public License, v2
+
+inherit eutils
+
+ECLASS=java-utils
+INHERITED="$INHERITED $ECLASS"
+DESCRIPTION="Based on the $ECLASS eclass"
+
+DEPEND=">=java-config-1.2.7"
+
+EXPORT_FUNCTIONS pkg_setup
+
+java-utils_pkg_setup() {
+ java-utils_ensure-jdk
+}
+
+java-utils_setup-vm() {
+
+ local vendor=`java-utils_get-vm-vendor`
+ if [ ${vendor} = "sun-jdk" ] && java-utils_is-vm-version 1 5; then
+ addpredict "/dev/random"
+ elif [[ ${vendor} = "ibm-jdk-bin" ]]; then
+ addwrite "/proc/self/maps"
+ addwrite "/proc/cpuinfo"
+ elif [[ ${vendor} = "jrockit-jdk-bin" ]]; then
+ addwrite "/proc/cpuinfo"
+ fi
+}
+
+java-utils_ensure-jdk() {
+ if ! java-utils_is-vm-jdk; then
+ eerror "A full JDK is needed by this package. You currently have no Java VM active or only a JRE"
+ eerror "Please use java-config -S to set your system vm to a JDK"
+ die "Active VM is not a JDK"
+ fi
+}
+
+java-utils_is-vm-jdk() {
+ if [ "$JDK_HOME" ] && [ "$JDK_HOME" == "$JAVA_HOME" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+java-utils_get-vm-vendor() {
+ local vm=$(java-config -f)
+ echo ${vm%-*}
+}
+
+java-utils_get-vm-version() {
+ local version=$(java-config -f | sed -r "s/^[a-zA-Z-]+//")
+ echo ${version}
+}
+
+java-utils_ensure-vm-version-ge() {
+ if ! java-utils_is-vm-version-ge $@ ; then
+ eerror "This package requires a Java VM version >= $@"
+ einfo "Please use java-config -S to set the correct one"
+ die "Active Java VM too old"
+ fi
+}
+
+java-utils_is-vm-version-ge() {
+ local user_major=${1-0}
+ local user_minor=${2-0}
+ local user_patch=${3-0}
+ local user_version=${user_major}.${user_minor}.${user_patch}
+
+ local vm_version=`java-utils_get-vm-version`
+
+ local ver_rx="([0-9]+)\.([0-9]+)\.([0-9]+)(.*)"
+ local vm_major=$(echo ${vm_version} | sed -r "s/${ver_rx}/\1/")
+ local vm_minor=$(echo ${vm_version} | sed -r "s/${ver_rx}/\2/")
+ local vm_patch=$(echo ${vm_version} | sed -r "s/${ver_rx}/\3/")
+ local vm_extra=$(echo ${vm_version} | sed -r "s/${ver_rx}/\4/")
+
+ if [ ${vm_major} -ge ${user_major} ] && [ ${vm_minor} -gt ${user_minor} ] ; then
+ echo "Detected a JDK >= ${user_version}"
+ return 0
+ elif [ ${vm_major} -ge ${user_major} ] && [ ${vm_minor} -ge ${user_minor} ] && [ ${vm_patch} -ge ${user_patch} ] ; then
+ echo "Detected a JDK >= ${user_version}"
+ return 0
+ else
+ echo "Detected a JDK < ${user_version}"
+ return 1
+ fi
+}