/[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.5 - (show annotations) (download)
Sat Jul 15 13:55:06 2006 UTC (7 years, 11 months ago) by grobian
Branch: MAIN
Changes since 1.4: +2 -2 lines
Bash 2.59 compatibility change.  Necessary for Gentoo for Mac OS X.
Permission to commit from nichoj.  See bug #139899

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.4 2006/06/30 15:00:07 nichoj Exp $
4 #
5 # Author: Karl Trygve Kalleberg <karltk@gentoo.org>
6
7 inherit eutils
8
9 DEPEND="
10 =dev-java/java-config-2.0*
11 =dev-java/java-config-1.3*
12 >=sys-apps/portage-2.1"
13 RDEPEND="
14 =dev-java/java-config-2.0*
15 =dev-java/java-config-1.3*"
16
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 local systemvm1="$(java-config-1 -f)"
38 # no generation-1 system-vm was yet set
39 if [[ -z "${systemvm1}" ]]; then
40 einfo "No valid generation-1 system-vm set, setting to ${P}"
41 java-config-1 --set-system-vm=${P}
42 # dirty check to see if we are upgrading current generation-1 system vm
43 elif [[ x${systemvm1} = x${VMHANDLE} ]]; then
44 einfo "Upgrading generation-1 system-vm... updating its env file"
45 java-config-1 --set-system-vm=${P}
46 fi
47 # else... some other VM is being updated, so we don't have to worry
48 fi
49
50 if has nsplugin ${IUSE} && use nsplugin; then
51 if [[ ! -f /usr/lib/nsbrowser/plugins/javaplugin.so ]]; then
52 eselect java-nsplugin set ${VMHANDLE}
53 fi
54 fi
55
56 java_mozilla_clean_
57 }
58
59 java-vm-2_pkg_prerm() {
60 if [[ "$(java-config -f)" == "${VMHANDLE}" ]]; then
61 ewarn "It appears you are removing your default system VM!"
62 ewarn "Please run java-config -L then java-config -S to set a new system VM!"
63 fi
64 }
65
66 java_set_default_vm_() {
67 java-config-2 --set-system-vm="${VMHANDLE}"
68
69 einfo " After installing ${P} this"
70 einfo " was set as the default JVM to run."
71 }
72
73 get_system_arch() {
74 local sarch
75 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/)
76 if [ -z "${sarch}" ]; then
77 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/)
78 fi
79 echo ${sarch}
80 }
81
82 # TODO rename to something more evident, like install_env_file
83 set_java_env() {
84 local platform="$(get_system_arch)"
85 local env_file="${D}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}"
86 local old_env_file="${D}/etc/env.d/java/20${P}"
87 local source_env_file="${FILESDIR}/${VMHANDLE}.env"
88
89 if [[ ! -f ${source_env_file} ]]; then
90 die "Unable to find the env file: ${source_env_file}"
91 fi
92
93 dodir ${JAVA_VM_CONFIG_DIR}
94 dodir /etc/env.d/java # generation-1 compatibility
95 sed \
96 -e "s/@P@/${P}/g" \
97 -e "s/@PN@/${PN}/g" \
98 -e "s/@PV@/${PV}/g" \
99 -e "s/@PF@/${PF}/g" \
100 -e "s/@PLATFORM@/${platform}/g" \
101 -e "/^LDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
102 < ${source_env_file} \
103 > ${env_file} || die "sed failed"
104
105 echo "VMHANDLE=\"${VMHANDLE}\"" >> ${env_file}
106
107 # generation-1 compatibility
108 if [[ ${JAVA_VM_NO_GENERATION1} != true ]]; then
109 # We need to strip some things out of the new style env,
110 # because these end up going in the env
111 sed -e 's/.*CLASSPATH.*//' \
112 -e 's/.*PROVIDES.*//' \
113 ${env_file} \
114 > ${old_env_file} || die "failed to create old-style env file"
115 fi
116
117 [[ -n ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" >> ${env_file}
118
119 local java_home=$(source ${env_file}; echo ${JAVA_HOME})
120 [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}"
121
122 # Make the symlink
123 dosym ${java_home} ${JAVA_VM_DIR}/${VMHANDLE} \
124 || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDE}"
125 }
126
127
128 java_get_plugin_dir_() {
129 echo /usr/$(get_libdir)/nsbrowser/plugins
130 }
131
132 install_mozilla_plugin() {
133 local plugin=${1}
134
135 if [ ! -f "${D}/${plugin}" ] ; then
136 die "Cannot find mozilla plugin at ${D}/${plugin}"
137 fi
138
139 local plugin_dir=/usr/share/java-config-2/nsplugin
140 dodir ${plugin_dir}
141 dosym ${plugin} ${plugin_dir}/${VMHANDLE}-javaplugin.so
142 }
143
144 java_mozilla_clean_() {
145 # Because previously some ebuilds installed symlinks outside of pkg_install
146 # and are left behind, which forces you to manualy remove them to select the
147 # jdk/jre you want to use for java
148 local plugin_dir=$(java_get_plugin_dir_)
149 for file in ${plugin_dir}/javaplugin_*; do
150 rm -f ${file}
151 done
152 for file in ${plugin_dir}/libjavaplugin*; do
153 rm -f ${file}
154 done
155 }

  ViewVC Help
Powered by ViewVC 1.1.20