EAPI=6 support; removed support befor media-video/vdr-2
[gentoo.git] / eclass / mozilla-launcher.eclass
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 inherit nsplugins multilib
6
7 if [[ ${PN: -4} != "-bin" ]] ; then
8         IUSE="moznopango"
9 fi
10
11 # update_mozilla_launcher_symlinks
12 # --------------------------------
13 # Create or remove the following symlinks in /usr/bin:
14 #
15 #    firefox -> firefox-bin
16 #    thunderbird -> thunderbird-bin
17 #    mozilla -> mozilla-bin
18 #    sunbird -> sunbird-bin
19 #    seamonkey -> seamonkey-bin
20 #
21 # The symlinks are removed if they're found to be dangling.  They are
22 # created according to the following rules:
23 #
24 # - If there's a -bin symlink in /usr/bin, and no corresponding
25 #   non-bin symlink, then create one.
26 #
27 # - Can't do this in src_install otherwise it overwrites the one
28 #   for the non-bin package.
29 #
30 # - Link to the -bin symlink so it's easier to detect when to
31 #   remove the symlink.
32 #
33 # NOTE: This eclass does *not* manage the launcher stubs in /usr/bin except
34 # when a -bin package is installed and the corresponding from-source
35 # package is not installed.  The usual stubs are actually installed in
36 # src_install so they are included in the package inventory.
37 #
38 update_mozilla_launcher_symlinks() {
39         local f browsers="mozilla firefox thunderbird sunbird seamonkey"
40         cd "${ROOT}"/usr/bin
41
42         # Remove launcher symlinks that no longer apply
43
44         for f in ${browsers}; do
45                 if [[ -L ${f} && ! -f ${f} ]]; then
46                         einfo "Removing dangling ${f} launcher"
47                         rm -f ${f}
48                 fi
49         done
50
51         # Create new symlinks
52
53         for f in ${browsers}; do
54                 if [[ -e ${f}-bin && ! -e ${f} ]]; then
55                         einfo "Adding link from ${f}-bin to ${f}"
56                         ln -s ${f}-bin ${f}
57                 fi
58         done
59 }
60
61 # install_mozilla_launcher_stub name libdir
62 # -----------------------------------------
63 # Install a stub called /usr/bin/$name that executes mozilla-launcher
64 #
65 # Note: $PLUGINS_DIR comes from nsplugins (specifically the deprecated section).
66 #
67 install_mozilla_launcher_stub() {
68         [[ -n $2 ]] || die "install_launcher_stub requires two arguments"
69         declare name=$1
70         declare libdir=$2
71
72         # If we use xulrunner, the name of the binary should be the same
73         if [[ ${name: -3} == "xul" ]]; then
74                 name=${name/xul/}
75                 declare appname=xulrunner
76                 declare xulparams="export XUL_PARAMS=${libdir}/application.ini"
77                 declare libdir="/usr/$(get_libdir)/xulrunner-1.9"
78         else
79                 declare appname=${name}
80         fi
81
82         dodir /usr/bin
83
84         if [[ ${PN: -4} == "-bin" ]]  || ! use moznopango; then
85         cat <<EOF >"${D}"/usr/bin/${name}
86 #!/bin/sh
87 #
88 # Stub script to run mozilla-launcher.  We used to use a symlink here
89 # but OOo brokenness makes it necessary to use a stub instead:
90 # https://bugs.gentoo.org/show_bug.cgi?id=78890
91
92 export MOZILLA_LAUNCHER=${appname}
93 export MOZILLA_LIBDIR=${libdir}
94 export MOZ_PLUGIN_PATH=\${MOZ_PLUGIN_PATH:-/usr/$(get_libdir)/$PLUGINS_DIR}
95 ${xulparams}
96 exec /usr/libexec/mozilla-launcher "\$@"
97 EOF
98         else
99         cat <<EOF >"${D}"/usr/bin/${name}
100 #!/bin/sh
101 #
102 # Stub script to run mozilla-launcher.  We used to use a symlink here
103 # but OOo brokenness makes it necessary to use a stub instead:
104 # https://bugs.gentoo.org/show_bug.cgi?id=78890
105
106 export MOZILLA_LAUNCHER=${appname}
107 export MOZILLA_LIBDIR=${libdir}
108 export MOZ_PLUGIN_PATH=\${MOZ_PLUGIN_PATH:-/usr/$(get_libdir)/$PLUGINS_DIR}
109 export MOZ_DISABLE_PANGO=1
110 ${xulparams}
111 exec /usr/libexec/mozilla-launcher "\$@"
112 EOF
113         fi
114         chmod 0755 "${D}"/usr/bin/${name}
115 }
116
117 warn_mozilla_launcher_stub() {
118         elog "Not all locales support the disabling of pango."
119         elog "If your locale does not support disabling pango,"
120         elog "please open a bug report on https://bugs.gentoo.org"
121         elog "Then we can filter around the problem with those"
122         elog "specific locales."
123 }