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