/[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.8 - (hide annotations) (download)
Thu Aug 31 01:03:11 2006 UTC (8 years, 6 months ago) by nichoj
Branch: MAIN
Changes since 1.7: +24 -9 lines
Changed use of =~ to using wildcards, allowing us to remove the bash-3 dependency. Also improved some of the checks during postinstall, to make sure the Java environment is sane.

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

  ViewVC Help
Powered by ViewVC 1.1.20