php-pear-lib-r1.eclass 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: php-pear-lib-r1.eclass
  4. # @MAINTAINER:
  5. # Gentoo PHP team <php-bugs@gentoo.org>
  6. # @AUTHOR:
  7. # Author: Luca Longinotti <chtekk@gentoo.org>
  8. # @BLURB: Provides means for an easy installation of PEAR-based libraries.
  9. # @DESCRIPTION:
  10. # This class provides means for an easy installation of PEAR-based libraries,
  11. # such as Creole, Jargon, Phing etc., while retaining the functionality to put
  12. # the libraries into version-dependant directories.
  13. inherit multilib
  14. EXPORT_FUNCTIONS pkg_setup src_install
  15. # Silence repoman warnings
  16. case "${EAPI:-0}" in
  17. 5)
  18. PHP_DEPEND="dev-lang/php:*"
  19. ;;
  20. *)
  21. PHP_DEPEND="dev-lang/php"
  22. ;;
  23. esac
  24. DEPEND="${PHP_DEPEND}
  25. >=dev-php/pear-1.9.0"
  26. RDEPEND="${DEPEND}"
  27. if [[ -n $PHP_PEAR_CHANNEL ]] ; then
  28. PHP_PEAR_PV=${PV/_rc/RC}
  29. [[ -z ${PHP_PEAR_PN} ]] && die "Missing PHP_PEAR_PN. Please notify the maintainer"
  30. PHP_PEAR_P=${PHP_PEAR_PN}-${PHP_PEAR_PV}
  31. S="${WORKDIR}/${PHP_PEAR_P}"
  32. SRC_URI="http://${PHP_PEAR_URI}/get/${PHP_PEAR_P}.tgz"
  33. fi
  34. # @FUNCTION: php-pear-lib-r1_pkg_setup
  35. # @DESCRIPTION:
  36. # Adds required PEAR channel if necessary
  37. php-pear-lib-r1_pkg_setup() {
  38. if [[ -n $PHP_PEAR_CHANNEL ]] ; then
  39. if [[ -f $PHP_PEAR_CHANNEL ]]; then
  40. pear channel-add $PHP_PEAR_CHANNEL || einfo "Ignore any errors about existing channels"
  41. else
  42. die "Could not find channel file $PHP_PEAR_CHANNEL"
  43. fi
  44. fi
  45. }
  46. # @FUNCTION: php-pear-lib-r1_src_install
  47. # @DESCRIPTION:
  48. # Takes care of standard install for PEAR-based libraries.
  49. php-pear-lib-r1_src_install() {
  50. # SNMP support
  51. addpredict /usr/share/snmp/mibs/.index
  52. addpredict /var/lib/net-snmp/
  53. addpredict /var/lib/net-snmp/mib_indexes
  54. addpredict /session_mm_cli0.sem
  55. PHP_BIN="/usr/bin/php"
  56. cd "${S}"
  57. # metadata_dir needs to be set relative to ${D} for >=dev-php/PEAR-PEAR-1.10
  58. if [[ -f "${WORKDIR}"/package2.xml ]] ; then
  59. mv -f "${WORKDIR}/package2.xml" "${S}"
  60. local WWW_DIR="/usr/share/webapps/${PN}/${PVR}/htdocs"
  61. peardev -d php_bin="${PHP_BIN}" -d www_dir="${WWW_DIR}" -d metadata_dir="/usr/share/php" \
  62. install --force --loose --nodeps --offline --packagingroot="${D}" \
  63. "${S}/package2.xml" || die "Unable to install PEAR package"
  64. else
  65. mv -f "${WORKDIR}/package.xml" "${S}"
  66. local WWW_DIR="/usr/share/webapps/${PN}/${PVR}/htdocs"
  67. peardev -d php_bin="${PHP_BIN}" -d www_dir="${WWW_DIR}" -d metadata_dir="/usr/share/php" \
  68. install --force --loose --nodeps --offline --packagingroot="${D}" \
  69. "${S}/package.xml" || die "Unable to install PEAR package"
  70. fi
  71. rm -Rf "${D}/usr/share/php/.channels" \
  72. "${D}/usr/share/php/.depdblock" \
  73. "${D}/usr/share/php/.depdb" \
  74. "${D}/usr/share/php/.filemap" \
  75. "${D}/usr/share/php/.lock" \
  76. "${D}/usr/share/php/.registry"
  77. einfo
  78. einfo "Installing to /usr/share/php ..."
  79. einfo
  80. }