php-pear-r1.eclass 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: php-pear-r1.eclass
  4. # @MAINTAINER:
  5. # Gentoo PHP Team <php-bugs@gentoo.org>
  6. # @AUTHOR:
  7. # Author: Tal Peer <coredumb@gentoo.org>
  8. # Author: Luca Longinotti <chtekk@gentoo.org>
  9. # @BLURB: Provides means for an easy installation of PEAR packages.
  10. # @DESCRIPTION:
  11. # This eclass provides means for an easy installation of PEAR packages.
  12. # For more information on PEAR, see http://pear.php.net/
  13. # Note that this eclass doesn't handle dependencies of PEAR packages
  14. # on purpose; please use (R)DEPEND to define them correctly!
  15. inherit multilib
  16. EXPORT_FUNCTIONS pkg_setup src_install
  17. case "${EAPI:-0}" in
  18. 0|1|2|3|4)
  19. PHP_DEPEND="dev-lang/php"
  20. ;;
  21. 5|6)
  22. # Repoman will complain about the missing slot in newer EAPIs.
  23. PHP_DEPEND="dev-lang/php:*"
  24. ;;
  25. *)
  26. die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
  27. ;;
  28. esac
  29. DEPEND="${PHP_DEPEND}
  30. >=dev-php/pear-1.8.1"
  31. RDEPEND="${DEPEND}"
  32. # @ECLASS-VARIABLE: PHP_PEAR_PKG_NAME
  33. # @DESCRIPTION:
  34. # Set this if the the PEAR package name differs from ${PN/PEAR-/}
  35. # (generally shouldn't be the case).
  36. [[ -z "${PHP_PEAR_PKG_NAME}" ]] && PHP_PEAR_PKG_NAME="${PN/PEAR-/}"
  37. fix_PEAR_PV() {
  38. tmp="${PV}"
  39. tmp="${tmp/_/}"
  40. tmp="${tmp/rc/RC}"
  41. tmp="${tmp/beta/b}"
  42. tmp="${tmp/alpha/a}"
  43. PEAR_PV="${tmp}"
  44. }
  45. # @ECLASS-VARIABLE: PEAR_PV
  46. # @DESCRIPTION:
  47. # Set in ebuild if the eclass ${PV} mangling breaks SRC_URI for alpha/beta/rc versions
  48. [[ -z "${PEAR_PV}" ]] && fix_PEAR_PV
  49. PEAR_PN="${PHP_PEAR_PKG_NAME}-${PEAR_PV}"
  50. : ${PHP_PEAR_URI:=pear.php.net}
  51. : ${PHP_PEAR_CHANNEL:=${FILESDIR}/channel.xml}
  52. [[ -z "${SRC_URI}" ]] && SRC_URI="http://${PHP_PEAR_URI}/get/${PEAR_PN}.tgz"
  53. [[ -z "${HOMEPAGE}" ]] && HOMEPAGE="http://${PHP_PEAR_URI}/${PHP_PEAR_PKG_NAME}"
  54. S="${WORKDIR}/${PEAR_PN}"
  55. # @FUNCTION: php-pear-lib-r1_pkg_setup
  56. # @DESCRIPTION:
  57. # Adds required PEAR channel if necessary
  58. php-pear-r1_pkg_setup() {
  59. if [[ -f $PHP_PEAR_CHANNEL ]]; then
  60. pear channel-add $PHP_PEAR_CHANNEL || einfo "Ignore any errors about existing channels"
  61. fi
  62. }
  63. # @FUNCTION: php-pear-r1_src_install
  64. # @DESCRIPTION:
  65. # Takes care of standard install for PEAR packages.
  66. php-pear-r1_src_install() {
  67. # SNMP support
  68. addpredict /usr/share/snmp/mibs/.index
  69. addpredict /var/lib/net-snmp/
  70. addpredict /var/lib/net-snmp/mib_indexes
  71. addpredict /session_mm_cli0.sem
  72. PHP_BIN="/usr/bin/php"
  73. cd "${S}"
  74. # metadata_dir needs to be set relative to ${D} for >=dev-php/PEAR-PEAR-1.10
  75. if [[ -f "${WORKDIR}"/package2.xml ]] ; then
  76. mv -f "${WORKDIR}/package2.xml" "${S}"
  77. if has_version '>=dev-php/PEAR-PEAR-1.7.0' ; then
  78. local WWW_DIR="/usr/share/webapps/${PN}/${PVR}/htdocs"
  79. peardev -d php_bin="${PHP_BIN}" -d www_dir="${WWW_DIR}" -d metadata_dir="/usr/share/php" \
  80. install --force --loose --nodeps --offline --packagingroot="${D}" \
  81. "${S}/package2.xml" || die "Unable to install PEAR package"
  82. else
  83. peardev -d php_bin="${PHP_BIN}" install --force --loose --nodeps --offline --packagingroot="${D}" \
  84. "${S}/package2.xml" || die "Unable to install PEAR package"
  85. fi
  86. else
  87. mv -f "${WORKDIR}/package.xml" "${S}"
  88. if has_version '>=dev-php/PEAR-PEAR-1.7.0' ; then
  89. local WWW_DIR="/usr/share/webapps/${PN}/${PVR}/htdocs"
  90. peardev -d php_bin="${PHP_BIN}" -d www_dir="${WWW_DIR}" -d metadata_dir="/usr/share/php" \
  91. install --force --loose --nodeps --offline --packagingroot="${D}" \
  92. "${S}/package.xml" || die "Unable to install PEAR package"
  93. else
  94. peardev -d php_bin="${PHP_BIN}" install --force --loose --nodeps --offline --packagingroot="${D}" \
  95. "${S}/package.xml" || die "Unable to install PEAR package"
  96. fi
  97. fi
  98. rm -Rf "${D}/usr/share/php/.channels" \
  99. "${D}/usr/share/php/.depdblock" \
  100. "${D}/usr/share/php/.depdb" \
  101. "${D}/usr/share/php/.filemap" \
  102. "${D}/usr/share/php/.lock" \
  103. "${D}/usr/share/php/.registry"
  104. }