/[gentoo-alt]/trunk/prefix/eclass/java-utils.eclass
Gentoo

Contents of /trunk/prefix/eclass/java-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 982 - (show annotations) (download)
Thu Feb 2 04:20:17 2006 UTC (13 years, 2 months ago) by kito
File size: 2647 byte(s)
Initial eclass import from gentoo-x86
1 #
2 # Helper class for all Java packages
3 #
4 # Copyright (c) 2004, Thomas Matthijs <axxo@keanu.be>
5 # Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
6 # Copyright (c) 2004, Gentoo Foundation
7 #
8 # Licensed under the GNU General Public License, v2
9
10 inherit eutils
11
12 DESCRIPTION="Based on the $ECLASS eclass"
13
14 DEPEND=">=dev-java/java-config-1.2.7"
15
16 EXPORT_FUNCTIONS pkg_setup
17
18 java-utils_pkg_setup() {
19 java-utils_ensure-jdk
20
21 java-utils_vm-version-sufficient
22 }
23
24 java-utils_setup-vm() {
25 local vendor=`java-utils_get-vm-vendor`
26 if [[ ${vendor} = "sun-jdk" ]] && java-utils_is-vm-version-ge 1 5; then
27 addpredict "/dev/random"
28 elif [[ ${vendor} = "ibm-jdk-bin" ]]; then
29 addwrite "/proc/self/maps"
30 addwrite "/proc/cpuinfo"
31 elif [[ ${vendor} = "jrockit-jdk-bin" ]]; then
32 addwrite "/proc/cpuinfo"
33 fi
34 }
35
36 java-utils_ensure-jdk() {
37 if ! java-utils_is-vm-jdk; then
38 eerror "A full JDK is needed by this package. You currently have no Java VM active or only a JRE"
39 eerror "Please use java-config -S to set your system vm to a JDK"
40 die "Active VM is not a JDK"
41 fi
42 }
43
44 java-utils_is-vm-jdk() {
45 if [ "$JDK_HOME" ] && [ "$JDK_HOME" == "$JAVA_HOME" ]; then
46 return 0
47 else
48 return 1
49 fi
50 }
51
52 java-utils_get-vm-vendor() {
53 local vm=$(java-config -f)
54 echo ${vm%-*}
55 }
56
57 java-utils_get-vm-version() {
58 local version=$(java-config -f | sed -e "s/.*-\([0-9.]\+\).*/\1/")
59 echo ${version}
60 }
61
62 java-utils_vm-version-sufficient() {
63 local version=$(echo ${DEPEND} | sed -e 's:.*virtual/jdk-\?\([^$ ]*\).*:\1:' -e 's:\.: :g')
64 if [ "${version}" != "" ]; then
65 java-utils_ensure-vm-version-ge ${version}
66 fi
67 }
68
69 java-utils_ensure-vm-version-ge() {
70 if ! java-utils_is-vm-version-ge $@ ; then
71 eerror "This package requires a Java VM version >= $@"
72 einfo "Please use java-config -S to set the correct one"
73 die "Active Java VM too old"
74 fi
75 }
76
77 java-utils_is-vm-version-ge() {
78 local user_major=${1:-0}
79 local user_minor=${2:-0}
80 local user_patch=${3:-0}
81 local user_version=${user_major}.${user_minor}.${user_patch}
82
83 local vm_version=$(java-utils_get-vm-version)
84
85 local vm_major=$(echo ${vm_version} | cut -d. -f1)
86 local vm_minor=$(echo ${vm_version} | cut -d. -f2)
87 local vm_patch=$(echo ${vm_version} | cut -d. -f3)
88 local vm_extra=$(echo ${vm_version} | cut -d. -f4)
89
90 if [ ${vm_major} -ge ${user_major} ] && [ ${vm_minor} -gt ${user_minor} ] ; then
91 echo "Detected a JDK >= ${user_version}"
92 return 0
93 elif [ ${vm_major} -ge ${user_major} ] && [ ${vm_minor} -ge ${user_minor} ] && [ ${vm_patch} -ge ${user_patch} ] ; then
94 echo "Detected a JDK >= ${user_version}"
95 return 0
96 else
97 echo "Detected a JDK < ${user_version}"
98 return 1
99 fi
100 }

  ViewVC Help
Powered by ViewVC 1.1.20