nsplugins.eclass 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. inherit eutils multilib versionator mozextension
  14. PLUGINS_DIR="nsbrowser/plugins"
  15. # This function move the plugin dir in src_install() to
  16. # ${D}/usr/$(get_libdir)/${PLUGIN_DIR}. First argument should be
  17. # the full path (without $D) to old plugin dir.
  18. src_mv_plugins() {
  19. has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
  20. # Move plugins dir. We use keepdir so that it might not be unmerged
  21. # by mistake ...
  22. keepdir /usr/$(get_libdir)/${PLUGINS_DIR}
  23. cp -a "${ED}"/$1/* "${ED}"/usr/$(get_libdir)/${PLUGINS_DIR}
  24. rm -rf "${ED}"/$1
  25. dosym /usr/$(get_libdir)/${PLUGINS_DIR} $1
  26. }
  27. # This function move plugins in pkg_preinst() in old dir to
  28. # ${ROOT}/usr/$(get_libdir)/${PLUGIN_DIR}. First argument should be
  29. # the full path (without $ROOT) to old plugin dir.
  30. pkg_mv_plugins() {
  31. has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${ROOT}"
  32. # Move old plugins dir
  33. if [ -d "${ROOT}/$1" -a ! -L "${ROOT}/$1" ]
  34. then
  35. mkdir -p "${EROOT}"/usr/$(get_libdir)/${PLUGINS_DIR}
  36. cp -a "${EROOT}"/$1/* "${EROOT}"/usr/$(get_libdir)/${PLUGINS_DIR}
  37. rm -rf "${EROOT}"/$1
  38. fi
  39. }
  40. # This function installs a plugin with dosym to PLUGINS_DIR.
  41. # First argument should be the plugin file.
  42. inst_plugin() {
  43. if [[ -z "${1}" ]]; then
  44. eerror "The plugin file \"${1}\" does not exist."
  45. die "No such file or directory."
  46. fi
  47. dodir /usr/$(get_libdir)/${PLUGINS_DIR}
  48. dosym ${1} /usr/$(get_libdir)/${PLUGINS_DIR}/$(basename ${1})
  49. }
  50. # This function ensures we use proper plugin path for Gentoo.
  51. # This should only be used by mozilla packages.
  52. # ${MOZILLA_FIVE_HOME} must be defined in src_install to support
  53. share_plugins_dir() {
  54. if [[ ${PN} == seamonkey ]] ; then
  55. rm -rf "${D}"${MOZILLA_FIVE_HOME}/plugins \
  56. || die "failed to remove existing plugins dir"
  57. fi
  58. if [[ ${PN} == *-bin ]] ; then
  59. PLUGIN_BASE_PATH="/usr/$(get_libdir)"
  60. else
  61. PLUGIN_BASE_PATH=".."
  62. fi
  63. if $(mozversion_extension_location) ; then
  64. dosym "${PLUGIN_BASE_PATH}/nsbrowser/plugins" "${MOZILLA_FIVE_HOME}/browser/plugins"
  65. else
  66. dosym "${PLUGIN_BASE_PATH}/nsbrowser/plugins" "${MOZILLA_FIVE_HOME}/plugins"
  67. fi
  68. }