/[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.6 - (show annotations) (download)
Tue Aug 1 12:23:57 2006 UTC (7 years, 8 months ago) by nichoj
Branch: MAIN
Changes since 1.5: +4 -3 lines
Reverted a change to the check during pkg_postinst that reset the system vm if it was the package being upgraded. Uses a bash-3 specific feature, so added it to DEPEND.

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

  ViewVC Help
Powered by ViewVC 1.1.20