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