/[gentoo-alt]/trunk/prefix/eclass/java.eclass
Gentoo

Contents of /trunk/prefix/eclass/java.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 982 - (show annotations) (download)
Thu Feb 2 04:20:17 2006 UTC (13 years, 2 months ago) by kito
File size: 3979 byte(s)
Initial eclass import from gentoo-x86
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.eclass,v 1.28 2006/01/20 00:08:39 nichoj Exp $
4 #
5 # Author: Karl Trygve Kalleberg <karltk@gentoo.org>
6
7 inherit eutils
8
9 DESCRIPTION="Based on the $ECLASS eclass"
10 DEPEND=">=dev-java/java-config-1.2.11
11 sys-apps/findutils"
12 RDEPEND=">=dev-java/java-config-1.2.11"
13
14 VMHANDLE=${PN}-${PV}
15
16 EXPORT_FUNCTIONS pkg_postinst pkg_prerm
17
18 java_pkg_postinst() {
19 local jdk=${PN#*-}
20 if [ ${jdk:0:3} == "jdk" ]; then
21 java_set_default_vm_
22 else
23 # Only install the JRE as the system default if there's no JDK
24 # installed. Installing a JRE over an existing JDK will result
25 # in major breakage, see #9289.
26 if [ ! -f "${JAVAC}" ]; then
27 ewarn "Found no JDK, setting ${VMHANDLE} as default system VM"
28 java_set_default_vm_
29 fi
30 fi
31 java_mozilla_clean_
32 }
33
34 java_pkg_prerm() {
35 if java-config -J | grep -q ${P} ; then
36 ewarn "It appears you are removing your default system VM!"
37 ewarn "Please run java-config -L then java-config-S to set a new system VM!"
38 fi
39 }
40
41 java_set_default_vm_() {
42 java-config --set-system-vm=${VMHANDLE}
43 /usr/sbin/env-update
44 source /etc/profile
45
46 echo
47 einfo " After installing ${P} this"
48 einfo " was set as the default JVM to run."
49 einfo " When finished please run the following so your"
50 einfo " enviroment gets updated."
51 eerror " /usr/sbin/env-update && source /etc/profile"
52 einfo " Or use java-config program to set your preferred VM"
53 }
54
55 system_arch() {
56 local sarch
57 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/`
58 if [ -z "$sarch" ] ; then
59 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/`
60 fi
61 echo $sarch
62 }
63
64 set_java_env() {
65 dodir /etc/env.d/java
66 platform=`system_arch`
67
68 sed \
69 -e "s/@P@/${P}/g" \
70 -e "s/@PN@/${PN}/g" \
71 -e "s/@PV@/${PV}/g" \
72 -e "s/@PF@/${PF}/g" \
73 -e "s/@PLATFORM@/${platform}/g" \
74 -e "/^ADDLDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
75 < $1 \
76 > ${D}/etc/env.d/java/20`basename $1` || die
77 }
78
79
80 java_get_plugin_dir_() {
81 echo /usr/$(get_libdir)/nsbrowser/plugins
82 }
83
84 install_mozilla_plugin() {
85 if [ ! -f ${D}/$1 ] ; then
86 die "Cannot find mozilla plugin at ${D}/${1}"
87 fi
88
89 local plugin_dir=$(java_get_plugin_dir_)
90 dodir ${plugin_dir}
91 dosym ${1} ${plugin_dir}/javaplugin.so
92 }
93
94 java_mozilla_clean_() {
95 #Because previously some ebuilds installed symlinks outside of pkg_install
96 #and are left behind, which forces you to manualy remove them to select the
97 #jdk/jre you want to use for java
98 local plugin_dir=$(java_get_plugin_dir_)
99 for file in ${plugin_dir}/javaplugin_*; do
100 rm -f ${file}
101 done
102 for file in ${plugin_dir}/libjavaplugin*; do
103 rm -f ${file}
104 done
105 }
106
107 # Use this to remove libjsoundalsa.so from ${D}.
108 # You generally would want to use this like:
109 # use !alsa && java_remove-libjoundalsa /opt/${P}
110 java_remove-libjsoundalsa() {
111 [[ ${#} -ne 1 ]] && die "Expected one argument"
112 local search_path="$@"
113 local libs=$(find ${D}/${search_path} -name libjsoundalsa.so)
114 if [[ -n ${libs} ]]; then
115 rm ${libs} || die "Failed to delete ${libs}"
116 fi
117 }
118
119 # Symlinks i386 to i?86. Updates env file to then use i?86
120 # for LD_LIBRARY_PATH. See bug #23579.
121 #
122 # Takes an argument, which is a directory living in ${D}
123 # which has a directory named i386, that should be i686, i486, etc.
124 # This argument defaults to /opt/${P}/jre/lib
125 fix-i386-dir() {
126 [[ ${#} != 1 ]] && die "Expected one argument"
127 local libdir=${1}
128 if use x86; then
129 local host=${CTARGET:-${CHOST}}
130 host=${host%%-*}
131
132 if [[ ${host} != i386 ]]; then
133 local orig_dir="${libdir}/i386"
134 local new_dir="${libdir}/${host}"
135 dosym i386 ${new_dir} || die "Failed to dosym"
136
137
138 sed -i -e "s/i386/${host}/g" \
139 ${D}/etc/env.d/java/20${VMHANDLE} || die "Failed to sed"
140 fi
141 fi
142 }

  ViewVC Help
Powered by ViewVC 1.1.20