summaryrefslogtreecommitdiff
blob: a8e0825b9dc5ca862ef82cb5c61cec3eb8923943 (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
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/nsplugins.eclass,v 1.28 2011/12/27 17:55:12 fauli Exp $
#
# @ECLASS: nsplugins.eclass
# @MAINTAINER:
# Mozilla Team <mozilla@gentoo.org>
# @AUTHOR:
# Original Author: Martin Schlemmer <azarah@gentoo.org>
# @BLURB: reusable functions for netscape/moz plugin sharing
# @DESCRIPTION:
# Reusable functions that promote sharing of netscape/moz plugins, also provides
# share_plugins_dir function for mozilla applications.

inherit eutils

DESCRIPTION="Based on the ${ECLASS} eclass"

PLUGINS_DIR="nsbrowser/plugins"

# This function move the plugin dir in src_install() to
# ${D}/usr/$(get_libdir)/${PLUGIN_DIR}.  First argument should be
# the full path (without $D) to old plugin dir.
src_mv_plugins() {
	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"

	# Move plugins dir.  We use keepdir so that it might not be unmerged
	# by mistake ...
	keepdir /usr/$(get_libdir)/${PLUGINS_DIR}
	cp -a "${ED}"/$1/* "${ED}"/usr/$(get_libdir)/${PLUGINS_DIR}
	rm -rf "${ED}"/$1
	dosym /usr/$(get_libdir)/${PLUGINS_DIR} $1
}

# This function move plugins in pkg_preinst() in old dir to
# ${ROOT}/usr/$(get_libdir)/${PLUGIN_DIR}.  First argument should be
# the full path (without $ROOT) to old plugin dir.
pkg_mv_plugins() {
	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${ROOT}"

	# Move old plugins dir
	if [ -d "${ROOT}/$1" -a ! -L "${ROOT}/$1" ]
	then
		mkdir -p "${EROOT}"/usr/$(get_libdir)/${PLUGINS_DIR}
		cp -a "${EROOT}"/$1/* "${EROOT}"/usr/$(get_libdir)/${PLUGINS_DIR}
		rm -rf "${EROOT}"/$1
	fi
}

# This function installs a plugin with dosym to PLUGINS_DIR.
# First argument should be the plugin file.
inst_plugin() {
	dodir /usr/$(get_libdir)/${PLUGINS_DIR}
	dosym ${1} /usr/$(get_libdir)/${PLUGINS_DIR}/$(basename ${1})
}

# This function ensures we use proper plugin path for Gentoo.
# This should only be used by mozilla packages.
# ${MOZILLA_FIVE_HOME} must be defined in src_install to support
share_plugins_dir() {
	if [[ ${PN} == seamonkey ]] ; then
		rm -rf "${D}"${MOZILLA_FIVE_HOME}/plugins \
			|| die "failed to remove existing plugins dir"
	fi

	if [[ ${PN} == *-bin ]] ; then
		PLUGIN_BASE_PATH="/usr/$(get_libdir)"
	else
		PLUGIN_BASE_PATH=".."
	fi

	dosym "${PLUGIN_BASE_PATH}/nsbrowser/plugins" "${MOZILLA_FIVE_HOME}/plugins"
}