summaryrefslogtreecommitdiff
blob: 0cc1b880a57668fa56acd16a809c57a683b7b548 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/java.eclass,v 1.20 2004/09/29 20:58:45 axxo Exp $
#
# Author: Karl Trygve Kalleberg <karltk@gentoo.org>

inherit eutils

ECLASS=java
INHERITED="$INHERITED $ECLASS"
DESCRIPTION="Based on the $ECLASS eclass"

VMHANDLE=${PN}-${PV}

EXPORT_FUNCTIONS pkg_postinst pkg_prerm

java_pkg_postinst() {
	local jdk=${PN#*-}
	if [ ${jdk:0:3} == "jdk" ]; then
		java_set_default_vm_
	else
		# Only install the JRE as the system default if there's no JDK
		# installed. Installing a JRE over an existing JDK will result
		# in major breakage, see #9289.
		if [ ! -f "${JAVAC}" ]; then
			 ewarn "Found no JDK, setting ${VMHANDLE} as default system VM"
			java_set_default_vm_
	fi
	fi
	java_mozilla_clean_
}

java_pkg_prerm() {
	if java-config -J | grep -q ${P} ; then
		ewarn "It appears you are removing your default system VM!"
		ewarn "Please run java-config -L then java-config-S to set a new system VM!"
	fi
}

java_set_default_vm_() {
		java-config --set-system-vm=${VMHANDLE}
		/usr/sbin/env-update
		source /etc/profile

	echo
	einfo " After installing ${P} this"
	einfo " was set as the default JVM to run."
	einfo " When finished please run the following so your"
	einfo " enviroment gets updated."
	eerror "	/usr/sbin/env-update && source /etc/profile"
	einfo " Or use java-config program to set your preferred VM"
}

system_arch() {
	local sarch
	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/`
	if [ -z "$sarch" ] ; then
		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/`
	fi
	echo $sarch
}

set_java_env() {
	dodir /etc/env.d/java
	platform=`system_arch`

	sed \
		-e "s/@P@/${P}/g" \
		-e "s/@PN@/${PN}/g" \
		-e "s/@PV@/${PV}/g" \
		-e "s/@PF@/${PF}/g" \
		-e "s/@PLATFORM@/${platform}/g" \
		-e "/^ADDLDPATH=.*lib\\/\\\"/s|\"\\(.*\\)\"|\"\\1${platform}/:\\1${platform}/server/\"|" \
		< $1 \
		> ${D}/etc/env.d/java/20`basename $1` || die
}


java_get_plugin_dir_() {
	echo /usr/$(get_libdir)/nsbrowser/plugins
}

install_mozilla_plugin() {
	if [ ! -f ${D}/$1 ] ; then
		die "Cannot find mozilla plugin at ${D}/${1}"
	fi

	local plugin_dir=$(java_get_plugin_dir_)
	dodir ${plugin_dir}
	dosym ${1} ${plugin_dir}/javaplugin.so
}

java_mozilla_clean_() {
	#Because previously some ebuilds installed symlinks outside of pkg_install
	#and are left behind, which forces you to manualy remove them to select the
	#jdk/jre you want to use for java
	local plugin_dir=$(java_get_plugin_dir_)
	for file in ${plugin_dir}/javaplugin_*; do
		rm -f ${file}
	done
	for file in ${plugin_dir}/libjavaplugin*; do
		rm -f ${file}
	done
}