/[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.28 - (hide annotations) (download)
Thu Aug 27 21:49:04 2009 UTC (5 years ago) by ali_bush
Branch: MAIN
Changes since 1.27: +6 -2 lines
Suuport for multi-provider virtuals and build only vms

1 nichoj 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 ali_bush 1.28 # $Header: /var/cvsroot/gentoo-x86/eclass/java-vm-2.eclass,v 1.27 2009/04/17 22:50:41 caster 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 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     -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
135     < ${source_env_file} \
136     > ${env_file} || die "sed failed"
137    
138 ali_bush 1.28 (
139     echo "VMHANDLE=\"${VMHANDLE}\""
140     echo "BUILD_ONLY=\"${JAVA_VM_BUILD_ONLY}\""
141     ) >> ${env_file}
142 swegener 1.13
143 nichoj 1.1 [[ -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 nichoj 1.10 || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}"
151 nichoj 1.1 }
152    
153 caster 1.19 # -----------------------------------------------------------------------------
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 maekke 1.24
172 caster 1.19 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 nichoj 1.1
178     java_get_plugin_dir_() {
179     echo /usr/$(get_libdir)/nsbrowser/plugins
180     }
181    
182     install_mozilla_plugin() {
183 caster 1.23 local plugin="${1}"
184     local variant="${2}"
185 nichoj 1.1
186 caster 1.23 if [[ ! -f "${D}/${plugin}" ]]; then
187 nichoj 1.1 die "Cannot find mozilla plugin at ${D}/${plugin}"
188     fi
189    
190 caster 1.23 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 nichoj 1.1 }
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 nichoj 1.9 # ------------------------------------------------------------------------------
213     # @eclass-end
214     # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20