/[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.33 - (hide annotations) (download)
Thu Sep 1 14:15:57 2011 UTC (3 years, 11 months ago) by caster
Branch: MAIN
Changes since 1.32: +26 -10 lines
Prefix support, thanks to sera and darkside.

1 nichoj 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 caster 1.33 # $Header: /var/cvsroot/gentoo-x86/eclass/java-vm-2.eclass,v 1.32 2011/07/08 11:35:01 ssuominen Exp $
4 nichoj 1.9
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 nichoj 1.1 #
13 nichoj 1.9 # -----------------------------------------------------------------------------
14 nichoj 1.1
15 caster 1.33 inherit eutils fdo-mime multilib prefix
16 nichoj 1.1
17 betelgeuse 1.26 DEPEND="=dev-java/java-config-2*"
18 ssuominen 1.32 has "${EAPI}" 0 1 && DEPEND="${DEPEND} >=sys-apps/portage-2.1"
19 betelgeuse 1.26
20 nichoj 1.1 RDEPEND="
21 caster 1.25 =dev-java/java-config-2*"
22    
23 nichoj 1.1 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 ali_bush 1.28 JAVA_VM_BUILD_ONLY="${JAVA_VM_BUILD_ONLY:-FALSE}"
28 nichoj 1.1
29 betelgeuse 1.22 EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_prerm pkg_postrm
30 betelgeuse 1.17
31     java-vm-2_pkg_setup() {
32     if [[ "${SLOT}" != "0" ]]; then
33     VMHANDLE=${PN}-${SLOT}
34     else
35     VMHANDLE=${PN}
36     fi
37     }
38 nichoj 1.1
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 nichoj 1.15 java-vm_check-nsplugin
46     java_mozilla_clean_
47 betelgeuse 1.16 fdo-mime_desktop_database_update
48 nichoj 1.15 }
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 caster 1.33
58     has ${EAPI:-0} 0 1 2 && ! use prefix && EPREFIX=
59    
60 nichoj 1.9 # Install a default nsplugin if we don't already have one
61 nichoj 1.3 if has nsplugin ${IUSE} && use nsplugin; then
62 caster 1.33 if [[ ! -f "${EPREFIX}"/usr/${libdir}/nsbrowser/plugins/javaplugin.so ]]; then
63 nichoj 1.15 einfo "No system nsplugin currently set."
64     java-vm_set-nsplugin
65 caster 1.12 else
66     einfo "System nsplugin is already set, not changing it."
67 nichoj 1.3 fi
68 caster 1.12 einfo "You can change nsplugin with eselect java-nsplugin."
69 nichoj 1.3 fi
70 nichoj 1.15 }
71 nichoj 1.3
72 nichoj 1.15 java-vm_set-nsplugin() {
73     local extra_args
74     if use amd64; then
75     if [[ ${VMHANDLE} =~ emul-linux-x86 ]]; then
76     extra_args="32bit"
77     else
78     extra_args="64bit"
79     fi
80     einfo "Setting ${extra_args} nsplugin to ${VMHANDLE}"
81     else
82     einfo "Setting nsplugin to ${VMHANDLE}..."
83     fi
84     eselect java-nsplugin set ${extra_args} ${VMHANDLE}
85 nichoj 1.1 }
86    
87     java-vm-2_pkg_prerm() {
88 betelgeuse 1.22 if [[ "$(java-config -f 2>/dev/null)" == "${VMHANDLE}" ]]; then
89     ewarn "It appears you are removing your system-vm!"
90     ewarn "Please run java-config -L to list available VMs,"
91     ewarn "then use java-config -S to set a new system-vm!"
92     fi
93 nichoj 1.1 }
94    
95 betelgeuse 1.16 java-vm-2_pkg_postrm() {
96     fdo-mime_desktop_database_update
97     }
98    
99 nichoj 1.1 java_set_default_vm_() {
100     java-config-2 --set-system-vm="${VMHANDLE}"
101    
102 nichoj 1.9 einfo " ${P} set as the default system-vm."
103 nichoj 1.1 }
104    
105     get_system_arch() {
106     local sarch
107     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/)
108     if [ -z "${sarch}" ]; then
109     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/)
110     fi
111     echo ${sarch}
112     }
113    
114     # TODO rename to something more evident, like install_env_file
115     set_java_env() {
116 betelgeuse 1.20 debug-print-function ${FUNCNAME} $*
117 caster 1.33
118     has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
119    
120 nichoj 1.1 local platform="$(get_system_arch)"
121 caster 1.33 local env_file="${ED}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}"
122     local old_env_file="${ED}/etc/env.d/java/20${P}"
123 betelgeuse 1.20 if [[ ${1} ]]; then
124     local source_env_file="${1}"
125     else
126     local source_env_file="${FILESDIR}/${VMHANDLE}.env"
127     fi
128 nichoj 1.1
129     if [[ ! -f ${source_env_file} ]]; then
130     die "Unable to find the env file: ${source_env_file}"
131     fi
132    
133     dodir ${JAVA_VM_CONFIG_DIR}
134     sed \
135     -e "s/@P@/${P}/g" \
136     -e "s/@PN@/${PN}/g" \
137     -e "s/@PV@/${PV}/g" \
138     -e "s/@PF@/${PF}/g" \
139     -e "s/@PLATFORM@/${platform}/g" \
140 caster 1.30 -e "s/@LIBDIR@/$(get_libdir)/g" \
141 nichoj 1.1 -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
142 betelgeuse 1.31 < "${source_env_file}" \
143     > "${env_file}" || die "sed failed"
144 nichoj 1.1
145 ali_bush 1.28 (
146     echo "VMHANDLE=\"${VMHANDLE}\""
147 maekke 1.29 echo "BUILD_ONLY=\"${JAVA_VM_BUILD_ONLY}\""
148 betelgeuse 1.31 ) >> "${env_file}"
149 swegener 1.13
150 caster 1.33 eprefixify ${env_file}
151    
152 nichoj 1.1 [[ -n ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" >> ${env_file}
153    
154 betelgeuse 1.31 local java_home=$(source "${env_file}"; echo ${JAVA_HOME})
155 nichoj 1.1 [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}"
156    
157     # Make the symlink
158 caster 1.33 dodir "${JAVA_VM_DIR}"
159 nichoj 1.1 dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \
160 nichoj 1.10 || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}"
161 nichoj 1.1 }
162    
163 caster 1.19 # -----------------------------------------------------------------------------
164     # @ebuild-function java-vm_revdep-mask
165     #
166     # Installs a revdep-rebuild control file which SEARCH_DIR_MASK set to the path
167     # where the VM is installed. Prevents pointless rebuilds - see bug #177925.
168     # Also gives a notice to the user.
169     #
170     # @example
171     # java-vm_revdep-mask
172     # java-vm_revdep-mask /path/to/jdk/
173     #
174     # @param $1 - Path of the VM (defaults to /opt/${P} if not set)
175     # ------------------------------------------------------------------------------
176     java-vm_revdep-mask() {
177 caster 1.33 if has ${EAPI:-0} 0 1 2 && ! use prefix; then
178     ED="${D}"
179     EPREFIX=
180     fi
181    
182     local VMROOT="${1-"${EPREFIX}"/opt/${P}}"
183 caster 1.19
184     dodir /etc/revdep-rebuild/
185 caster 1.33 echo "SEARCH_DIRS_MASK=\"${VMROOT}\""> "${ED}/etc/revdep-rebuild/61-${VMHANDLE}"
186 maekke 1.24
187 caster 1.19 elog "A revdep-rebuild control file was installed to prevent reinstalls due to"
188     elog "missing dependencies (see bug #177925 for more info). Note that some parts"
189     elog "of the JVM may require dependencies that are pulled only through respective"
190     elog "USE flags (typically X, alsa, odbc) and some Java code may fail without them."
191     }
192 nichoj 1.1
193     java_get_plugin_dir_() {
194 caster 1.33 has ${EAPI:-0} 0 1 2 && ! use prefix && EPREFIX=
195     echo "${EPREFIX}"/usr/$(get_libdir)/nsbrowser/plugins
196 nichoj 1.1 }
197    
198     install_mozilla_plugin() {
199 caster 1.23 local plugin="${1}"
200     local variant="${2}"
201 nichoj 1.1
202 caster 1.33 has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}"
203     if [[ ! -f "${ED}/${plugin}" ]]; then
204     die "Cannot find mozilla plugin at ${ED}/${plugin}"
205 nichoj 1.1 fi
206    
207 caster 1.23 if [[ -n "${variant}" ]]; then
208     variant="-${variant}"
209     fi
210    
211     local plugin_dir="/usr/share/java-config-2/nsplugin"
212     dodir "${plugin_dir}"
213     dosym "${plugin}" "${plugin_dir}/${VMHANDLE}${variant}-javaplugin.so"
214 nichoj 1.1 }
215    
216     java_mozilla_clean_() {
217     # Because previously some ebuilds installed symlinks outside of pkg_install
218     # and are left behind, which forces you to manualy remove them to select the
219     # jdk/jre you want to use for java
220     local plugin_dir=$(java_get_plugin_dir_)
221     for file in ${plugin_dir}/javaplugin_*; do
222     rm -f ${file}
223     done
224     for file in ${plugin_dir}/libjavaplugin*; do
225     rm -f ${file}
226     done
227     }
228    
229 nichoj 1.9 # ------------------------------------------------------------------------------
230     # @eclass-end
231     # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20