kde-plasma/breeze-gtk: x86 stable wrt bug #613144
[gentoo.git] / eclass / nsplugins.eclass
1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 #
4 # @ECLASS: nsplugins.eclass
5 # @MAINTAINER:
6 # Mozilla Team <mozilla@gentoo.org>
7 # @AUTHOR:
8 # Original Author: Martin Schlemmer <azarah@gentoo.org>
9 # @BLURB: reusable functions for netscape/moz plugin sharing
10 # @DESCRIPTION:
11 # Reusable functions that promote sharing of netscape/moz plugins, also provides
12 # share_plugins_dir function for mozilla applications.
13
14 inherit eutils multilib versionator mozextension
15
16 PLUGINS_DIR="nsbrowser/plugins"
17
18 # This function move the plugin dir in src_install() to
19 # ${D}/usr/$(get_libdir)/${PLUGIN_DIR}.  First argument should be
20 # the full path (without $D) to old plugin dir.
21 src_mv_plugins() {
22         has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
23
24         # Move plugins dir.  We use keepdir so that it might not be unmerged
25         # by mistake ...
26         keepdir /usr/$(get_libdir)/${PLUGINS_DIR}
27         cp -a "${ED}"/$1/* "${ED}"/usr/$(get_libdir)/${PLUGINS_DIR}
28         rm -rf "${ED}"/$1
29         dosym /usr/$(get_libdir)/${PLUGINS_DIR} $1
30 }
31
32 # This function move plugins in pkg_preinst() in old dir to
33 # ${ROOT}/usr/$(get_libdir)/${PLUGIN_DIR}.  First argument should be
34 # the full path (without $ROOT) to old plugin dir.
35 pkg_mv_plugins() {
36         has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${ROOT}"
37
38         # Move old plugins dir
39         if [ -d "${ROOT}/$1" -a ! -L "${ROOT}/$1" ]
40         then
41                 mkdir -p "${EROOT}"/usr/$(get_libdir)/${PLUGINS_DIR}
42                 cp -a "${EROOT}"/$1/* "${EROOT}"/usr/$(get_libdir)/${PLUGINS_DIR}
43                 rm -rf "${EROOT}"/$1
44         fi
45 }
46
47 # This function installs a plugin with dosym to PLUGINS_DIR.
48 # First argument should be the plugin file.
49 inst_plugin() {
50         if [[ -z "${1}" ]]; then
51                 eerror "The plugin file \"${1}\" does not exist."
52                 die "No such file or directory."
53         fi
54
55         dodir /usr/$(get_libdir)/${PLUGINS_DIR}
56         dosym ${1} /usr/$(get_libdir)/${PLUGINS_DIR}/$(basename ${1})
57 }
58
59 # This function ensures we use proper plugin path for Gentoo.
60 # This should only be used by mozilla packages.
61 # ${MOZILLA_FIVE_HOME} must be defined in src_install to support
62 share_plugins_dir() {
63         if [[ ${PN} == seamonkey ]] ; then
64                 rm -rf "${D}"${MOZILLA_FIVE_HOME}/plugins \
65                         || die "failed to remove existing plugins dir"
66         fi
67
68         if [[ ${PN} == *-bin ]] ; then
69                 PLUGIN_BASE_PATH="/usr/$(get_libdir)"
70         else
71                 PLUGIN_BASE_PATH=".."
72         fi
73
74         if $(mozversion_extension_location) ; then
75                 dosym "${PLUGIN_BASE_PATH}/nsbrowser/plugins" "${MOZILLA_FIVE_HOME}/browser/plugins"
76         else
77                 dosym "${PLUGIN_BASE_PATH}/nsbrowser/plugins" "${MOZILLA_FIVE_HOME}/plugins"
78         fi
79 }