/[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.27 - (hide annotations) (download)
Fri Apr 17 22:50:41 2009 UTC (6 years ago) by caster
Branch: MAIN
Changes since 1.26: +1 -60 lines
Stop supporting generation 1

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

  ViewVC Help
Powered by ViewVC 1.1.20