/[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.13 - (hide annotations) (download)
Sat Oct 14 20:27:21 2006 UTC (8 years, 2 months ago) by swegener
Branch: MAIN
Changes since 1.12: +6 -6 lines
Apply whitespace checks from repoman to eclasses.

1 nichoj 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 swegener 1.13 # $Header: /var/cvsroot/gentoo-x86/eclass/java-vm-2.eclass,v 1.12 2006/09/29 16:51:01 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     inherit eutils
16    
17     DEPEND="
18     =dev-java/java-config-2.0*
19 nichoj 1.4 >=sys-apps/portage-2.1"
20 nichoj 1.1 RDEPEND="
21 nichoj 1.9 =dev-java/java-config-2.0*"
22    
23     # If the VM supports generation-1, we need to depend on java-config-1
24     if [[ ${JAVA_SUPPORTS_GENERATION_1} == 'true' ]]; then
25     DEPEND="${DEPEND} =dev-java/java-config-1.3*"
26 betelgeuse 1.11 RDEPEND="${RDEPEND} =dev-java/java-config-1.3*"
27 nichoj 1.9 fi
28 nichoj 1.1
29     export WANT_JAVA_CONFIG=2
30    
31     if [[ "${SLOT}" != "0" ]]; then
32     VMHANDLE=${PN}-${SLOT}
33     else
34     VMHANDLE=${PN}
35     fi
36    
37     JAVA_VM_CONFIG_DIR="/usr/share/java-config-2/vm"
38     JAVA_VM_DIR="/usr/lib/jvm"
39    
40     EXPORT_FUNCTIONS pkg_postinst pkg_prerm
41    
42     java-vm-2_pkg_postinst() {
43     # Set the generation-2 system VM, if it isn't set
44     if [[ -z "$(java-config-2 -f)" ]]; then
45     java_set_default_vm_
46     fi
47    
48 nichoj 1.9 # support both variables for now
49     if [[ ${JAVA_SUPPORTS_GENERATION_1} == 'true' && ${JAVA_VM_NO_GENERATION1} != 'true' ]]; then
50 nichoj 1.8 local systemvm1="$(java-config-1 -f 2>/dev/null)"
51 nichoj 1.9 # no generation-1 system-vm was previously set
52 nichoj 1.1 if [[ -z "${systemvm1}" ]]; then
53 nichoj 1.8 # if 20java exists, must be using old VM
54     if [[ -f /etc/env.d/20java ]]; then
55     ewarn "The current generation-1 system-vm is using an out-of-date VM,"
56     ewarn "as in, it hasn't been updated for use with the new Java sytem."
57     # othewise, it must not have been set before
58     else
59     ewarn "No generation-1 system-vm previously set."
60     fi
61     ewarn "Setting generation-1 system-vm to ${VMHANDLE}"
62     java-config-1 --set-system-vm=${P} 2>/dev/null
63 nichoj 1.1 # dirty check to see if we are upgrading current generation-1 system vm
64 nichoj 1.8 elif [[ "${systemvm1}" = ${VMHANDLE}* ]]; then
65 swegener 1.13 einfo "Emerging the current generation-1 system-vm..."
66 nichoj 1.8 einfo "Updating its config files."
67 swegener 1.13 java-config-1 --set-system-vm=${P} 2>/dev/null
68 nichoj 1.8 # dirty check to see if current system vm is a jre - replace it with
69     elif [[ "${systemvm1}" = *jre* ]]; then
70 swegener 1.13 ewarn "Current generation-1 system-vm is a JRE"
71 nichoj 1.8 ewarn "For the new and old Java systems to coexist,"
72     ewarn "the generation-1 system-vm must be a JDK."
73     ewarn "Setting generation-1 system-vm to ${VMHANDLE}"
74 swegener 1.13 java-config-1 --set-system-vm=${P} 2>/dev/null
75 nichoj 1.1 fi
76     # else... some other VM is being updated, so we don't have to worry
77 nichoj 1.9 else
78     einfo "JREs and 1.5+ JDKs are not supported for use with generation-1."
79     einfo "This is because generation-1 is only for use for building packages."
80     einfo "Only generation-2 should be used by end-users,"
81     einfo "where all JREs and JDKs will be available"
82 nichoj 1.1 fi
83    
84 nichoj 1.9 # Install a default nsplugin if we don't already have one
85 nichoj 1.3 if has nsplugin ${IUSE} && use nsplugin; then
86     if [[ ! -f /usr/lib/nsbrowser/plugins/javaplugin.so ]]; then
87 caster 1.12 einfo "You have no system nsplugin set, setting it to ${VMHANDLE}."
88 nichoj 1.3 eselect java-nsplugin set ${VMHANDLE}
89 caster 1.12 else
90     einfo "System nsplugin is already set, not changing it."
91 nichoj 1.3 fi
92 caster 1.12 einfo "You can change nsplugin with eselect java-nsplugin."
93 nichoj 1.3 fi
94    
95 nichoj 1.1 java_mozilla_clean_
96     }
97    
98     java-vm-2_pkg_prerm() {
99 nichoj 1.9 if [[ "$(java-config -f 2>/dev/null)" == "${VMHANDLE}" ]]; then
100     ewarn "It appears you are removing your system-vm!"
101     ewarn "Please run java-config -L to list available VMs,"
102     ewarn "then use java-config -S to set a new system-vm!"
103 nichoj 1.1 fi
104     }
105    
106     java_set_default_vm_() {
107     java-config-2 --set-system-vm="${VMHANDLE}"
108    
109 nichoj 1.9 einfo " ${P} set as the default system-vm."
110 nichoj 1.1 }
111    
112     get_system_arch() {
113     local sarch
114     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/)
115     if [ -z "${sarch}" ]; then
116     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/)
117     fi
118     echo ${sarch}
119     }
120    
121     # TODO rename to something more evident, like install_env_file
122     set_java_env() {
123     local platform="$(get_system_arch)"
124     local env_file="${D}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}"
125     local old_env_file="${D}/etc/env.d/java/20${P}"
126 nichoj 1.2 local source_env_file="${FILESDIR}/${VMHANDLE}.env"
127 nichoj 1.1
128     if [[ ! -f ${source_env_file} ]]; then
129     die "Unable to find the env file: ${source_env_file}"
130     fi
131    
132     dodir ${JAVA_VM_CONFIG_DIR}
133     sed \
134     -e "s/@P@/${P}/g" \
135     -e "s/@PN@/${PN}/g" \
136     -e "s/@PV@/${PV}/g" \
137     -e "s/@PF@/${PF}/g" \
138     -e "s/@PLATFORM@/${platform}/g" \
139     -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
140     < ${source_env_file} \
141     > ${env_file} || die "sed failed"
142    
143     echo "VMHANDLE=\"${VMHANDLE}\"" >> ${env_file}
144 swegener 1.13
145 nichoj 1.1 # generation-1 compatibility
146 nichoj 1.9 # respect both variables for now...
147     if [[ ${JAVA_SUPPORTS_GENERATION_1} == 'true' && ${JAVA_VM_NO_GENERATION1} != 'true' ]]; then
148     einfo "Enabling generation-1 compatibility..."
149     dodir /etc/env.d/java # generation-1 compatibility
150 nichoj 1.1 # We need to strip some things out of the new style env,
151     # because these end up going in the env
152     sed -e 's/.*CLASSPATH.*//' \
153     -e 's/.*PROVIDES.*//' \
154     ${env_file} \
155 nichoj 1.9 > ${old_env_file} || die "failed to create generation-1 env file"
156     else
157     ewarn "Disabling generation-1 compatibility..."
158 nichoj 1.1 fi
159    
160     [[ -n ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" >> ${env_file}
161    
162     local java_home=$(source ${env_file}; echo ${JAVA_HOME})
163     [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}"
164    
165     # Make the symlink
166     dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \
167 nichoj 1.10 || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}"
168 nichoj 1.1 }
169    
170    
171     java_get_plugin_dir_() {
172     echo /usr/$(get_libdir)/nsbrowser/plugins
173     }
174    
175     install_mozilla_plugin() {
176     local plugin=${1}
177    
178     if [ ! -f "${D}/${plugin}" ] ; then
179     die "Cannot find mozilla plugin at ${D}/${plugin}"
180     fi
181    
182 nichoj 1.3 local plugin_dir=/usr/share/java-config-2/nsplugin
183 nichoj 1.1 dodir ${plugin_dir}
184 nichoj 1.3 dosym ${plugin} ${plugin_dir}/${VMHANDLE}-javaplugin.so
185 nichoj 1.1 }
186    
187     java_mozilla_clean_() {
188     # Because previously some ebuilds installed symlinks outside of pkg_install
189     # and are left behind, which forces you to manualy remove them to select the
190     # jdk/jre you want to use for java
191     local plugin_dir=$(java_get_plugin_dir_)
192     for file in ${plugin_dir}/javaplugin_*; do
193     rm -f ${file}
194     done
195     for file in ${plugin_dir}/libjavaplugin*; do
196     rm -f ${file}
197     done
198     }
199    
200 nichoj 1.9 # ------------------------------------------------------------------------------
201     # @eclass-end
202     # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20