1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
9 DESCRIPTION="PEAR Base System"
10 HOMEPAGE="https://pear.php.net/package/PEAR"
11 SRC_URI="https://pear.php.net/get/${MY_P}.tgz"
13 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
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"
25 S="${WORKDIR}/${MY_P}"
27 PATCHES=( "${FILESDIR}/gentoo-libtool-mismatch-fix-v2.patch" )
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"
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}"
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}."
47 # Exception.php is part of dev-php/PEAR-Exception.
48 rm PEAR/Exception.php || die "failed to remove PEAR/Exception.php"
52 insinto /usr/share/php
55 doins PEAR.php System.php
56 doins scripts/pearcmd.php
57 doins scripts/peclcmd.php
59 newbin scripts/pear.sh pear
60 newbin scripts/peardev.sh peardev
61 newbin scripts/pecl.sh pecl
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"
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}"
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"
81 sed "s:@package_version@:${PEAR}:g" \
82 -i "${D}/usr/share/php/PEAR/Command/Package.php" \
83 || die "failed to sed @package_version@"
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"
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"
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"
99 newins "${FILESDIR}"/pear.conf-r2 pear.conf
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"
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"
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"
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"
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"
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"
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"
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"
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"
138 [[ "${PEAR_TEMPDIR}" != "/tmp" ]] && keepdir "${PEAR_TEMPDIR#${EPREFIX}}"
139 keepdir "${PEAR_CACHEDIR#${EPREFIX}}"
141 keepdir "${PEAR_DOWNLOADDIR#${EPREFIX}}"
143 insinto /usr/share/php/.packagexml
144 newins "${WORKDIR}/package.xml" "${MY_P}.xml"
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"
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}"
161 pear clear-cache || die "failed to clear PEAR cache"
163 elog "Run 'emerge --config =${PF}' to automatically update the PEAR/PECL channels while online."
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"
175 # Uninstall known dependency
176 "${EROOT}/usr/bin/peardev" uninstall -nrO "pear.php.net/PEAR"