/[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.10 - (hide annotations) (download)
Sat Sep 2 01:42:57 2006 UTC (8 years, 1 month ago) by nichoj
Branch: MAIN
Changes since 1.9: +2 -2 lines
Fixed typo in variable name, as pointed out by pioto

1 nichoj 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 nichoj 1.10 # $Header: /var/cvsroot/gentoo-x86/eclass/java-vm-2.eclass,v 1.9 2006/09/01 03:00:47 nichoj 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     RDEPEND="${DDEPEND} =dev-java/java-config-1.3*"
27     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     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 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     eselect java-nsplugin set ${VMHANDLE}
88     fi
89     fi
90    
91 nichoj 1.1 java_mozilla_clean_
92     }
93    
94     java-vm-2_pkg_prerm() {
95 nichoj 1.9 if [[ "$(java-config -f 2>/dev/null)" == "${VMHANDLE}" ]]; then
96     ewarn "It appears you are removing your system-vm!"
97     ewarn "Please run java-config -L to list available VMs,"
98     ewarn "then use java-config -S to set a new system-vm!"
99 nichoj 1.1 fi
100     }
101    
102     java_set_default_vm_() {
103     java-config-2 --set-system-vm="${VMHANDLE}"
104    
105 nichoj 1.9 einfo " ${P} set as the default system-vm."
106 nichoj 1.1 }
107    
108     get_system_arch() {
109     local sarch
110     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/)
111     if [ -z "${sarch}" ]; then
112     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/)
113     fi
114     echo ${sarch}
115     }
116    
117     # TODO rename to something more evident, like install_env_file
118     set_java_env() {
119     local platform="$(get_system_arch)"
120     local env_file="${D}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}"
121     local old_env_file="${D}/etc/env.d/java/20${P}"
122 nichoj 1.2 local source_env_file="${FILESDIR}/${VMHANDLE}.env"
123 nichoj 1.1
124     if [[ ! -f ${source_env_file} ]]; then
125     die "Unable to find the env file: ${source_env_file}"
126     fi
127    
128     dodir ${JAVA_VM_CONFIG_DIR}
129     sed \
130     -e "s/@P@/${P}/g" \
131     -e "s/@PN@/${PN}/g" \
132     -e "s/@PV@/${PV}/g" \
133     -e "s/@PF@/${PF}/g" \
134     -e "s/@PLATFORM@/${platform}/g" \
135     -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
136     < ${source_env_file} \
137     > ${env_file} || die "sed failed"
138    
139     echo "VMHANDLE=\"${VMHANDLE}\"" >> ${env_file}
140    
141     # generation-1 compatibility
142 nichoj 1.9 # respect both variables for now...
143     if [[ ${JAVA_SUPPORTS_GENERATION_1} == 'true' && ${JAVA_VM_NO_GENERATION1} != 'true' ]]; then
144     einfo "Enabling generation-1 compatibility..."
145     dodir /etc/env.d/java # generation-1 compatibility
146 nichoj 1.1 # We need to strip some things out of the new style env,
147     # because these end up going in the env
148     sed -e 's/.*CLASSPATH.*//' \
149     -e 's/.*PROVIDES.*//' \
150     ${env_file} \
151 nichoj 1.9 > ${old_env_file} || die "failed to create generation-1 env file"
152     else
153     ewarn "Disabling generation-1 compatibility..."
154 nichoj 1.1 fi
155    
156     [[ -n ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" >> ${env_file}
157    
158     local java_home=$(source ${env_file}; echo ${JAVA_HOME})
159     [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}"
160    
161     # Make the symlink
162     dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \
163 nichoj 1.10 || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}"
164 nichoj 1.1 }
165    
166    
167     java_get_plugin_dir_() {
168     echo /usr/$(get_libdir)/nsbrowser/plugins
169     }
170    
171     install_mozilla_plugin() {
172     local plugin=${1}
173    
174     if [ ! -f "${D}/${plugin}" ] ; then
175     die "Cannot find mozilla plugin at ${D}/${plugin}"
176     fi
177    
178 nichoj 1.3 local plugin_dir=/usr/share/java-config-2/nsplugin
179 nichoj 1.1 dodir ${plugin_dir}
180 nichoj 1.3 dosym ${plugin} ${plugin_dir}/${VMHANDLE}-javaplugin.so
181 nichoj 1.1 }
182    
183     java_mozilla_clean_() {
184     # Because previously some ebuilds installed symlinks outside of pkg_install
185     # and are left behind, which forces you to manualy remove them to select the
186     # jdk/jre you want to use for java
187     local plugin_dir=$(java_get_plugin_dir_)
188     for file in ${plugin_dir}/javaplugin_*; do
189     rm -f ${file}
190     done
191     for file in ${plugin_dir}/libjavaplugin*; do
192     rm -f ${file}
193     done
194     }
195    
196 nichoj 1.9 # ------------------------------------------------------------------------------
197     # @eclass-end
198     # ------------------------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.20