/[gentoo-x86]/eclass/java-vm-2.eclass
Gentoo

Contents of /eclass/java-vm-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.29 - (show annotations) (download)
Sun Oct 11 11:46:59 2009 UTC (4 years, 9 months ago) by maekke
Branch: MAIN
Changes since 1.28: +2 -2 lines
whitespace

1 # Copyright 1999-2004 Gentoo Foundation
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.28 2009/08/27 21:49:04 ali_bush Exp $
4
5 # -----------------------------------------------------------------------------
6 # @eclass-begin
7 # @eclass-shortdesc Java Virtual Machine eclass
8 # @eclass-maintainer java@gentoo.org
9 #
10 # This eclass provides functionality which assists with installing
11 # virtual machines, and ensures that they are recognized by java-config.
12 #
13 # -----------------------------------------------------------------------------
14
15 inherit eutils fdo-mime
16
17 DEPEND="=dev-java/java-config-2*"
18 hasq "${EAPI}" 0 1 && DEPEND="${DEPEND} >=sys-apps/portage-2.1"
19
20 RDEPEND="
21 =dev-java/java-config-2*"
22
23 export WANT_JAVA_CONFIG=2
24
25 JAVA_VM_CONFIG_DIR="/usr/share/java-config-2/vm"
26 JAVA_VM_DIR="/usr/lib/jvm"
27 JAVA_VM_BUILD_ONLY="${JAVA_VM_BUILD_ONLY:-FALSE}"
28
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 }
38
39 java-vm-2_pkg_postinst() {
40 # Set the generation-2 system VM, if it isn't set
41 if [[ -z "$(java-config-2 -f)" ]]; then
42 java_set_default_vm_
43 fi
44
45 java-vm_check-nsplugin
46 java_mozilla_clean_
47 fdo-mime_desktop_database_update
48 }
49
50 java-vm_check-nsplugin() {
51 local libdir
52 if [[ ${VMHANDLE} =~ emul-linux-x86 ]]; then
53 libdir=lib32
54 else
55 libdir=lib
56 fi
57 # Install a default nsplugin if we don't already have one
58 if has nsplugin ${IUSE} && use nsplugin; then
59 if [[ ! -f /usr/${libdir}/nsbrowser/plugins/javaplugin.so ]]; then
60 einfo "No system nsplugin currently set."
61 java-vm_set-nsplugin
62 else
63 einfo "System nsplugin is already set, not changing it."
64 fi
65 einfo "You can change nsplugin with eselect java-nsplugin."
66 fi
67 }
68
69 java-vm_set-nsplugin() {
70 local extra_args
71 if use amd64; then
72 if [[ ${VMHANDLE} =~ emul-linux-x86 ]]; then
73 extra_args="32bit"
74 else
75 extra_args="64bit"
76 fi
77 einfo "Setting ${extra_args} nsplugin to ${VMHANDLE}"
78 else
79 einfo "Setting nsplugin to ${VMHANDLE}..."
80 fi
81 eselect java-nsplugin set ${extra_args} ${VMHANDLE}
82 }
83
84 java-vm-2_pkg_prerm() {
85 if [[ "$(java-config -f 2>/dev/null)" == "${VMHANDLE}" ]]; then
86 ewarn "It appears you are removing your system-vm!"
87 ewarn "Please run java-config -L to list available VMs,"
88 ewarn "then use java-config -S to set a new system-vm!"
89 fi
90 }
91
92 java-vm-2_pkg_postrm() {
93 fdo-mime_desktop_database_update
94 }
95
96 java_set_default_vm_() {
97 java-config-2 --set-system-vm="${VMHANDLE}"
98
99 einfo " ${P} set as the default system-vm."
100 }
101
102 get_system_arch() {
103 local sarch
104 sarch=$(echo ${ARCH} | sed -e s/[i]*.86/i386/ -e s/x86_64/amd64/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/)
105 if [ -z "${sarch}" ]; then
106 sarch=$(uname -m | sed -e s/[i]*.86/i386/ -e s/x86_64/amd64/ -e s/sun4u/sparc/ -e s/sparc64/sparc/ -e s/arm.*/arm/ -e s/sa110/arm/)
107 fi
108 echo ${sarch}
109 }
110
111 # TODO rename to something more evident, like install_env_file
112 set_java_env() {
113 debug-print-function ${FUNCNAME} $*
114 local platform="$(get_system_arch)"
115 local env_file="${D}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}"
116 local old_env_file="${D}/etc/env.d/java/20${P}"
117 if [[ ${1} ]]; then
118 local source_env_file="${1}"
119 else
120 local source_env_file="${FILESDIR}/${VMHANDLE}.env"
121 fi
122
123 if [[ ! -f ${source_env_file} ]]; then
124 die "Unable to find the env file: ${source_env_file}"
125 fi
126
127 dodir ${JAVA_VM_CONFIG_DIR}
128 sed \
129 -e "s/@P@/${P}/g" \
130 -e "s/@PN@/${PN}/g" \
131 -e "s/@PV@/${PV}/g" \
132 -e "s/@PF@/${PF}/g" \
133 -e "s/@PLATFORM@/${platform}/g" \
134 -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
135 < ${source_env_file} \
136 > ${env_file} || die "sed failed"
137
138 (
139 echo "VMHANDLE=\"${VMHANDLE}\""
140 echo "BUILD_ONLY=\"${JAVA_VM_BUILD_ONLY}\""
141 ) >> ${env_file}
142
143 [[ -n ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" >> ${env_file}
144
145 local java_home=$(source ${env_file}; echo ${JAVA_HOME})
146 [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}"
147
148 # Make the symlink
149 dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \
150 || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}"
151 }
152
153 # -----------------------------------------------------------------------------
154 # @ebuild-function java-vm_revdep-mask
155 #
156 # Installs a revdep-rebuild control file which SEARCH_DIR_MASK set to the path
157 # where the VM is installed. Prevents pointless rebuilds - see bug #177925.
158 # Also gives a notice to the user.
159 #
160 # @example
161 # java-vm_revdep-mask
162 # java-vm_revdep-mask /path/to/jdk/
163 #
164 # @param $1 - Path of the VM (defaults to /opt/${P} if not set)
165 # ------------------------------------------------------------------------------
166 java-vm_revdep-mask() {
167 local VMROOT="${1-/opt/${P}}"
168
169 dodir /etc/revdep-rebuild/
170 echo "SEARCH_DIRS_MASK=\"${VMROOT}\""> "${D}/etc/revdep-rebuild/61-${VMHANDLE}"
171
172 elog "A revdep-rebuild control file was installed to prevent reinstalls due to"
173 elog "missing dependencies (see bug #177925 for more info). Note that some parts"
174 elog "of the JVM may require dependencies that are pulled only through respective"
175 elog "USE flags (typically X, alsa, odbc) and some Java code may fail without them."
176 }
177
178 java_get_plugin_dir_() {
179 echo /usr/$(get_libdir)/nsbrowser/plugins
180 }
181
182 install_mozilla_plugin() {
183 local plugin="${1}"
184 local variant="${2}"
185
186 if [[ ! -f "${D}/${plugin}" ]]; then
187 die "Cannot find mozilla plugin at ${D}/${plugin}"
188 fi
189
190 if [[ -n "${variant}" ]]; then
191 variant="-${variant}"
192 fi
193
194 local plugin_dir="/usr/share/java-config-2/nsplugin"
195 dodir "${plugin_dir}"
196 dosym "${plugin}" "${plugin_dir}/${VMHANDLE}${variant}-javaplugin.so"
197 }
198
199 java_mozilla_clean_() {
200 # Because previously some ebuilds installed symlinks outside of pkg_install
201 # and are left behind, which forces you to manualy remove them to select the
202 # jdk/jre you want to use for java
203 local plugin_dir=$(java_get_plugin_dir_)
204 for file in ${plugin_dir}/javaplugin_*; do
205 rm -f ${file}
206 done
207 for file in ${plugin_dir}/libjavaplugin*; do
208 rm -f ${file}
209 done
210 }
211
212 # ------------------------------------------------------------------------------
213 # @eclass-end
214 # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20