/[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.32 - (hide annotations) (download)
Fri Jul 8 11:35:01 2011 UTC (3 years, 5 months ago) by ssuominen
Branch: MAIN
Changes since 1.31: +2 -2 lines
Convert every instance of hasq to has.

1 nichoj 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 ssuominen 1.32 # $Header: /var/cvsroot/gentoo-x86/eclass/java-vm-2.eclass,v 1.31 2010/04/17 08:30:36 betelgeuse 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.30 inherit eutils fdo-mime multilib
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 nichoj 1.9 # Install a default nsplugin if we don't already have one
58 nichoj 1.3 if has nsplugin ${IUSE} && use nsplugin; then
59 nichoj 1.15 if [[ ! -f /usr/${libdir}/nsbrowser/plugins/javaplugin.so ]]; then
60     einfo "No system nsplugin currently set."
61     java-vm_set-nsplugin
62 caster 1.12 else
63     einfo "System nsplugin is already set, not changing it."
64 nichoj 1.3 fi
65 caster 1.12 einfo "You can change nsplugin with eselect java-nsplugin."
66 nichoj 1.3 fi
67 nichoj 1.15 }
68 nichoj 1.3
69 nichoj 1.15 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 nichoj 1.1 }
83    
84     java-vm-2_pkg_prerm() {
85 betelgeuse 1.22 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 nichoj 1.1 }
91    
92 betelgeuse 1.16 java-vm-2_pkg_postrm() {
93     fdo-mime_desktop_database_update
94     }
95    
96 nichoj 1.1 java_set_default_vm_() {
97     java-config-2 --set-system-vm="${VMHANDLE}"
98    
99 nichoj 1.9 einfo " ${P} set as the default system-vm."
100 nichoj 1.1 }
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 betelgeuse 1.20 debug-print-function ${FUNCNAME} $*
114 nichoj 1.1 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 betelgeuse 1.20 if [[ ${1} ]]; then
118     local source_env_file="${1}"
119     else
120     local source_env_file="${FILESDIR}/${VMHANDLE}.env"
121     fi
122 nichoj 1.1
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 caster 1.30 -e "s/@LIBDIR@/$(get_libdir)/g" \
135 nichoj 1.1 -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
136 betelgeuse 1.31 < "${source_env_file}" \
137     > "${env_file}" || die "sed failed"
138 nichoj 1.1
139 ali_bush 1.28 (
140     echo "VMHANDLE=\"${VMHANDLE}\""
141 maekke 1.29 echo "BUILD_ONLY=\"${JAVA_VM_BUILD_ONLY}\""
142 betelgeuse 1.31 ) >> "${env_file}"
143 swegener 1.13
144 nichoj 1.1 [[ -n ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" >> ${env_file}
145    
146 betelgeuse 1.31 local java_home=$(source "${env_file}"; echo ${JAVA_HOME})
147 nichoj 1.1 [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}"
148    
149     # Make the symlink
150     dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \
151 nichoj 1.10 || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}"
152 nichoj 1.1 }
153    
154 caster 1.19 # -----------------------------------------------------------------------------
155     # @ebuild-function java-vm_revdep-mask
156     #
157     # Installs a revdep-rebuild control file which SEARCH_DIR_MASK set to the path
158     # where the VM is installed. Prevents pointless rebuilds - see bug #177925.
159     # Also gives a notice to the user.
160     #
161     # @example
162     # java-vm_revdep-mask
163     # java-vm_revdep-mask /path/to/jdk/
164     #
165     # @param $1 - Path of the VM (defaults to /opt/${P} if not set)
166     # ------------------------------------------------------------------------------
167     java-vm_revdep-mask() {
168     local VMROOT="${1-/opt/${P}}"
169    
170     dodir /etc/revdep-rebuild/
171     echo "SEARCH_DIRS_MASK=\"${VMROOT}\""> "${D}/etc/revdep-rebuild/61-${VMHANDLE}"
172 maekke 1.24
173 caster 1.19 elog "A revdep-rebuild control file was installed to prevent reinstalls due to"
174     elog "missing dependencies (see bug #177925 for more info). Note that some parts"
175     elog "of the JVM may require dependencies that are pulled only through respective"
176     elog "USE flags (typically X, alsa, odbc) and some Java code may fail without them."
177     }
178 nichoj 1.1
179     java_get_plugin_dir_() {
180     echo /usr/$(get_libdir)/nsbrowser/plugins
181     }
182    
183     install_mozilla_plugin() {
184 caster 1.23 local plugin="${1}"
185     local variant="${2}"
186 nichoj 1.1
187 caster 1.23 if [[ ! -f "${D}/${plugin}" ]]; then
188 nichoj 1.1 die "Cannot find mozilla plugin at ${D}/${plugin}"
189     fi
190    
191 caster 1.23 if [[ -n "${variant}" ]]; then
192     variant="-${variant}"
193     fi
194    
195     local plugin_dir="/usr/share/java-config-2/nsplugin"
196     dodir "${plugin_dir}"
197     dosym "${plugin}" "${plugin_dir}/${VMHANDLE}${variant}-javaplugin.so"
198 nichoj 1.1 }
199    
200     java_mozilla_clean_() {
201     # Because previously some ebuilds installed symlinks outside of pkg_install
202     # and are left behind, which forces you to manualy remove them to select the
203     # jdk/jre you want to use for java
204     local plugin_dir=$(java_get_plugin_dir_)
205     for file in ${plugin_dir}/javaplugin_*; do
206     rm -f ${file}
207     done
208     for file in ${plugin_dir}/libjavaplugin*; do
209     rm -f ${file}
210     done
211     }
212    
213 nichoj 1.9 # ------------------------------------------------------------------------------
214     # @eclass-end
215     # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20