dev-qt/qtpositioning: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / eclass / php-pear-r2.eclass
1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: php-pear-r2.eclass
5 # @MAINTAINER:
6 # Gentoo PHP Team <php-bugs@gentoo.org>
7 # @AUTHOR:
8 # Author: Brian Evans <grknight@gentoo.org>
9 # @SUPPORTED_EAPIS: 6 7
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 https://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 EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
18
19 case "${EAPI:-0}" in
20         6|7)
21                 ;;
22         *)
23                 die "Unsupported EAPI=${EAPI} for ${ECLASS}"
24                 ;;
25 esac
26
27 RDEPEND=">=dev-php/pear-1.8.1"
28
29 # @ECLASS-VARIABLE: PHP_PEAR_PKG_NAME
30 # @DESCRIPTION:
31 # Set this if the PEAR package name differs from ${PN/PEAR-/}
32 # (generally shouldn't be the case).
33 : ${PHP_PEAR_PKG_NAME:=${PN/PEAR-/}}
34
35 # @ECLASS-VARIABLE: PEAR_PV
36 # @DESCRIPTION:
37 # Set in ebuild if the ${PV} breaks SRC_URI for alpha/beta/rc versions
38 : ${PEAR_PV:=${PV}}
39
40 # @ECLASS-VARIABLE: PEAR-P
41 # @INTERNAL
42 # @DESCRIPTION: Combines PHP_PEAR_PKG_NAME and PEAR_PV
43 PEAR_P="${PHP_PEAR_PKG_NAME}-${PEAR_PV}"
44
45 # @ECLASS-VARIABLE: PHP_PEAR_DOMAIN
46 # @DESCRIPTION:
47 # Set in ebuild to the domain name of the channel if not pear.php.net
48 # When the domain is not pear.php.net, setting the SRC_URI is required
49 : ${PHP_PEAR_DOMAIN:=pear.php.net}
50
51 # @ECLASS-VARIABLE: PHP_PEAR_CHANNEL
52 # @DEFAULT_UNSET
53 # @DESCRIPTION:
54 # Set in ebuild to the path of channel.xml file which is necessary for
55 # 3rd party pear channels (besides pear.php.net) to be added to PEAR
56 # Default is unset to do nothing
57
58 # set default SRC_URI for pear.php.net packages
59 if [[ "${PHP_PEAR_DOMAIN}" == "pear.php.net" ]] ; then
60         SRC_URI="https://pear.php.net/get/${PEAR_P}.tgz"
61 fi
62
63 : ${HOMEPAGE:=https://${PHP_PEAR_DOMAIN}/package/${PHP_PEAR_PKG_NAME}}
64
65 S="${WORKDIR}/${PEAR_P}"
66
67 # @FUNCTION: php-pear-r2_install_packagexml
68 # @DESCRIPTION:
69 # Copies the package2.xml or package.xml file and, optionally, the channel.xml
70 # file to a Gentoo-specific location so that pkg_postinst can install the package
71 # to the local PEAR database
72 php-pear-r2_install_packagexml() {
73         insinto /usr/share/php/.packagexml
74         if [[ -f "${WORKDIR}/package2.xml" ]] ; then
75                 newins "${WORKDIR}/package2.xml" "${PEAR_P}.xml"
76         elif [[ -f "${WORKDIR}/package.xml" ]] ; then
77                 newins "${WORKDIR}/package.xml" "${PEAR_P}.xml"
78         fi
79
80         if [[ -f "${PHP_PEAR_CHANNEL}" ]] ; then
81                 newins "${PHP_PEAR_CHANNEL}" "${PEAR_P}-channel.xml"
82         fi
83 }
84
85 # @FUNCTION: php-pear-r2_src_install
86 # @DESCRIPTION:
87 # Takes care of standard install for PEAR packages.
88 # Override src_install if the package installs more than "${PHP_PEAR_PKG_NAME}.php"
89 # or "${PHP_PEAR_PKG_NAME%%_*}/" as a directory
90 php-pear-r2_src_install() {
91         insinto /usr/share/php
92         [[ -f "${PHP_PEAR_PKG_NAME}.php" ]] && doins "${PHP_PEAR_PKG_NAME}.php"
93         [[ -d "${PHP_PEAR_PKG_NAME%%_*}" ]] && doins -r "${PHP_PEAR_PKG_NAME%%_*}/"
94         php-pear-r2_install_packagexml
95         einstalldocs
96 }
97
98 # @FUNCTION: php-pear-r2_pkg_postinst
99 # @DESCRIPTION:
100 # Register package with the local PEAR database.
101 php-pear-r2_pkg_postinst() {
102         # Add unknown channels
103         if [[ -f "${EROOT%/}/usr/share/php/.packagexml/${PEAR_P}-channel.xml" ]] ; then
104                 "${EROOT%/}/usr/bin/peardev" channel-info "${PHP_PEAR_DOMAIN}" &> /dev/null
105                 if [[ $? -ne 0 ]]; then
106                         "${EROOT%/}/usr/bin/peardev" channel-add \
107                                 "${EROOT%/}/usr/share/php/.packagexml/${PEAR_P}-channel.xml" \
108                                 || einfo "Ignore any errors about existing channels"
109                 fi
110         fi
111
112         # Register the package from the package{,2}.xml file
113         # It is not critical to complete so only warn on failure
114         if [[ -f "${EROOT%/}/usr/share/php/.packagexml/${PEAR_P}.xml" ]] ; then
115                 "${EROOT%/}/usr/bin/peardev" install -nrO --force \
116                         "${EROOT%/}/usr/share/php/.packagexml/${PEAR_P}.xml" 2> /dev/null \
117                         || ewarn "Failed to insert package into local PEAR database"
118         fi
119 }
120
121 # @FUNCTION: php-pear-r2_pkg_postrm
122 # @DESCRIPTION:
123 # Deregister package from the local PEAR database
124 php-pear-r2_pkg_postrm() {
125         # Uninstall known dependency
126         "${EROOT%/}/usr/bin/peardev" uninstall -nrO "${PHP_PEAR_DOMAIN}/${PHP_PEAR_PKG_NAME}"
127 }