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