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