add dev-lang/php-5.6.40
[portage-squeep] / dev-lang / php / php-5.6.40.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="7"
5
6 inherit autotools flag-o-matic systemd
7
8 DESCRIPTION="The PHP language runtime engine"
9 HOMEPAGE="https://secure.php.net/"
10 SRC_URI="https://php.net/distributions/${P}.tar.xz
11 https://salsa.debian.org/php-team/php/raw/8149a436/debian/patches/0055-Use-OpenSSL-1.1-compatibility-patch-when-built-with-.patch?inline=false -> php-5.6-openssl-1.1-compatibility.patch"
12
13 LICENSE="PHP-3.01
14 BSD
15 Zend-2.0
16 bcmath? ( LGPL-2.1+ )
17 fpm? ( BSD-2 )
18 gd? ( gd )
19 unicode? ( BSD-2 LGPL-2.1 )"
20
21 SLOT="$(ver_cut 1-2)"
22 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
23
24 # We can build the following SAPIs in the given order
25 SAPIS="embed cli cgi fpm apache2"
26
27 # SAPIs and SAPI-specific USE flags (cli SAPI is default on):
28 IUSE="${IUSE}
29 ${SAPIS/cli/+cli}
30 threads"
31
32 IUSE="${IUSE} acl bcmath berkdb bzip2 calendar cdb cjk
33 coverage crypt +ctype curl debug
34 enchant exif +fileinfo +filter firebird
35 flatfile ftp gd gdbm gmp +hash +iconv imap inifile
36 intl iodbc ipv6 +json kerberos ldap ldap-sasl libedit libressl
37 mhash mssql mysql libmysqlclient mysqli nls
38 oci8-instant-client odbc +opcache pcntl pdo +phar +posix postgres qdbm
39 readline recode selinux +session sharedmem
40 +simplexml snmp soap sockets spell sqlite ssl
41 sybase-ct sysvipc systemd tidy +tokenizer truetype unicode vpx wddx
42 +xml xmlreader xmlwriter xmlrpc xpm xslt zip zlib"
43
44 # The supported (that is, autodetected) versions of BDB are listed in
45 # the ./configure script. Other versions *work*, but we need to stick to
46 # the ones that can be detected to avoid a repeat of bug #564824.
47 COMMON_DEPEND="
48 >=app-eselect/eselect-php-0.9.1[apache2?,fpm?]
49 >=dev-libs/libpcre-8.32[unicode]
50 fpm? ( acl? ( sys-apps/acl ) )
51 apache2? ( || ( >=www-servers/apache-2.4[apache2_modules_unixd,threads=]
52 <www-servers/apache-2.4[threads=] ) )
53 berkdb? ( || ( sys-libs/db:5.3
54 sys-libs/db:5.1
55 sys-libs/db:4.8
56 sys-libs/db:4.7
57 sys-libs/db:4.6
58 sys-libs/db:4.5 ) )
59 bzip2? ( app-arch/bzip2:0= )
60 cdb? ( || ( dev-db/cdb dev-db/tinycdb ) )
61 cjk? ( !gd? (
62 virtual/jpeg:0
63 media-libs/libpng:0=
64 sys-libs/zlib:0=
65 ) )
66 coverage? ( dev-util/lcov )
67 crypt? ( >=dev-libs/libmcrypt-2.4 )
68 curl? ( >=net-misc/curl-7.10.5 )
69 enchant? ( app-text/enchant )
70 exif? ( !gd? (
71 virtual/jpeg:0
72 media-libs/libpng:0=
73 sys-libs/zlib:0=
74 ) )
75 firebird? ( dev-db/firebird )
76 gd? ( virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib:0= )
77 gdbm? ( >=sys-libs/gdbm-1.8.0:0= )
78 gmp? ( dev-libs/gmp:0= )
79 iconv? ( virtual/libiconv )
80 imap? ( virtual/imap-c-client[kerberos=,ssl=] )
81 intl? ( dev-libs/icu:= )
82 iodbc? ( dev-db/libiodbc )
83 kerberos? ( virtual/krb5 )
84 ldap? ( >=net-nds/openldap-1.2.11 )
85 ldap-sasl? ( dev-libs/cyrus-sasl >=net-nds/openldap-1.2.11 )
86 libedit? ( || ( sys-freebsd/freebsd-lib dev-libs/libedit ) )
87 mssql? ( dev-db/freetds[mssql] )
88 libmysqlclient? (
89 mysql? ( virtual/libmysqlclient:= )
90 mysqli? ( virtual/libmysqlclient:= )
91 )
92 nls? ( sys-devel/gettext )
93 oci8-instant-client? ( dev-db/oracle-instantclient-basic )
94 odbc? ( >=dev-db/unixODBC-1.8.13 )
95 postgres? ( dev-db/postgresql:* )
96 qdbm? ( dev-db/qdbm )
97 readline? ( sys-libs/readline:0= )
98 recode? ( app-text/recode )
99 sharedmem? ( dev-libs/mm )
100 simplexml? ( >=dev-libs/libxml2-2.6.8 )
101 snmp? ( >=net-analyzer/net-snmp-5.2 )
102 soap? ( >=dev-libs/libxml2-2.6.8 )
103 spell? ( >=app-text/aspell-0.50 )
104 sqlite? ( >=dev-db/sqlite-3.7.6.3 )
105 ssl? (
106 !libressl? ( dev-libs/openssl:0= )
107 libressl? ( dev-libs/libressl:0= )
108 )
109 sybase-ct? ( dev-db/freetds )
110 tidy? ( app-text/htmltidy )
111 truetype? (
112 =media-libs/freetype-2*
113 >=media-libs/t1lib-5.0.0
114 !gd? (
115 virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib:0= )
116 )
117 unicode? ( dev-libs/oniguruma:= )
118 vpx? ( media-libs/libvpx:0= )
119 wddx? ( >=dev-libs/libxml2-2.6.8 )
120 xml? ( >=dev-libs/libxml2-2.6.8 )
121 xmlrpc? ( >=dev-libs/libxml2-2.6.8 virtual/libiconv )
122 xmlreader? ( >=dev-libs/libxml2-2.6.8 )
123 xmlwriter? ( >=dev-libs/libxml2-2.6.8 )
124 xpm? (
125 x11-libs/libXpm
126 virtual/jpeg:0
127 media-libs/libpng:0= sys-libs/zlib:0=
128 )
129 xslt? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 )
130 zip? ( sys-libs/zlib:0= )
131 zlib? ( sys-libs/zlib:0= )
132 "
133
134 RDEPEND="${COMMON_DEPEND}
135 virtual/mta
136 fpm? (
137 selinux? ( sec-policy/selinux-phpfpm )
138 systemd? ( sys-apps/systemd ) )"
139
140 DEPEND="${COMMON_DEPEND}
141 app-arch/xz-utils
142 >=sys-devel/bison-3.0.1
143 sys-devel/flex
144 >=sys-devel/m4-1.4.3
145 >=sys-devel/libtool-1.5.18"
146
147 # Without USE=readline or libedit, the interactive "php -a" CLI will hang.
148 REQUIRED_USE="
149 || ( cli cgi fpm apache2 embed )
150 cli? ( ^^ ( readline libedit ) )
151 truetype? ( gd zlib )
152 vpx? ( gd zlib )
153 cjk? ( gd zlib )
154 exif? ( gd zlib )
155 xpm? ( gd zlib )
156 gd? ( zlib )
157 simplexml? ( xml )
158 soap? ( xml )
159 wddx? ( xml )
160 xmlrpc? ( || ( xml iconv ) )
161 xmlreader? ( xml )
162 xslt? ( xml )
163 ldap-sasl? ( ldap )
164 mhash? ( hash )
165 phar? ( hash )
166 recode? ( !imap !mysql !mysqli !libmysqlclient )
167 libmysqlclient? ( || (
168 mysql
169 mysqli
170 pdo
171 ) )
172
173 qdbm? ( !gdbm )
174 readline? ( !libedit )
175 sharedmem? ( !threads )
176 "
177
178 PHP_MV="$(ver_cut 1)"
179
180 php_install_ini() {
181 local phpsapi="${1}"
182
183 # work out where we are installing the ini file
184 php_set_ini_dir "${phpsapi}"
185
186 # Always install the production INI file, bug 611214.
187 local phpinisrc="php.ini-production-${phpsapi}"
188 cp php.ini-production "${phpinisrc}" || die
189
190 # default to /tmp for save_path, bug #282768
191 sed -e 's|^;session.save_path .*$|session.save_path = "'"${EPREFIX}"'/tmp"|g' -i "${phpinisrc}" || die
192
193 # Set the extension dir
194 sed -e "s|^extension_dir .*$|extension_dir = ${extension_dir}|g" \
195 -i "${phpinisrc}" || die
196
197 # Set the include path to point to where we want to find PEAR packages
198 sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:'"${EPREFIX}"'/usr/share/php'${PHP_MV}':'"${EPREFIX}"'/usr/share/php"|' -i "${phpinisrc}" || die
199
200 dodir "${PHP_INI_DIR#${EPREFIX}}"
201 insinto "${PHP_INI_DIR#${EPREFIX}}"
202 newins "${phpinisrc}" php.ini
203
204 elog "Installing php.ini for ${phpsapi} into ${PHP_INI_DIR#${EPREFIX}}"
205 elog
206
207 dodir "${PHP_EXT_INI_DIR#${EPREFIX}}"
208 dodir "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}"
209
210 if use opcache; then
211 elog "Adding opcache to $PHP_EXT_INI_DIR"
212 echo "zend_extension=${PHP_DESTDIR}/$(get_libdir)/opcache.so" >> \
213 "${D}/${PHP_EXT_INI_DIR}"/opcache.ini
214 dosym "${PHP_EXT_INI_DIR#${EPREFIX}}/opcache.ini" \
215 "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}/opcache.ini"
216 fi
217
218 # SAPI-specific handling
219 if [[ "${sapi}" == "fpm" ]] ; then
220 einfo "Installing FPM config file php-fpm.conf"
221 insinto "${PHP_INI_DIR#${EPREFIX}}"
222 doins sapi/fpm/php-fpm.conf
223 fi
224
225 dodoc php.ini-{development,production}
226 }
227
228 php_set_ini_dir() {
229 PHP_INI_DIR="${EPREFIX}/etc/php/${1}-php${SLOT}"
230 PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
231 PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
232 }
233
234 src_prepare() {
235 eapply "${FILESDIR}/php-${SLOT}-no-bison-warnings.patch"
236 eapply "${FILESDIR}/5.6-mbstring-oniguruma-6.8.patch"
237 eapply "${DISTDIR}/php-5.6-openssl-1.1-compatibility.patch"
238 eapply "${FILESDIR}/php-5.6-intl-detect-icu-via-pkg-config.patch"
239 eapply "${FILESDIR}/php-5.6-intl-use-icu-namespace.patch"
240 eapply "${FILESDIR}/php-5.6-intl-icu-memory-corruption.patch"
241 eapply "${FILESDIR}/php-freetype-2.9.1.patch"
242
243 # Change PHP branding
244 # Get the alpha/beta/rc version
245 sed -re "s|^(PHP_EXTRA_VERSION=\").*(\")|\1-pl${PR/r/}-gentoo\2|g" \
246 -i configure.in || die "Unable to change PHP branding"
247
248 # Patch PHP to show Gentoo as the server platform
249 sed -e 's/PHP_UNAME=`uname -a | xargs`/PHP_UNAME=`uname -s -n -r -v | xargs`/g' \
250 -i configure.in || die "Failed to fix server platform name"
251
252 # Prevent PHP from activating the Apache config,
253 # as we will do that ourselves
254 sed -i \
255 -e "s,-i -a -n php${PHP_MV},-i -n php${PHP_MV},g" \
256 -e "s,-i -A -n php${PHP_MV},-i -n php${PHP_MV},g" \
257 configure sapi/apache2filter/config.m4 sapi/apache2handler/config.m4 \
258 || die
259
260 # Patch PHP to support heimdal instead of mit-krb5
261 if has_version "app-crypt/heimdal" ; then
262 sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 \
263 || die "Failed to fix heimdal libname"
264 sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 \
265 || die "Failed to fix heimdal crypt library reference"
266 fi
267
268 eapply_user
269
270 # Force rebuilding aclocal.m4
271 rm -f aclocal.m4 || die "failed to remove aclocal.m4 in src_prepare"
272
273 mv configure.in configure.ac || die
274
275 eautoreconf
276
277 if [[ ${CHOST} == *-darwin* ]] ; then
278 # http://bugs.php.net/bug.php?id=48795, bug #343481
279 sed -i -e '/BUILD_CGI="\\$(CC)/s/CC/CXX/' configure || die
280 fi
281 }
282
283 src_configure() {
284 addpredict /usr/share/snmp/mibs/.index #nowarn
285 addpredict /var/lib/net-snmp/mib_indexes #nowarn
286
287 PHP_DESTDIR="${EPREFIX}/usr/$(get_libdir)/php${SLOT}"
288
289 # The php-fpm config file wants localstatedir to be ${EPREFIX}/var
290 # and not the Gentoo default ${EPREFIX}/var/lib. See bug 572002.
291 local our_conf=(
292 --prefix="${PHP_DESTDIR}"
293 --mandir="${PHP_DESTDIR}/man"
294 --infodir="${PHP_DESTDIR}/info"
295 --libdir="${PHP_DESTDIR}/lib"
296 --with-libdir="$(get_libdir)"
297 --localstatedir="${EPREFIX}/var"
298 --without-pear
299 $(use_enable threads maintainer-zts)
300 )
301
302 our_conf+=(
303 $(use_enable bcmath bcmath)
304 $(use_with bzip2 bz2 "${EPREFIX}/usr")
305 $(use_enable calendar calendar)
306 $(use_enable coverage gcov)
307 $(use_enable ctype ctype)
308 $(use_with curl curl "${EPREFIX}/usr")
309 $(use_enable xml dom)
310 $(use_with enchant enchant "${EPREFIX}/usr")
311 $(use_enable exif exif)
312 $(use_enable fileinfo fileinfo)
313 $(use_enable filter filter)
314 $(use_enable ftp ftp)
315 $(use_with nls gettext "${EPREFIX}/usr")
316 $(use_with gmp gmp "${EPREFIX}/usr")
317 $(use_enable hash hash)
318 $(use_with mhash mhash "${EPREFIX}/usr")
319 $(use_with iconv iconv \
320 $(use elibc_glibc || use elibc_musl || use elibc_FreeBSD || echo "${EPREFIX}/usr"))
321 $(use_enable intl intl)
322 $(use_enable ipv6 ipv6)
323 $(use_enable json json)
324 $(use_with kerberos kerberos "${EPREFIX}/usr")
325 $(use_enable xml libxml)
326 $(use_with xml libxml-dir "${EPREFIX}/usr")
327 $(use_enable unicode mbstring)
328 $(use_with crypt mcrypt "${EPREFIX}/usr")
329 $(use_with mssql mssql "${EPREFIX}/usr")
330 $(use_with unicode onig "${EPREFIX}/usr")
331 $(use_with ssl openssl "${EPREFIX}/usr")
332 $(use_with ssl openssl-dir "${EPREFIX}/usr")
333 $(use_enable pcntl pcntl)
334 $(use_enable phar phar)
335 $(use_enable pdo pdo)
336 $(use_enable opcache opcache)
337 $(use_with postgres pgsql "${EPREFIX}/usr")
338 $(use_enable posix posix)
339 $(use_with spell pspell "${EPREFIX}/usr")
340 $(use_with recode recode "${EPREFIX}/usr")
341 $(use_enable simplexml simplexml)
342 $(use_enable sharedmem shmop)
343 $(use_with snmp snmp "${EPREFIX}/usr")
344 $(use_enable soap soap)
345 $(use_enable sockets sockets)
346 $(use_with sqlite sqlite3 "${EPREFIX}/usr")
347 $(use_with sybase-ct sybase-ct "${EPREFIX}/usr")
348 $(use_enable sysvipc sysvmsg)
349 $(use_enable sysvipc sysvsem)
350 $(use_enable sysvipc sysvshm)
351 $(use_with tidy tidy "${EPREFIX}/usr")
352 $(use_enable tokenizer tokenizer)
353 $(use_enable wddx wddx)
354 $(use_enable xml xml)
355 $(use_enable xmlreader xmlreader)
356 $(use_enable xmlwriter xmlwriter)
357 $(use_with xmlrpc xmlrpc)
358 $(use_with xslt xsl "${EPREFIX}/usr")
359 $(use_enable zip zip)
360 $(use_with zlib zlib "${EPREFIX}/usr")
361 $(use_enable debug debug)
362 )
363
364 # DBA support
365 if use cdb || use berkdb || use flatfile || use gdbm || use inifile \
366 || use qdbm ; then
367 our_conf+=( "--enable-dba${shared}" )
368 fi
369
370 # DBA drivers support
371 our_conf+=(
372 $(use_with cdb cdb)
373 $(use_with berkdb db4 "${EPREFIX}/usr")
374 $(use_enable flatfile flatfile)
375 $(use_with gdbm gdbm "${EPREFIX}/usr")
376 $(use_enable inifile inifile)
377 $(use_with qdbm qdbm "${EPREFIX}/usr")
378 )
379
380 # Support for the GD graphics library
381 our_conf+=(
382 $(use_with truetype freetype-dir "${EPREFIX}/usr")
383 $(use_with truetype t1lib "${EPREFIX}/usr")
384 $(use_enable cjk gd-jis-conv)
385 $(use_with gd jpeg-dir "${EPREFIX}/usr")
386 $(use_with gd png-dir "${EPREFIX}/usr")
387 $(use_with xpm xpm-dir "${EPREFIX}/usr")
388 $(use_with vpx vpx-dir "${EPREFIX}/usr")
389 )
390 # enable gd last, so configure can pick up the previous settings
391 our_conf+=( $(use_with gd gd) )
392
393 # IMAP support
394 if use imap ; then
395 our_conf+=(
396 $(use_with imap imap "${EPREFIX}/usr")
397 $(use_with ssl imap-ssl "${EPREFIX}/usr")
398 )
399 fi
400
401 # Interbase/firebird support
402 our_conf+=( $(use_with firebird interbase "${EPREFIX}/usr") )
403
404 # LDAP support
405 if use ldap ; then
406 our_conf+=(
407 $(use_with ldap ldap "${EPREFIX}/usr")
408 $(use_with ldap-sasl ldap-sasl "${EPREFIX}/usr")
409 )
410 fi
411
412 # MySQL support
413 local mysqllib="mysqlnd"
414 local mysqlilib="mysqlnd"
415 use libmysqlclient && mysqllib="${EPREFIX}/usr"
416 use libmysqlclient && mysqlilib="${EPREFIX}/usr/bin/mysql_config"
417
418 our_conf+=( $(use_with mysql mysql "${mysqllib}") )
419 our_conf+=( $(use_with mysqli mysqli "${mysqlilib}") )
420
421 local mysqlsock="${EPREFIX}/var/run/mysqld/mysqld.sock"
422 if use mysql || use mysqli ; then
423 our_conf+=( $(use_with mysql mysql-sock "${mysqlsock}") )
424 fi
425
426 # ODBC support
427 our_conf+=(
428 $(use_with odbc unixODBC "${EPREFIX}/usr")
429 $(use_with iodbc iodbc "${EPREFIX}/usr")
430 )
431
432 # Oracle support
433 our_conf+=( $(use_with oci8-instant-client oci8) )
434
435 # PDO support
436 if use pdo ; then
437 our_conf+=(
438 $(use_with mssql pdo-dblib)
439 $(use_with mysql pdo-mysql "${mysqllib}")
440 $(use_with postgres pdo-pgsql)
441 $(use_with sqlite pdo-sqlite "${EPREFIX}/usr")
442 $(use_with firebird pdo-firebird "${EPREFIX}/usr")
443 $(use_with odbc pdo-odbc "unixODBC,${EPREFIX}/usr")
444 $(use_with oci8-instant-client pdo-oci)
445 )
446 fi
447
448 # readline/libedit support
449 our_conf+=(
450 $(use_with readline readline "${EPREFIX}/usr")
451 $(use_with libedit libedit "${EPREFIX}/usr")
452 )
453
454 # Session support
455 if use session ; then
456 our_conf+=( $(use_with sharedmem mm "${EPREFIX}/usr") )
457 else
458 our_conf+=( $(use_enable session session) )
459 fi
460
461 # Use pic for shared modules such as apache2's mod_php
462 our_conf+=( --with-pic )
463
464 # we use the system copy of pcre
465 # --with-pcre-regex affects ext/pcre
466 # --with-pcre-dir affects ext/filter and ext/zip
467 our_conf+=(
468 --with-pcre-regex="${EPREFIX}/usr"
469 --with-pcre-dir="${EPREFIX}/usr"
470 )
471
472 # Catch CFLAGS problems
473 # Fixes bug #14067.
474 # Changed order to run it in reverse for bug #32022 and #12021.
475 replace-cpu-flags "k6*" "i586"
476
477 # Cache the ./configure test results between SAPIs.
478 our_conf+=( --cache-file="${T}/config.cache" )
479
480 # Support user-passed configuration parameters
481 our_conf+=( ${EXTRA_ECONF:-} )
482
483 # Support the Apache2 extras, they must be set globally for all
484 # SAPIs to work correctly, especially for external PHP extensions
485
486 mkdir -p "${WORKDIR}/sapis-build" || die
487 for one_sapi in $SAPIS ; do
488 use "${one_sapi}" || continue
489 php_set_ini_dir "${one_sapi}"
490
491 # The BUILD_DIR variable is used to determine where to output
492 # the files that autotools creates. This was all originally
493 # based on the autotools-utils eclass.
494 BUILD_DIR="${WORKDIR}/sapis-build/${one_sapi}"
495 cp -a "${S}" "${BUILD_DIR}" || die
496 cd "${BUILD_DIR}" || die
497
498 local sapi_conf=(
499 --with-config-file-path="${PHP_INI_DIR}"
500 --with-config-file-scan-dir="${PHP_EXT_INI_DIR_ACTIVE}"
501 )
502
503 for sapi in $SAPIS ; do
504 case "$sapi" in
505 cli|cgi|embed|fpm)
506 if [[ "${one_sapi}" == "${sapi}" ]] ; then
507 sapi_conf+=( "--enable-${sapi}" )
508 if [[ "fpm" == "${sapi}" ]] ; then
509 sapi_conf+=(
510 $(use_with acl fpm-acl)
511 $(use_with systemd fpm-systemd)
512 )
513 fi
514 else
515 sapi_conf+=( "--disable-${sapi}" )
516 fi
517 ;;
518
519 apache2)
520 if [[ "${one_sapi}" == "${sapi}" ]] ; then
521 sapi_conf+=( --with-apxs2="${EPREFIX}/usr/bin/apxs" )
522 else
523 sapi_conf+=( --without-apxs2 )
524 fi
525 ;;
526 esac
527 done
528
529 # Construct the $myeconfargs array by concatenating $our_conf
530 # (the common args) and $sapi_conf (the SAPI-specific args).
531 local myeconfargs=( "${our_conf[@]}" )
532 myeconfargs+=( "${sapi_conf[@]}" )
533
534 pushd "${BUILD_DIR}" > /dev/null || die
535 econf "${myeconfargs[@]}"
536 popd > /dev/null || die
537 done
538 }
539
540 src_compile() {
541 # snmp seems to run during src_compile, too (bug #324739)
542 addpredict /usr/share/snmp/mibs/.index #nowarn
543 addpredict /var/lib/net-snmp/mib_indexes #nowarn
544
545 for sapi in ${SAPIS} ; do
546 if use "${sapi}"; then
547 cd "${WORKDIR}/sapis-build/$sapi" || \
548 die "Failed to change dir to ${WORKDIR}/sapis-build/$1"
549 emake
550 fi
551 done
552 }
553
554 src_install() {
555 # see bug #324739 for what happens when we don't have that
556 addpredict /usr/share/snmp/mibs/.index #nowarn
557
558 # grab the first SAPI that got built and install common files from there
559 local first_sapi=""
560 for sapi in $SAPIS ; do
561 if use $sapi ; then
562 first_sapi=$sapi
563 break
564 fi
565 done
566
567 # Makefile forgets to create this before trying to write to it...
568 dodir "${PHP_DESTDIR#${EPREFIX}}/bin"
569
570 # Install php environment (without any sapis)
571 cd "${WORKDIR}/sapis-build/$first_sapi" || die
572 emake INSTALL_ROOT="${D}" \
573 install-build install-headers install-programs
574
575 local extension_dir="$("${ED}/${PHP_DESTDIR#${EPREFIX}}/bin/php-config" --extension-dir)"
576
577 # Create the directory where we'll put version-specific php scripts
578 keepdir "/usr/share/php${PHP_MV}"
579
580 local sapi="", file=""
581 local sapi_list=""
582
583 for sapi in ${SAPIS}; do
584 if use "${sapi}" ; then
585 einfo "Installing SAPI: ${sapi}"
586 cd "${WORKDIR}/sapis-build/${sapi}" || die
587
588 if [[ "${sapi}" == "apache2" ]] ; then
589 # We're specifically not using emake install-sapi as libtool
590 # may cause unnecessary relink failures (see bug #351266)
591 insinto "${PHP_DESTDIR#${EPREFIX}}/apache2/"
592 newins ".libs/libphp5$(get_libname)" \
593 "libphp${PHP_MV}$(get_libname)"
594 keepdir "/usr/$(get_libdir)/apache2/modules"
595 else
596 # needed each time, php_install_ini would reset it
597 local dest="${PHP_DESTDIR#${EPREFIX}}"
598 into "${dest}"
599 case "$sapi" in
600 cli)
601 source="sapi/cli/php"
602 ;;
603 cgi)
604 source="sapi/cgi/php-cgi"
605 ;;
606 fpm)
607 source="sapi/fpm/php-fpm"
608 ;;
609 embed)
610 source="libs/libphp${PHP_MV}$(get_libname)"
611 ;;
612 *)
613 die "unhandled sapi in src_install"
614 ;;
615 esac
616
617 if [[ "${source}" == *"$(get_libname)" ]]; then
618 dolib.so "${source}"
619 else
620 dobin "${source}"
621 local name="$(basename ${source})"
622 dosym "${dest}/bin/${name}" "/usr/bin/${name}${SLOT}"
623 fi
624 fi
625
626 php_install_ini "${sapi}"
627
628 # construct correct SAPI string for php-config
629 # thanks to ferringb for the bash voodoo
630 if [[ "${sapi}" == "apache2" ]]; then
631 sapi_list="${sapi_list:+${sapi_list} }apache2handler"
632 else
633 sapi_list="${sapi_list:+${sapi_list} }${sapi}"
634 fi
635 fi
636 done
637
638 # Installing opcache module
639 if use opcache ; then
640 into "${PHP_DESTDIR#${EPREFIX}}"
641 dolib.so "modules/opcache$(get_libname)"
642 fi
643
644 # Install env.d files
645 newenvd "${FILESDIR}/20php5-envd" "20php${SLOT}"
646 sed -e "s|/lib/|/$(get_libdir)/|g" -i "${ED}/etc/env.d/20php${SLOT}" || die
647 sed -e "s|php5|php${SLOT}|g" -i "${ED}/etc/env.d/20php${SLOT}" || die
648
649 # set php-config variable correctly (bug #278439)
650 sed -e "s:^\(php_sapis=\)\".*\"$:\1\"${sapi_list}\":" -i \
651 "${ED}/usr/$(get_libdir)/php${SLOT}/bin/php-config" || die
652
653 if use fpm ; then
654 if use systemd; then
655 systemd_newunit "${FILESDIR}/php-fpm_at.service" \
656 "php-fpm@${SLOT}.service"
657 else
658 systemd_newunit "${FILESDIR}/php-fpm_at-simple.service" \
659 "php-fpm@${SLOT}.service"
660 fi
661 fi
662 }
663
664 src_test() {
665 echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
666 PHP_BIN="${WORKDIR}/sapis-build/cli/sapi/cli/php"
667 if [[ ! -x "${PHP_BIN}" ]] ; then
668 ewarn "Test phase requires USE=cli, skipping"
669 return
670 else
671 export TEST_PHP_EXECUTABLE="${PHP_BIN}"
672 fi
673
674 if [[ -x "${WORKDIR}/sapis/cgi/php-cgi" ]] ; then
675 export TEST_PHP_CGI_EXECUTABLE="${WORKDIR}/sapis/cgi/php-cgi"
676 fi
677
678 REPORT_EXIT_STATUS=1 "${TEST_PHP_EXECUTABLE}" -n -d \
679 "session.save_path=${T}" \
680 "${WORKDIR}/sapis-build/cli/run-tests.php" -n -q -d \
681 "session.save_path=${T}"
682
683 for name in ${EXPECTED_TEST_FAILURES}; do
684 mv "${name}.out" "${name}.out.orig" 2>/dev/null || die
685 done
686
687 local failed="$(find -name '*.out')"
688 if [[ ${failed} != "" ]] ; then
689 ewarn "The following test cases failed unexpectedly:"
690 for name in ${failed}; do
691 ewarn " ${name/.out/}"
692 done
693 else
694 einfo "No unexpected test failures, all fine"
695 fi
696
697 if [[ ${PHP_SHOW_UNEXPECTED_TEST_PASS} == "1" ]] ; then
698 local passed=""
699 for name in ${EXPECTED_TEST_FAILURES}; do
700 [[ -f "${name}.diff" ]] && continue
701 passed="${passed} ${name}"
702 done
703 if [[ ${passed} != "" ]] ; then
704 einfo "The following test cases passed unexpectedly:"
705 for name in ${passed}; do
706 ewarn " ${passed}"
707 done
708 else
709 einfo "None of the known-to-fail tests passed, all fine"
710 fi
711 fi
712 }
713
714 pkg_postinst() {
715 # Output some general info to the user
716 if use apache2 ; then
717 elog
718 elog "To enable PHP in apache, you will need to add \"-D PHP\" to"
719 elog "your apache2 command. OpenRC users can append that string to"
720 elog "APACHE2_OPTS in /etc/conf.d/apache2."
721 elog
722 elog "The apache module configuration file 70_mod_php.conf is"
723 elog "provided (and maintained) by eselect-php."
724 elog
725 fi
726
727 # Create the symlinks for php
728 for m in ${SAPIS}; do
729 [[ ${m} == 'embed' ]] && continue;
730 if use $m ; then
731 local ci=$(eselect php show $m)
732 if [[ -z $ci ]]; then
733 eselect php set $m php${SLOT} || die
734 einfo "Switched ${m} to use php:${SLOT}"
735 einfo
736 elif [[ $ci != "php${SLOT}" ]] ; then
737 elog "To switch $m to use php:${SLOT}, run"
738 elog " eselect php set $m php${SLOT}"
739 elog
740 fi
741 fi
742 done
743
744 # Remove dead symlinks for SAPIs that were just disabled. For
745 # example, if the user has the cgi SAPI enabled, then he has an
746 # eselect-php symlink for it. If he later reinstalls PHP with
747 # USE="-cgi", that symlink will break. This call to eselect is
748 # supposed to remove that dead link per bug 572436.
749 eselect php cleanup || die
750
751 if ! has "php${SLOT/./-}" ${PHP_TARGETS}; then
752 elog "To build extensions for this version of PHP, you will need to"
753 elog "add php${SLOT/./-} to your PHP_TARGETS USE_EXPAND variable."
754 elog
755 fi
756
757 # Warn about the removal of PHP_INI_VERSION if the user has it set.
758 if [[ -n "${PHP_INI_VERSION}" ]]; then
759 ewarn 'The PHP_INI_VERSION variable has been phased out. You may'
760 ewarn 'remove it from your configuration at your convenience. See'
761 ewarn
762 ewarn ' https://bugs.gentoo.org/611214'
763 ewarn
764 ewarn 'for more information.'
765 fi
766
767 elog "For details on how version slotting works, please see"
768 elog "the wiki:"
769 elog
770 elog " https://wiki.gentoo.org/wiki/PHP"
771 elog
772 }
773
774 pkg_postrm() {
775 # This serves two purposes. First, if we have just removed the last
776 # installed version of PHP, then this will remove any dead symlinks
777 # belonging to eselect-php. Second, if a user upgrades slots from
778 # (say) 5.6 to 7.0 and depcleans the old slot, then this will update
779 # his existing symlinks to point to the new 7.0 installation. The
780 # latter is bug 432962.
781 #
782 # Note: the eselect-php package may not be installed at this point,
783 # so we can't die() if this command fails.
784 eselect php cleanup
785 }