*/*: Discontinue Gentoo SuperH port
[gentoo.git] / dev-php / PEAR-PEAR / PEAR-PEAR-1.10.6.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 MY_PN="${PN/PEAR-/}"
7 MY_P="${MY_PN}-${PV}"
8
9 DESCRIPTION="PEAR Base System"
10 HOMEPAGE="https://pear.php.net/package/PEAR"
11 SRC_URI="https://pear.php.net/get/${MY_P}.tgz"
12 LICENSE="MIT"
13 KEYWORDS="~alpha amd64 arm ~hppa ia64 ppc ppc64 ~s390 sparc x86"
14 SLOT="0"
15 IUSE=""
16
17 DEPEND=""
18 RDEPEND="dev-lang/php:*[cli,xml,zlib]
19         >=dev-php/PEAR-Archive_Tar-1.4.0
20         >=dev-php/PEAR-Console_Getopt-1.4.1
21         dev-php/PEAR-Exception
22         >=dev-php/PEAR-Structures_Graph-1.1.0
23         >=dev-php/PEAR-XML_Util-1.3.0"
24
25 S="${WORKDIR}/${MY_P}"
26
27 PATCHES=( "${FILESDIR}/gentoo-libtool-mismatch-fix-v2.patch" )
28
29 pkg_setup() {
30         [[ -z "${PEAR_CACHEDIR}" ]] && PEAR_CACHEDIR="${EPREFIX}/var/cache/pear"
31         [[ -z "${PEAR_DOWNLOADDIR}" ]] && PEAR_DOWNLOADDIR="${EPREFIX}/var/tmp/pear"
32         [[ -z "${PEAR_TEMPDIR}" ]] && PEAR_TEMPDIR="${EPREFIX}/tmp"
33
34         elog
35         elog "cache_dir is set to: ${PEAR_CACHEDIR}"
36         elog "download_dir is set to: ${PEAR_DOWNLOADDIR}"
37         elog "temp_dir is set to: ${PEAR_TEMPDIR}"
38         elog
39         elog "If you want to change the above values, you need to set"
40         elog "PEAR_CACHEDIR, PEAR_DOWNLOADDIR and PEAR_TEMPDIR variable(s)"
41         elog "accordingly in /etc/portage/make.conf and re-emerge ${PN}."
42         elog
43 }
44
45 src_prepare() {
46         default
47         # Exception.php is part of dev-php/PEAR-Exception.
48         rm PEAR/Exception.php || die "failed to remove PEAR/Exception.php"
49 }
50
51 src_install() {
52         insinto /usr/share/php
53         doins -r PEAR/
54         doins -r OS/
55         doins PEAR.php System.php
56         doins scripts/pearcmd.php
57         doins scripts/peclcmd.php
58
59         newbin scripts/pear.sh pear
60         newbin scripts/peardev.sh peardev
61         newbin scripts/pecl.sh pecl
62
63         # adjust some scripts for current version
64         [[ -z "${PEAR}" ]] && PEAR="${PV}"
65         for i in pearcmd.php peclcmd.php ; do
66                 sed "s:@pear_version@:${PEAR}:g" -i "${D}/usr/share/php/${i}" \
67                         || die "failed to sed pear_version"
68         done
69
70         for i in pear peardev pecl ; do
71                 sed "s:@bin_dir@:${EPREFIX}/usr/bin:g" -i "${D}/usr/bin/${i}" \
72                         || die "failed to sed @bin_dir@ in ${i}"
73                 sed "s:@php_dir@:${EPREFIX}/usr/share/php:g" -i "${D}/usr/bin/${i}" \
74                         || die "failed to sed @php_dir@ in ${i}"
75         done
76
77         sed "s:-d output_buffering=1:-d output_buffering=1 -d memory_limit=32M:g" \
78                 -i "${D}/usr/bin/pear" \
79                 || die "failed to set PHP ini values in pear executable"
80
81         sed "s:@package_version@:${PEAR}:g" \
82                 -i "${D}/usr/share/php/PEAR/Command/Package.php" \
83                 || die "failed to sed @package_version@"
84
85         sed "s:@PEAR-VER@:${PEAR}:g" \
86                 -i "${D}/usr/share/php/PEAR/Dependency2.php" \
87                 || die "failed to sed @PEAR-VER@ in Dependency2.php"
88
89         sed "s:@PEAR-VER@:${PEAR}:g" \
90                 -i "${D}/usr/share/php/PEAR/PackageFile/Parser/v1.php" \
91                 || die "failed to sed @PEAR-VER@ in v1.php"
92
93         sed "s:@PEAR-VER@:${PEAR}:g" \
94                 -i "${D}/usr/share/php/PEAR/PackageFile/Parser/v2.php" \
95                 || die "failed to sed @PEAR-VER@ in v2.php"
96
97         # finalize install
98         insinto /etc
99         newins "${FILESDIR}"/pear.conf-r2 pear.conf
100
101         sed "s|s:PHPCLILEN:\"PHPCLI\"|s:${#PHPCLI}:\"${PHPCLI}\"|g" \
102                 -i "${D}/etc/pear.conf" \
103                 || die "failed to sed PHPCLILEN in pear.conf"
104
105         sed "s|s:CACHEDIRLEN:\"CACHEDIR\"|s:${#PEAR_CACHEDIR}:\"${PEAR_CACHEDIR}\"|g" \
106                 -i "${D}/etc/pear.conf" \
107                 || die "failed to sed CACHEDIRLEN in pear.conf"
108
109         sed "s|s:DOWNLOADDIRLEN:\"DOWNLOADDIR\"|s:${#PEAR_DOWNLOADDIR}:\"${PEAR_DOWNLOADDIR}\"|g" \
110                 -i "${D}/etc/pear.conf" \
111                 || die "failed to sed DOWNLOADDIRLEN in pear.conf"
112
113         sed "s|s:TEMPDIRLEN:\"TEMPDIR\"|s:${#PEAR_TEMPDIR}:\"${PEAR_TEMPDIR}\"|g" \
114                 -i "${D}/etc/pear.conf" \
115                 || die "failed to sed TEMPDIRLEN in pear.conf"
116
117         # Change the paths for eprefix!
118         sed "s|s:19:\"/usr/share/php/docs\"|s:$(( ${#EPREFIX}+19 )):\"${EPREFIX}/usr/share/php/docs\"|g" \
119                 -i "${D}/etc/pear.conf" \
120                 || die "failed to sed the docs path (prefix) in pear.conf"
121
122         sed "s|s:19:\"/usr/share/php/data\"|s:$(( ${#EPREFIX}+19 )):\"${EPREFIX}/usr/share/php/data\"|g" \
123                 -i "${D}/etc/pear.conf" \
124                 || die "failed to sed the data path (prefix) in pear.conf"
125
126         sed "s|s:20:\"/usr/share/php/tests\"|s:$(( ${#EPREFIX}+20 )):\"${EPREFIX}/usr/share/php/tests\"|g" \
127                 -i "${D}/etc/pear.conf" \
128                 || die "failed to sed the tests path (prefix) in pear.conf"
129
130         sed "s|s:14:\"/usr/share/php\"|s:$(( ${#EPREFIX}+14 )):\"${EPREFIX}/usr/share/php\"|g" \
131                 -i "${D}/etc/pear.conf" \
132                 || die "failed to sed the PHP include path (prefix) in pear.conf"
133
134         sed "s|s:8:\"/usr/bin\"|s:$(( ${#EPREFIX}+8 )):\"${EPREFIX}/usr/bin\"|g" \
135                 -i "${D}/etc/pear.conf" \
136                 || die "failed to sed the bin path (prefix) in pear.conf"
137
138         [[ "${PEAR_TEMPDIR}" != "/tmp" ]] && keepdir "${PEAR_TEMPDIR#${EPREFIX}}"
139         keepdir "${PEAR_CACHEDIR#${EPREFIX}}"
140         diropts -m1777
141         keepdir "${PEAR_DOWNLOADDIR#${EPREFIX}}"
142
143         insinto /usr/share/php/.packagexml
144         newins "${WORKDIR}/package.xml" "${MY_P}.xml"
145 }
146
147 pkg_config() {
148         # Update PEAR/PECL channels as needed, add new ones to the list if needed
149         elog "Updating PEAR/PECL channels"
150         local pearchans="pear.php.net pecl.php.net pear.symfony-project.com"
151
152         for chan in ${pearchans} ; do
153                 # The first command may fail if, for example, the channels have
154                 # already been initialized.
155                 pear channel-discover ${chan}
156                 pear channel-update ${chan} || die "failed to update channels: ${chan}"
157         done
158 }
159
160 pkg_postinst() {
161         pear clear-cache || die "failed to clear PEAR cache"
162
163         elog "Run 'emerge --config =${PF}' to automatically update the PEAR/PECL channels while online."
164
165         # Register the package from the package.xml file
166         # It is not critical to complete so only warn on failure
167         if [[ -f "${EROOT}usr/share/php/.packagexml/${MY_P}.xml" ]] ; then
168                 "${EROOT}usr/bin/peardev" install -nrO --force \
169                         "${EROOT}usr/share/php/.packagexml/${MY_P}.xml" 2> /dev/null \
170                         || ewarn "Failed to insert package into local PEAR database"
171         fi
172 }
173
174 pkg_prerm() {
175         # Uninstall known dependency
176         "${EROOT}usr/bin/peardev" uninstall -nrO "pear.php.net/PEAR"
177 }