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