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