/[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.12 - (show annotations) (download)
Fri Sep 29 16:51:01 2006 UTC (7 years, 11 months ago) by caster
Branch: MAIN
Changes since 1.11: +5 -1 lines
Inform user about (not) setting nsplugin.

1 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/java-vm-2.eclass,v 1.11 2006/09/10 20:59:11 betelgeuse Exp $
4
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 #
13 # -----------------------------------------------------------------------------
14
15 inherit eutils
16
17 DEPEND="
18 =dev-java/java-config-2.0*
19 >=sys-apps/portage-2.1"
20 RDEPEND="
21 =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 RDEPEND="${RDEPEND} =dev-java/java-config-1.3*"
27 fi
28
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 # support both variables for now
49 if [[ ${JAVA_SUPPORTS_GENERATION_1} == 'true' && ${JAVA_VM_NO_GENERATION1} != 'true' ]]; then
50 local systemvm1="$(java-config-1 -f 2>/dev/null)"
51 # no generation-1 system-vm was previously set
52 if [[ -z "${systemvm1}" ]]; then
53 # 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 # dirty check to see if we are upgrading current generation-1 system vm
64 elif [[ "${systemvm1}" = ${VMHANDLE}* ]]; then
65 einfo "Emerging the current generation-1 system-vm..."
66 einfo "Updating its config files."
67 java-config-1 --set-system-vm=${P} 2>/dev/null
68 # dirty check to see if current system vm is a jre - replace it with
69 elif [[ "${systemvm1}" = *jre* ]]; then
70 ewarn "Current generation-1 system-vm is a JRE"
71 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 java-config-1 --set-system-vm=${P} 2>/dev/null
75 fi
76 # else... some other VM is being updated, so we don't have to worry
77 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 fi
83
84 # Install a default nsplugin if we don't already have one
85 if has nsplugin ${IUSE} && use nsplugin; then
86 if [[ ! -f /usr/lib/nsbrowser/plugins/javaplugin.so ]]; then
87 einfo "You have no system nsplugin set, setting it to ${VMHANDLE}."
88 eselect java-nsplugin set ${VMHANDLE}
89 else
90 einfo "System nsplugin is already set, not changing it."
91 fi
92 einfo "You can change nsplugin with eselect java-nsplugin."
93 fi
94
95 java_mozilla_clean_
96 }
97
98 java-vm-2_pkg_prerm() {
99 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 fi
104 }
105
106 java_set_default_vm_() {
107 java-config-2 --set-system-vm="${VMHANDLE}"
108
109 einfo " ${P} set as the default system-vm."
110 }
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 local source_env_file="${FILESDIR}/${VMHANDLE}.env"
127
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
145 # generation-1 compatibility
146 # 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 # 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 > ${old_env_file} || die "failed to create generation-1 env file"
156 else
157 ewarn "Disabling generation-1 compatibility..."
158 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 || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}"
168 }
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 local plugin_dir=/usr/share/java-config-2/nsplugin
183 dodir ${plugin_dir}
184 dosym ${plugin} ${plugin_dir}/${VMHANDLE}-javaplugin.so
185 }
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 # ------------------------------------------------------------------------------
201 # @eclass-end
202 # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20