| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2004 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/java-vm-2.eclass,v 1.15 2006/10/20 03:52:24 nichoj Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/java-vm-2.eclass,v 1.23 2008/08/29 19:10:19 caster Exp $ |
| 4 | |
4 | |
| 5 | # ----------------------------------------------------------------------------- |
5 | # ----------------------------------------------------------------------------- |
| 6 | # @eclass-begin |
6 | # @eclass-begin |
| 7 | # @eclass-shortdesc Java Virtual Machine eclass |
7 | # @eclass-shortdesc Java Virtual Machine eclass |
| 8 | # @eclass-maintainer java@gentoo.org |
8 | # @eclass-maintainer java@gentoo.org |
| … | |
… | |
| 10 | # This eclass provides functionality which assists with installing |
10 | # This eclass provides functionality which assists with installing |
| 11 | # virtual machines, and ensures that they are recognized by java-config. |
11 | # virtual machines, and ensures that they are recognized by java-config. |
| 12 | # |
12 | # |
| 13 | # ----------------------------------------------------------------------------- |
13 | # ----------------------------------------------------------------------------- |
| 14 | |
14 | |
| 15 | inherit eutils |
15 | inherit eutils fdo-mime |
| 16 | |
16 | |
| 17 | DEPEND=" |
17 | DEPEND=" |
| 18 | =dev-java/java-config-2.0* |
18 | =dev-java/java-config-2* |
| 19 | >=sys-apps/portage-2.1" |
19 | >=sys-apps/portage-2.1" |
| 20 | RDEPEND=" |
20 | RDEPEND=" |
| 21 | =dev-java/java-config-2.0* |
21 | =dev-java/java-config-2* |
| 22 | =dev-java/java-config-1.3*" |
22 | =dev-java/java-config-1.3*" |
| 23 | |
23 | |
| 24 | export WANT_JAVA_CONFIG=2 |
24 | export WANT_JAVA_CONFIG=2 |
| 25 | |
|
|
| 26 | if [[ "${SLOT}" != "0" ]]; then |
|
|
| 27 | VMHANDLE=${PN}-${SLOT} |
|
|
| 28 | else |
|
|
| 29 | VMHANDLE=${PN} |
|
|
| 30 | fi |
|
|
| 31 | |
25 | |
| 32 | JAVA_VM_CONFIG_DIR="/usr/share/java-config-2/vm" |
26 | JAVA_VM_CONFIG_DIR="/usr/share/java-config-2/vm" |
| 33 | JAVA_VM_DIR="/usr/lib/jvm" |
27 | JAVA_VM_DIR="/usr/lib/jvm" |
| 34 | |
28 | |
| 35 | EXPORT_FUNCTIONS pkg_postinst pkg_prerm |
29 | EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_prerm pkg_postrm |
|
|
30 | |
|
|
31 | java-vm-2_pkg_setup() { |
|
|
32 | if [[ "${SLOT}" != "0" ]]; then |
|
|
33 | VMHANDLE=${PN}-${SLOT} |
|
|
34 | else |
|
|
35 | VMHANDLE=${PN} |
|
|
36 | fi |
|
|
37 | } |
| 36 | |
38 | |
| 37 | java-vm-2_pkg_postinst() { |
39 | java-vm-2_pkg_postinst() { |
| 38 | # Set the generation-2 system VM, if it isn't set |
40 | # Set the generation-2 system VM, if it isn't set |
| 39 | if [[ -z "$(java-config-2 -f)" ]]; then |
41 | if [[ -z "$(java-config-2 -f)" ]]; then |
| 40 | java_set_default_vm_ |
42 | java_set_default_vm_ |
| … | |
… | |
| 78 | |
80 | |
| 79 | echo |
81 | echo |
| 80 | |
82 | |
| 81 | java-vm_check-nsplugin |
83 | java-vm_check-nsplugin |
| 82 | java_mozilla_clean_ |
84 | java_mozilla_clean_ |
|
|
85 | fdo-mime_desktop_database_update |
| 83 | } |
86 | } |
| 84 | |
87 | |
| 85 | java-vm_check-nsplugin() { |
88 | java-vm_check-nsplugin() { |
| 86 | local libdir |
89 | local libdir |
| 87 | if [[ ${VMHANDLE} =~ emul-linux-x86 ]]; then |
90 | if [[ ${VMHANDLE} =~ emul-linux-x86 ]]; then |
| … | |
… | |
| 122 | ewarn "Please run java-config -L to list available VMs," |
125 | ewarn "Please run java-config -L to list available VMs," |
| 123 | ewarn "then use java-config -S to set a new system-vm!" |
126 | ewarn "then use java-config -S to set a new system-vm!" |
| 124 | fi |
127 | fi |
| 125 | } |
128 | } |
| 126 | |
129 | |
|
|
130 | java-vm-2_pkg_postrm() { |
|
|
131 | fdo-mime_desktop_database_update |
|
|
132 | } |
|
|
133 | |
| 127 | java_set_default_vm_() { |
134 | java_set_default_vm_() { |
| 128 | java-config-2 --set-system-vm="${VMHANDLE}" |
135 | java-config-2 --set-system-vm="${VMHANDLE}" |
| 129 | |
136 | |
| 130 | einfo " ${P} set as the default system-vm." |
137 | einfo " ${P} set as the default system-vm." |
| 131 | } |
138 | } |
| … | |
… | |
| 139 | echo ${sarch} |
146 | echo ${sarch} |
| 140 | } |
147 | } |
| 141 | |
148 | |
| 142 | # TODO rename to something more evident, like install_env_file |
149 | # TODO rename to something more evident, like install_env_file |
| 143 | set_java_env() { |
150 | set_java_env() { |
|
|
151 | debug-print-function ${FUNCNAME} $* |
| 144 | local platform="$(get_system_arch)" |
152 | local platform="$(get_system_arch)" |
| 145 | local env_file="${D}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}" |
153 | local env_file="${D}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}" |
| 146 | local old_env_file="${D}/etc/env.d/java/20${P}" |
154 | local old_env_file="${D}/etc/env.d/java/20${P}" |
|
|
155 | if [[ ${1} ]]; then |
|
|
156 | local source_env_file="${1}" |
|
|
157 | else |
| 147 | local source_env_file="${FILESDIR}/${VMHANDLE}.env" |
158 | local source_env_file="${FILESDIR}/${VMHANDLE}.env" |
|
|
159 | fi |
| 148 | |
160 | |
| 149 | if [[ ! -f ${source_env_file} ]]; then |
161 | if [[ ! -f ${source_env_file} ]]; then |
| 150 | die "Unable to find the env file: ${source_env_file}" |
162 | die "Unable to find the env file: ${source_env_file}" |
| 151 | fi |
163 | fi |
| 152 | |
164 | |
| … | |
… | |
| 186 | # Make the symlink |
198 | # Make the symlink |
| 187 | dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \ |
199 | dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \ |
| 188 | || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}" |
200 | || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}" |
| 189 | } |
201 | } |
| 190 | |
202 | |
|
|
203 | # ----------------------------------------------------------------------------- |
|
|
204 | # @ebuild-function java-vm_revdep-mask |
|
|
205 | # |
|
|
206 | # Installs a revdep-rebuild control file which SEARCH_DIR_MASK set to the path |
|
|
207 | # where the VM is installed. Prevents pointless rebuilds - see bug #177925. |
|
|
208 | # Also gives a notice to the user. |
|
|
209 | # |
|
|
210 | # @example |
|
|
211 | # java-vm_revdep-mask |
|
|
212 | # java-vm_revdep-mask /path/to/jdk/ |
|
|
213 | # |
|
|
214 | # @param $1 - Path of the VM (defaults to /opt/${P} if not set) |
|
|
215 | # ------------------------------------------------------------------------------ |
|
|
216 | java-vm_revdep-mask() { |
|
|
217 | local VMROOT="${1-/opt/${P}}" |
|
|
218 | |
|
|
219 | dodir /etc/revdep-rebuild/ |
|
|
220 | echo "SEARCH_DIRS_MASK=\"${VMROOT}\""> "${D}/etc/revdep-rebuild/61-${VMHANDLE}" |
|
|
221 | |
|
|
222 | elog "A revdep-rebuild control file was installed to prevent reinstalls due to" |
|
|
223 | elog "missing dependencies (see bug #177925 for more info). Note that some parts" |
|
|
224 | elog "of the JVM may require dependencies that are pulled only through respective" |
|
|
225 | elog "USE flags (typically X, alsa, odbc) and some Java code may fail without them." |
|
|
226 | } |
| 191 | |
227 | |
| 192 | java_get_plugin_dir_() { |
228 | java_get_plugin_dir_() { |
| 193 | echo /usr/$(get_libdir)/nsbrowser/plugins |
229 | echo /usr/$(get_libdir)/nsbrowser/plugins |
| 194 | } |
230 | } |
| 195 | |
231 | |
| 196 | install_mozilla_plugin() { |
232 | install_mozilla_plugin() { |
| 197 | local plugin=${1} |
233 | local plugin="${1}" |
|
|
234 | local variant="${2}" |
| 198 | |
235 | |
| 199 | if [ ! -f "${D}/${plugin}" ] ; then |
236 | if [[ ! -f "${D}/${plugin}" ]]; then |
| 200 | die "Cannot find mozilla plugin at ${D}/${plugin}" |
237 | die "Cannot find mozilla plugin at ${D}/${plugin}" |
| 201 | fi |
238 | fi |
| 202 | |
239 | |
|
|
240 | if [[ -n "${variant}" ]]; then |
|
|
241 | variant="-${variant}" |
|
|
242 | fi |
|
|
243 | |
| 203 | local plugin_dir=/usr/share/java-config-2/nsplugin |
244 | local plugin_dir="/usr/share/java-config-2/nsplugin" |
| 204 | dodir ${plugin_dir} |
245 | dodir "${plugin_dir}" |
| 205 | dosym ${plugin} ${plugin_dir}/${VMHANDLE}-javaplugin.so |
246 | dosym "${plugin}" "${plugin_dir}/${VMHANDLE}${variant}-javaplugin.so" |
| 206 | } |
247 | } |
| 207 | |
248 | |
| 208 | java_mozilla_clean_() { |
249 | java_mozilla_clean_() { |
| 209 | # Because previously some ebuilds installed symlinks outside of pkg_install |
250 | # Because previously some ebuilds installed symlinks outside of pkg_install |
| 210 | # and are left behind, which forces you to manualy remove them to select the |
251 | # and are left behind, which forces you to manualy remove them to select the |