Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/php/
Date: Tue, 26 Jul 2016 21:47:05
Message-Id: 1469569408.1402e128c523180f57ce7bc22567ca28b6930a9f.mjo@gentoo
1 commit: 1402e128c523180f57ce7bc22567ca28b6930a9f
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jul 26 17:15:11 2016 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 26 21:43:28 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1402e128
7
8 dev-lang/php: new 5.6 and 7.0 revisions to clean up metadata cruft.
9
10 The SRC_URI handling in our current ebuilds was a bit
11 over-complicated. I've reorganized all of the metadata (KEYWORDS,
12 SRC_URI, etc.) so that it's easier to understand. There were also some
13 superfluous environment variables that have been removed.
14
15 Package-Manager: portage-2.2.28
16
17 dev-lang/php/php-5.6.24-r1.ebuild | 767 ++++++++++++++++++++++++++++++++++++++
18 dev-lang/php/php-7.0.9-r1.ebuild | 758 +++++++++++++++++++++++++++++++++++++
19 2 files changed, 1525 insertions(+)
20
21 diff --git a/dev-lang/php/php-5.6.24-r1.ebuild b/dev-lang/php/php-5.6.24-r1.ebuild
22 new file mode 100644
23 index 0000000..fe534cc
24 --- /dev/null
25 +++ b/dev-lang/php/php-5.6.24-r1.ebuild
26 @@ -0,0 +1,767 @@
27 +# Copyright 1999-2016 Gentoo Foundation
28 +# Distributed under the terms of the GNU General Public License v2
29 +# $Id$
30 +
31 +EAPI=5
32 +
33 +inherit eutils autotools flag-o-matic versionator libtool systemd
34 +
35 +DESCRIPTION="The PHP language runtime engine"
36 +HOMEPAGE="http://php.net/"
37 +SRC_URI="http://php.net/distributions/${P}.tar.xz"
38 +LICENSE="PHP-3"
39 +SLOT="$(get_version_component_range 1-2)"
40 +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"
41 +
42 +# We can build the following SAPIs in the given order
43 +SAPIS="embed cli cgi fpm apache2"
44 +
45 +# SAPIs and SAPI-specific USE flags (cli SAPI is default on):
46 +IUSE="${IUSE}
47 + ${SAPIS/cli/+cli}
48 + threads"
49 +
50 +IUSE="${IUSE} bcmath berkdb bzip2 calendar cdb cjk
51 + crypt +ctype curl debug
52 + enchant exif frontbase +fileinfo +filter firebird
53 + flatfile ftp gd gdbm gmp +hash +iconv imap inifile
54 + intl iodbc ipv6 +json kerberos ldap ldap-sasl libedit libressl
55 + mhash mssql mysql libmysqlclient mysqli nls
56 + oci8-instant-client odbc +opcache pcntl pdo +phar +posix postgres qdbm
57 + readline recode selinux +session sharedmem
58 + +simplexml snmp soap sockets spell sqlite ssl
59 + sybase-ct sysvipc systemd tidy +tokenizer truetype unicode vpx wddx
60 + +xml xmlreader xmlwriter xmlrpc xpm xslt zip zlib"
61 +
62 +# The supported (that is, autodetected) versions of BDB are listed in
63 +# the ./configure script. Other versions *work*, but we need to stick to
64 +# the ones that can be detected to avoid a repeat of bug #564824.
65 +COMMON_DEPEND="
66 + >=app-eselect/eselect-php-0.9.1[apache2?,fpm?]
67 + >=dev-libs/libpcre-8.32[unicode]
68 + apache2? ( || ( >=www-servers/apache-2.4[apache2_modules_unixd,threads=]
69 + <www-servers/apache-2.4[threads=] ) )
70 + berkdb? ( || ( sys-libs/db:5.3
71 + sys-libs/db:5.1
72 + sys-libs/db:4.8
73 + sys-libs/db:4.7
74 + sys-libs/db:4.6
75 + sys-libs/db:4.5 ) )
76 + bzip2? ( app-arch/bzip2 )
77 + cdb? ( || ( dev-db/cdb dev-db/tinycdb ) )
78 + cjk? ( !gd? (
79 + virtual/jpeg:0
80 + media-libs/libpng:0=
81 + sys-libs/zlib
82 + ) )
83 + crypt? ( >=dev-libs/libmcrypt-2.4 )
84 + curl? ( >=net-misc/curl-7.10.5 )
85 + enchant? ( app-text/enchant )
86 + exif? ( !gd? (
87 + virtual/jpeg:0
88 + media-libs/libpng:0=
89 + sys-libs/zlib
90 + ) )
91 + firebird? ( dev-db/firebird )
92 + gd? ( virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib )
93 + gdbm? ( >=sys-libs/gdbm-1.8.0 )
94 + gmp? ( dev-libs/gmp:0 )
95 + iconv? ( virtual/libiconv )
96 + imap? ( virtual/imap-c-client[ssl=] )
97 + intl? ( dev-libs/icu:= )
98 + iodbc? ( dev-db/libiodbc )
99 + kerberos? ( virtual/krb5 )
100 + ldap? ( >=net-nds/openldap-1.2.11 )
101 + ldap-sasl? ( dev-libs/cyrus-sasl >=net-nds/openldap-1.2.11 )
102 + libedit? ( || ( sys-freebsd/freebsd-lib dev-libs/libedit ) )
103 + mssql? ( dev-db/freetds[mssql] )
104 + libmysqlclient? (
105 + mysql? ( virtual/mysql )
106 + mysqli? ( >=virtual/mysql-4.1 )
107 + )
108 + nls? ( sys-devel/gettext )
109 + oci8-instant-client? ( dev-db/oracle-instantclient-basic )
110 + odbc? ( >=dev-db/unixODBC-1.8.13 )
111 + postgres? ( dev-db/postgresql:* )
112 + qdbm? ( dev-db/qdbm )
113 + readline? ( sys-libs/readline:0 )
114 + recode? ( app-text/recode )
115 + sharedmem? ( dev-libs/mm )
116 + simplexml? ( >=dev-libs/libxml2-2.6.8 )
117 + snmp? ( >=net-analyzer/net-snmp-5.2 )
118 + soap? ( >=dev-libs/libxml2-2.6.8 )
119 + spell? ( >=app-text/aspell-0.50 )
120 + sqlite? ( >=dev-db/sqlite-3.7.6.3 )
121 + ssl? (
122 + !libressl? ( dev-libs/openssl:0 )
123 + libressl? ( dev-libs/libressl )
124 + )
125 + sybase-ct? ( dev-db/freetds )
126 + tidy? ( app-text/htmltidy )
127 + truetype? (
128 + =media-libs/freetype-2*
129 + >=media-libs/t1lib-5.0.0
130 + !gd? (
131 + virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib )
132 + )
133 + unicode? ( dev-libs/oniguruma )
134 + vpx? ( media-libs/libvpx )
135 + wddx? ( >=dev-libs/libxml2-2.6.8 )
136 + xml? ( >=dev-libs/libxml2-2.6.8 )
137 + xmlrpc? ( >=dev-libs/libxml2-2.6.8 virtual/libiconv )
138 + xmlreader? ( >=dev-libs/libxml2-2.6.8 )
139 + xmlwriter? ( >=dev-libs/libxml2-2.6.8 )
140 + xpm? (
141 + x11-libs/libXpm
142 + virtual/jpeg:0
143 + media-libs/libpng:0= sys-libs/zlib
144 + )
145 + xslt? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 )
146 + zip? ( sys-libs/zlib )
147 + zlib? ( sys-libs/zlib )
148 +"
149 +
150 +RDEPEND="${COMMON_DEPEND}
151 + virtual/mta
152 + fpm? (
153 + selinux? ( sec-policy/selinux-phpfpm )
154 + systemd? ( sys-apps/systemd ) )"
155 +
156 +DEPEND="${COMMON_DEPEND}
157 + app-arch/xz-utils
158 + sys-devel/flex
159 + >=sys-devel/m4-1.4.3
160 + >=sys-devel/libtool-1.5.18"
161 +
162 +# Without USE=readline or libedit, the interactive "php -a" CLI will hang.
163 +REQUIRED_USE="
164 + cli? ( ^^ ( readline libedit ) )
165 + truetype? ( gd )
166 + vpx? ( gd )
167 + cjk? ( gd )
168 + exif? ( gd )
169 +
170 + xpm? ( gd )
171 + gd? ( zlib )
172 + simplexml? ( xml )
173 + soap? ( xml )
174 + wddx? ( xml )
175 + xmlrpc? ( || ( xml iconv ) )
176 + xmlreader? ( xml )
177 + xslt? ( xml )
178 + ldap-sasl? ( ldap )
179 + mhash? ( hash )
180 + phar? ( hash )
181 + libmysqlclient? ( || (
182 + mysql
183 + mysqli
184 + pdo
185 + ) )
186 +
187 + qdbm? ( !gdbm )
188 + readline? ( !libedit )
189 + recode? ( !imap !mysql !mysqli )
190 + sharedmem? ( !threads )
191 +
192 + !cli? ( !cgi? ( !fpm? ( !apache2? ( !embed? ( cli ) ) ) ) )"
193 +
194 +PHP_MV="$(get_major_version)"
195 +
196 +# Allow users to install production version if they want to
197 +if [[ "${PHP_INI_VERSION}" == "production" ]]; then
198 + PHP_INI_UPSTREAM="php.ini-production"
199 +else
200 + PHP_INI_UPSTREAM="php.ini-development"
201 +fi
202 +
203 +php_install_ini() {
204 + local phpsapi="${1}"
205 +
206 + # work out where we are installing the ini file
207 + php_set_ini_dir "${phpsapi}"
208 +
209 + local phpinisrc="${PHP_INI_UPSTREAM}-${phpsapi}"
210 + cp "${PHP_INI_UPSTREAM}" "${phpinisrc}" || die
211 +
212 + # default to /tmp for save_path, bug #282768
213 + sed -e 's|^;session.save_path .*$|session.save_path = "'"${EPREFIX}"'/tmp"|g' -i "${phpinisrc}" || die
214 +
215 + # Set the extension dir
216 + sed -e "s|^extension_dir .*$|extension_dir = ${extension_dir}|g" -i "${phpinisrc}" || die
217 +
218 + # Set the include path to point to where we want to find PEAR packages
219 + sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:'"${EPREFIX}"'/usr/share/php'${PHP_MV}':'"${EPREFIX}"'/usr/share/php"|' -i "${phpinisrc}" || die
220 +
221 + dodir "${PHP_INI_DIR#${EPREFIX}}"
222 + insinto "${PHP_INI_DIR#${EPREFIX}}"
223 + newins "${phpinisrc}" php.ini
224 +
225 + elog "Installing php.ini for ${phpsapi} into ${PHP_INI_DIR#${EPREFIX}}"
226 + elog
227 +
228 + dodir "${PHP_EXT_INI_DIR#${EPREFIX}}"
229 + dodir "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}"
230 +
231 + if use opcache; then
232 + elog "Adding opcache to $PHP_EXT_INI_DIR"
233 + echo "zend_extension=${PHP_DESTDIR}/$(get_libdir)/opcache.so" >> \
234 + "${D}/${PHP_EXT_INI_DIR}"/opcache.ini
235 + dosym "${PHP_EXT_INI_DIR#${EPREFIX}}/opcache.ini" \
236 + "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}/opcache.ini"
237 + fi
238 +
239 + # SAPI-specific handling
240 + if [[ "${sapi}" == "fpm" ]] ; then
241 + einfo "Installing FPM config file php-fpm.conf"
242 + insinto "${PHP_INI_DIR#${EPREFIX}}"
243 + doins sapi/fpm/php-fpm.conf
244 + fi
245 +
246 + dodoc php.ini-development
247 + dodoc php.ini-production
248 +}
249 +
250 +php_set_ini_dir() {
251 + PHP_INI_DIR="${EPREFIX}/etc/php/${1}-php${SLOT}"
252 + PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
253 + PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
254 +}
255 +
256 +src_prepare() {
257 + # Change PHP branding
258 + # Get the alpha/beta/rc version
259 + sed -re "s|^(PHP_EXTRA_VERSION=\").*(\")|\1-pl${PR/r/}-gentoo\2|g" \
260 + -i configure.in || die "Unable to change PHP branding"
261 +
262 + # Patch PHP to show Gentoo as the server platform
263 + sed -e 's/PHP_UNAME=`uname -a | xargs`/PHP_UNAME=`uname -s -n -r -v | xargs`/g' \
264 + -i configure.in || die "Failed to fix server platform name"
265 +
266 + # Prevent PHP from activating the Apache config,
267 + # as we will do that ourselves
268 + sed -i \
269 + -e "s,-i -a -n php${PHP_MV},-i -n php${PHP_MV},g" \
270 + -e "s,-i -A -n php${PHP_MV},-i -n php${PHP_MV},g" \
271 + configure sapi/apache2filter/config.m4 sapi/apache2handler/config.m4 \
272 + || die
273 +
274 + # Patch PHP to support heimdal instead of mit-krb5
275 + if has_version "app-crypt/heimdal" ; then
276 + sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 \
277 + || die "Failed to fix heimdal libname"
278 + sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 \
279 + || die "Failed to fix heimdal crypt library reference"
280 + fi
281 +
282 + # Add user patches #357637
283 + epatch_user
284 +
285 + # Force rebuilding aclocal.m4
286 + rm -f aclocal.m4 || die
287 + eautoreconf
288 +
289 + if [[ ${CHOST} == *-darwin* ]] ; then
290 + # http://bugs.php.net/bug.php?id=48795, bug #343481
291 + sed -i -e '/BUILD_CGI="\\$(CC)/s/CC/CXX/' configure || die
292 + fi
293 +}
294 +
295 +src_configure() {
296 + addpredict /usr/share/snmp/mibs/.index
297 + addpredict /var/lib/net-snmp/mib_indexes
298 +
299 + PHP_DESTDIR="${EPREFIX}/usr/$(get_libdir)/php${SLOT}"
300 +
301 + # The php-fpm config file wants localstatedir to be ${EPREFIX}/var
302 + # and not the Gentoo default ${EPREFIX}/var/lib. See bug 572002.
303 + local our_conf=(
304 + --prefix="${PHP_DESTDIR}"
305 + --mandir="${PHP_DESTDIR}/man"
306 + --infodir="${PHP_DESTDIR}/info"
307 + --libdir="${PHP_DESTDIR}/lib"
308 + --with-libdir="$(get_libdir)"
309 + --localstatedir="${EPREFIX}/var"
310 + --without-pear
311 + $(use_enable threads maintainer-zts)
312 + )
313 +
314 + our_conf+=(
315 + $(use_enable bcmath bcmath)
316 + $(use_with bzip2 bz2 "${EPREFIX}/usr")
317 + $(use_enable calendar calendar)
318 + $(use_enable ctype ctype)
319 + $(use_with curl curl "${EPREFIX}/usr")
320 + $(use_enable xml dom)
321 + $(use_with enchant enchant "${EPREFIX}/usr")
322 + $(use_enable exif exif)
323 + $(use_enable fileinfo fileinfo)
324 + $(use_enable filter filter)
325 + $(use_enable ftp ftp)
326 + $(use_with nls gettext "${EPREFIX}/usr")
327 + $(use_with gmp gmp "${EPREFIX}/usr")
328 + $(use_enable hash hash)
329 + $(use_with mhash mhash "${EPREFIX}/usr")
330 + $(use_with iconv iconv \
331 + $(use elibc_glibc || use elibc_musl || echo "${EPREFIX}/usr"))
332 + $(use_enable intl intl)
333 + $(use_enable ipv6 ipv6)
334 + $(use_enable json json)
335 + $(use_with kerberos kerberos "${EPREFIX}/usr")
336 + $(use_enable xml libxml)
337 + $(use_with xml libxml-dir "${EPREFIX}/usr")
338 + $(use_enable unicode mbstring)
339 + $(use_with crypt mcrypt "${EPREFIX}/usr")
340 + $(use_with mssql mssql "${EPREFIX}/usr")
341 + $(use_with unicode onig "${EPREFIX}/usr")
342 + $(use_with ssl openssl "${EPREFIX}/usr")
343 + $(use_with ssl openssl-dir "${EPREFIX}/usr")
344 + $(use_enable pcntl pcntl)
345 + $(use_enable phar phar)
346 + $(use_enable pdo pdo)
347 + $(use_enable opcache opcache)
348 + $(use_with postgres pgsql "${EPREFIX}/usr")
349 + $(use_enable posix posix)
350 + $(use_with spell pspell "${EPREFIX}/usr")
351 + $(use_with recode recode "${EPREFIX}/usr")
352 + $(use_enable simplexml simplexml)
353 + $(use_enable sharedmem shmop)
354 + $(use_with snmp snmp "${EPREFIX}/usr")
355 + $(use_enable soap soap)
356 + $(use_enable sockets sockets)
357 + $(use_with sqlite sqlite3 "${EPREFIX}/usr")
358 + $(use_with sybase-ct sybase-ct "${EPREFIX}/usr")
359 + $(use_enable sysvipc sysvmsg)
360 + $(use_enable sysvipc sysvsem)
361 + $(use_enable sysvipc sysvshm)
362 + $(use_with systemd fpm-systemd)
363 + $(use_with tidy tidy "${EPREFIX}/usr")
364 + $(use_enable tokenizer tokenizer)
365 + $(use_enable wddx wddx)
366 + $(use_enable xml xml)
367 + $(use_enable xmlreader xmlreader)
368 + $(use_enable xmlwriter xmlwriter)
369 + $(use_with xmlrpc xmlrpc)
370 + $(use_with xslt xsl "${EPREFIX}/usr")
371 + $(use_enable zip zip)
372 + $(use_with zlib zlib "${EPREFIX}/usr")
373 + $(use_enable debug debug)
374 + )
375 +
376 + # DBA support
377 + if use cdb || use berkdb || use flatfile || use gdbm || use inifile \
378 + || use qdbm ; then
379 + our_conf+=( "--enable-dba${shared}" )
380 + fi
381 +
382 + # DBA drivers support
383 + our_conf+=(
384 + $(use_with cdb cdb)
385 + $(use_with berkdb db4 "${EPREFIX}/usr")
386 + $(use_enable flatfile flatfile)
387 + $(use_with gdbm gdbm "${EPREFIX}/usr")
388 + $(use_enable inifile inifile)
389 + $(use_with qdbm qdbm "${EPREFIX}/usr")
390 + )
391 +
392 + # Support for the GD graphics library
393 + our_conf+=(
394 + $(use_with truetype freetype-dir "${EPREFIX}/usr")
395 + $(use_with truetype t1lib "${EPREFIX}/usr")
396 + $(use_enable cjk gd-jis-conv)
397 + $(use_with gd jpeg-dir "${EPREFIX}/usr")
398 + $(use_with gd png-dir "${EPREFIX}/usr")
399 + $(use_with xpm xpm-dir "${EPREFIX}/usr")
400 + $(use_with vpx vpx-dir "${EPREFIX}/usr")
401 + )
402 + # enable gd last, so configure can pick up the previous settings
403 + our_conf+=( $(use_with gd gd) )
404 +
405 + # IMAP support
406 + if use imap ; then
407 + our_conf+=(
408 + $(use_with imap imap "${EPREFIX}/usr")
409 + $(use_with ssl imap-ssl "${EPREFIX}/usr")
410 + )
411 + fi
412 +
413 + # Interbase/firebird support
414 + our_conf+=( $(use_with firebird interbase "${EPREFIX}/usr") )
415 +
416 + # LDAP support
417 + if use ldap ; then
418 + our_conf+=(
419 + $(use_with ldap ldap "${EPREFIX}/usr")
420 + $(use_with ldap-sasl ldap-sasl "${EPREFIX}/usr")
421 + )
422 + fi
423 +
424 + # MySQL support
425 + local mysqllib="mysqlnd"
426 + local mysqlilib="mysqlnd"
427 + use libmysqlclient && mysqllib="${EPREFIX}/usr"
428 + use libmysqlclient && mysqlilib="${EPREFIX}/usr/bin/mysql_config"
429 +
430 + our_conf+=( $(use_with mysql mysql "${mysqllib}") )
431 + our_conf+=( $(use_with mysqli mysqli "${mysqlilib}") )
432 +
433 + local mysqlsock="${EPREFIX}/var/run/mysqld/mysqld.sock"
434 + if use mysql || use mysqli ; then
435 + our_conf+=( $(use_with mysql mysql-sock "${mysqlsock}") )
436 + fi
437 +
438 + # ODBC support
439 + our_conf+=(
440 + $(use_with odbc unixODBC "${EPREFIX}/usr")
441 + $(use_with iodbc iodbc "${EPREFIX}/usr")
442 + )
443 +
444 + # Oracle support
445 + our_conf+=( $(use_with oci8-instant-client oci8) )
446 +
447 + # PDO support
448 + if use pdo ; then
449 + our_conf+=(
450 + $(use_with mssql pdo-dblib)
451 + $(use_with mysql pdo-mysql "${mysqllib}")
452 + $(use_with postgres pdo-pgsql)
453 + $(use_with sqlite pdo-sqlite "${EPREFIX}/usr")
454 + $(use_with firebird pdo-firebird "${EPREFIX}/usr")
455 + $(use_with odbc pdo-odbc "unixODBC,${EPREFIX}/usr")
456 + $(use_with oci8-instant-client pdo-oci)
457 + )
458 + fi
459 +
460 + # readline/libedit support
461 + our_conf+=(
462 + $(use_with readline readline "${EPREFIX}/usr")
463 + $(use_with libedit libedit "${EPREFIX}/usr")
464 + )
465 +
466 + # Session support
467 + if use session ; then
468 + our_conf+=( $(use_with sharedmem mm "${EPREFIX}/usr") )
469 + else
470 + our_conf+=( $(use_enable session session) )
471 + fi
472 +
473 + # Use pic for shared modules such as apache2's mod_php
474 + our_conf+=( --with-pic )
475 +
476 + # we use the system copy of pcre
477 + # --with-pcre-regex affects ext/pcre
478 + # --with-pcre-dir affects ext/filter and ext/zip
479 + our_conf+=(
480 + --with-pcre-regex="${EPREFIX}/usr"
481 + --with-pcre-dir="${EPREFIX}/usr"
482 + )
483 +
484 + # Catch CFLAGS problems
485 + # Fixes bug #14067.
486 + # Changed order to run it in reverse for bug #32022 and #12021.
487 + replace-cpu-flags "k6*" "i586"
488 +
489 + # Support user-passed configuration parameters
490 + our_conf+=( ${EXTRA_ECONF:-} )
491 +
492 + # Support the Apache2 extras, they must be set globally for all
493 + # SAPIs to work correctly, especially for external PHP extensions
494 +
495 + mkdir -p "${WORKDIR}/sapis-build" || die
496 + for one_sapi in $SAPIS ; do
497 + use "${one_sapi}" || continue
498 + php_set_ini_dir "${one_sapi}"
499 +
500 + # The BUILD_DIR variable is used to determine where to output
501 + # the files that autotools creates. This was all originally
502 + # based on the autotools-utils eclass.
503 + BUILD_DIR="${WORKDIR}/sapis-build/${one_sapi}"
504 + cp -r "${S}" "${BUILD_DIR}" || die
505 + cd "${BUILD_DIR}" || die
506 +
507 + local sapi_conf=(
508 + --with-config-file-path="${PHP_INI_DIR}"
509 + --with-config-file-scan-dir="${PHP_EXT_INI_DIR_ACTIVE}"
510 + )
511 +
512 + for sapi in $SAPIS ; do
513 + case "$sapi" in
514 + cli|cgi|embed|fpm)
515 + if [[ "${one_sapi}" == "${sapi}" ]] ; then
516 + sapi_conf+=( "--enable-${sapi}" )
517 + else
518 + sapi_conf+=( "--disable-${sapi}" )
519 + fi
520 + ;;
521 +
522 + apache2)
523 + if [[ "${one_sapi}" == "${sapi}" ]] ; then
524 + sapi_conf+=( --with-apxs2="${EPREFIX}/usr/sbin/apxs" )
525 + else
526 + sapi_conf+=( --without-apxs2 )
527 + fi
528 + ;;
529 + esac
530 + done
531 +
532 + # Construct the $myeconfargs array by concatenating $our_conf
533 + # (the common args) and $sapi_conf (the SAPI-specific args).
534 + local myeconfargs=( "${our_conf[@]}" )
535 + myeconfargs+=( "${sapi_conf[@]}" )
536 +
537 + pushd "${BUILD_DIR}" > /dev/null || die
538 + econf "${myeconfargs[@]}"
539 + popd > /dev/null || die
540 + done
541 +}
542 +
543 +src_compile() {
544 + # snmp seems to run during src_compile, too (bug #324739)
545 + addpredict /usr/share/snmp/mibs/.index
546 + addpredict /var/lib/net-snmp/mib_indexes
547 +
548 + for sapi in ${SAPIS} ; do
549 + if use "${sapi}"; then
550 + cd "${WORKDIR}/sapis-build/$sapi" || \
551 + die "Failed to change dir to ${WORKDIR}/sapis-build/$1"
552 + emake
553 + fi
554 + done
555 +}
556 +
557 +src_install() {
558 + # see bug #324739 for what happens when we don't have that
559 + addpredict /usr/share/snmp/mibs/.index
560 +
561 + # grab the first SAPI that got built and install common files from there
562 + local first_sapi=""
563 + for sapi in $SAPIS ; do
564 + if use $sapi ; then
565 + first_sapi=$sapi
566 + break
567 + fi
568 + done
569 +
570 + # Makefile forgets to create this before trying to write to it...
571 + dodir "${PHP_DESTDIR#${EPREFIX}}/bin"
572 +
573 + # Install php environment (without any sapis)
574 + cd "${WORKDIR}/sapis-build/$first_sapi" || die
575 + emake INSTALL_ROOT="${D}" \
576 + install-build install-headers install-programs
577 +
578 + local extension_dir="$("${ED}/${PHP_DESTDIR#${EPREFIX}}/bin/php-config" --extension-dir)"
579 +
580 + # Create the directory where we'll put version-specific php scripts
581 + keepdir "/usr/share/php${PHP_MV}"
582 +
583 + local sapi="", file=""
584 + local sapi_list=""
585 +
586 + for sapi in ${SAPIS}; do
587 + if use "${sapi}" ; then
588 + einfo "Installing SAPI: ${sapi}"
589 + cd "${WORKDIR}/sapis-build/${sapi}" || die
590 +
591 + if [[ "${sapi}" == "apache2" ]] ; then
592 + # We're specifically not using emake install-sapi as libtool
593 + # may cause unnecessary relink failures (see bug #351266)
594 + insinto "${PHP_DESTDIR#${EPREFIX}}/apache2/"
595 + newins ".libs/libphp5$(get_libname)" \
596 + "libphp${PHP_MV}$(get_libname)"
597 + keepdir "/usr/$(get_libdir)/apache2/modules"
598 + else
599 + # needed each time, php_install_ini would reset it
600 + local dest="${PHP_DESTDIR#${EPREFIX}}"
601 + into "${dest}"
602 + case "$sapi" in
603 + cli)
604 + source="sapi/cli/php"
605 + ;;
606 + cgi)
607 + source="sapi/cgi/php-cgi"
608 + ;;
609 + fpm)
610 + source="sapi/fpm/php-fpm"
611 + ;;
612 + embed)
613 + source="libs/libphp${PHP_MV}$(get_libname)"
614 + ;;
615 + *)
616 + die "unhandled sapi in src_install"
617 + ;;
618 + esac
619 +
620 + if [[ "${source}" == *"$(get_libname)" ]]; then
621 + dolib.so "${source}"
622 + else
623 + dobin "${source}"
624 + local name="$(basename ${source})"
625 + dosym "${dest}/bin/${name}" "/usr/bin/${name}${SLOT}"
626 + fi
627 + fi
628 +
629 + php_install_ini "${sapi}"
630 +
631 + # construct correct SAPI string for php-config
632 + # thanks to ferringb for the bash voodoo
633 + if [[ "${sapi}" == "apache2" ]]; then
634 + sapi_list="${sapi_list:+${sapi_list} }apache2handler"
635 + else
636 + sapi_list="${sapi_list:+${sapi_list} }${sapi}"
637 + fi
638 + fi
639 + done
640 +
641 + # Installing opcache module
642 + if use opcache ; then
643 + into "${PHP_DESTDIR#${EPREFIX}}"
644 + dolib.so "modules/opcache$(get_libname)"
645 + fi
646 +
647 + # Install env.d files
648 + newenvd "${FILESDIR}/20php5-envd" "20php${SLOT}"
649 + sed -e "s|/lib/|/$(get_libdir)/|g" -i "${ED}/etc/env.d/20php${SLOT}" || die
650 + sed -e "s|php5|php${SLOT}|g" -i "${ED}/etc/env.d/20php${SLOT}" || die
651 +
652 + # set php-config variable correctly (bug #278439)
653 + sed -e "s:^\(php_sapis=\)\".*\"$:\1\"${sapi_list}\":" -i \
654 + "${ED}/usr/$(get_libdir)/php${SLOT}/bin/php-config" || die
655 +
656 + if use fpm ; then
657 + if use systemd; then
658 + systemd_newunit "${FILESDIR}/php-fpm_at.service" \
659 + "php-fpm@${SLOT}.service"
660 + else
661 + systemd_newunit "${FILESDIR}/php-fpm_at-simple.service" \
662 + "php-fpm@${SLOT}.service"
663 + fi
664 + fi
665 +}
666 +
667 +src_test() {
668 + echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
669 + PHP_BIN="${WORKDIR}/sapis-build/cli/sapi/cli/php"
670 + if [[ ! -x "${PHP_BIN}" ]] ; then
671 + ewarn "Test phase requires USE=cli, skipping"
672 + return
673 + else
674 + export TEST_PHP_EXECUTABLE="${PHP_BIN}"
675 + fi
676 +
677 + if [[ -x "${WORKDIR}/sapis/cgi/php-cgi" ]] ; then
678 + export TEST_PHP_CGI_EXECUTABLE="${WORKDIR}/sapis/cgi/php-cgi"
679 + fi
680 +
681 + REPORT_EXIT_STATUS=1 "${TEST_PHP_EXECUTABLE}" -n -d \
682 + "session.save_path=${T}" \
683 + "${WORKDIR}/sapis-build/cli/run-tests.php" -n -q -d \
684 + "session.save_path=${T}"
685 +
686 + for name in ${EXPECTED_TEST_FAILURES}; do
687 + mv "${name}.out" "${name}.out.orig" 2>/dev/null || die
688 + done
689 +
690 + local failed="$(find -name '*.out')"
691 + if [[ ${failed} != "" ]] ; then
692 + ewarn "The following test cases failed unexpectedly:"
693 + for name in ${failed}; do
694 + ewarn " ${name/.out/}"
695 + done
696 + else
697 + einfo "No unexpected test failures, all fine"
698 + fi
699 +
700 + if [[ ${PHP_SHOW_UNEXPECTED_TEST_PASS} == "1" ]] ; then
701 + local passed=""
702 + for name in ${EXPECTED_TEST_FAILURES}; do
703 + [[ -f "${name}.diff" ]] && continue
704 + passed="${passed} ${name}"
705 + done
706 + if [[ ${passed} != "" ]] ; then
707 + einfo "The following test cases passed unexpectedly:"
708 + for name in ${passed}; do
709 + ewarn " ${passed}"
710 + done
711 + else
712 + einfo "None of the known-to-fail tests passed, all fine"
713 + fi
714 + fi
715 +}
716 +
717 +pkg_postinst() {
718 + # Output some general info to the user
719 + if use apache2 ; then
720 + elog
721 + elog "To enable PHP in apache, you will need to add \"-D PHP\" to"
722 + elog "your apache2 command. OpenRC users can append that string to"
723 + elog "APACHE2_OPTS in /etc/conf.d/apache2."
724 + elog
725 + elog "The apache module configuration file 70_mod_php.conf is"
726 + elog "provided (and maintained) by eselect-php."
727 + elog
728 + fi
729 +
730 + # Create the symlinks for php
731 + for m in ${SAPIS}; do
732 + [[ ${m} == 'embed' ]] && continue;
733 + if use $m ; then
734 + local ci=$(eselect php show $m)
735 + if [[ -z $ci ]]; then
736 + eselect php set $m php${SLOT} || die
737 + einfo "Switched ${m} to use php:${SLOT}"
738 + einfo
739 + elif [[ $ci != "php${SLOT}" ]] ; then
740 + elog "To switch $m to use php:${SLOT}, run"
741 + elog " eselect php set $m php${SLOT}"
742 + elog
743 + fi
744 + fi
745 + done
746 +
747 + # Remove dead symlinks for SAPIs that were just disabled. For
748 + # example, if the user has the cgi SAPI enabled, then he has an
749 + # eselect-php symlink for it. If he later reinstalls PHP with
750 + # USE="-cgi", that symlink will break. This call to eselect is
751 + # supposed to remove that dead link per bug 572436.
752 + eselect php cleanup || die
753 +
754 + if ! has "php${SLOT/./-}" ${PHP_TARGETS}; then
755 + elog "To build extensions for this version of PHP, you will need to"
756 + elog "add php${SLOT/./-} to your PHP_TARGETS USE_EXPAND variable."
757 + elog
758 + fi
759 +
760 + # Only mention PHP_INI_VERSION if the user doesn't have it set.
761 + case "${PHP_INI_VERSION}" in
762 + production|development)
763 + ;;
764 + *)
765 + elog "This ebuild installed a version of php.ini based on"
766 + elog "${PHP_INI_UPSTREAM}. You can choose which version of"
767 + elog "php.ini to install by default by setting PHP_INI_VERSION"
768 + elog "to either 'production' or 'development' in your make.conf."
769 + elog "Both versions of php.ini can be found with the PHP docs in"
770 + elog "${EPREFIX}/usr/share/doc/${PF}"
771 + elog
772 + ;;
773 + esac
774 +
775 + elog "For details on how version slotting works, please see"
776 + elog "the wiki:"
777 + elog
778 + elog " https://wiki.gentoo.org/wiki/PHP"
779 + elog
780 +}
781 +
782 +pkg_postrm() {
783 + # This serves two purposes. First, if we have just removed the last
784 + # installed version of PHP, then this will remove any dead symlinks
785 + # belonging to eselect-php. Second, if a user upgrades slots from
786 + # (say) 5.6 to 7.0 and depcleans the old slot, then this will update
787 + # his existing symlinks to point to the new 7.0 installation. The
788 + # latter is bug 432962.
789 + #
790 + # Note: the eselect-php package may not be installed at this point,
791 + # so we can't die() if this command fails.
792 + eselect php cleanup
793 +}
794
795 diff --git a/dev-lang/php/php-7.0.9-r1.ebuild b/dev-lang/php/php-7.0.9-r1.ebuild
796 new file mode 100644
797 index 0000000..f785ca6
798 --- /dev/null
799 +++ b/dev-lang/php/php-7.0.9-r1.ebuild
800 @@ -0,0 +1,758 @@
801 +# Copyright 1999-2016 Gentoo Foundation
802 +# Distributed under the terms of the GNU General Public License v2
803 +# $Id$
804 +
805 +EAPI=5
806 +
807 +inherit eutils autotools flag-o-matic versionator libtool systemd
808 +
809 +DESCRIPTION="The PHP language runtime engine"
810 +HOMEPAGE="http://php.net/"
811 +SRC_URI="http://php.net/distributions/${P}.tar.xz"
812 +LICENSE="PHP-3"
813 +SLOT="$(get_version_component_range 1-2)"
814 +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"
815 +
816 +# We can build the following SAPIs in the given order
817 +SAPIS="embed cli cgi fpm apache2 phpdbg"
818 +
819 +# SAPIs and SAPI-specific USE flags (cli SAPI is default on):
820 +IUSE="${IUSE}
821 + ${SAPIS/cli/+cli}
822 + threads"
823 +
824 +IUSE="${IUSE} bcmath berkdb bzip2 calendar cdb cjk
825 + crypt +ctype curl debug
826 + enchant exif frontbase +fileinfo +filter firebird
827 + flatfile ftp gd gdbm gmp +hash +iconv imap inifile
828 + intl iodbc ipv6 +json kerberos ldap ldap-sasl libedit libressl
829 + mhash mssql mysql mysqli nls
830 + oci8-instant-client odbc +opcache pcntl pdo +phar +posix postgres qdbm
831 + readline recode selinux +session sharedmem
832 + +simplexml snmp soap sockets spell sqlite ssl
833 + sysvipc systemd tidy +tokenizer truetype unicode wddx webp
834 + +xml xmlreader xmlwriter xmlrpc xpm xslt zip zlib"
835 +
836 +# The supported (that is, autodetected) versions of BDB are listed in
837 +# the ./configure script. Other versions *work*, but we need to stick to
838 +# the ones that can be detected to avoid a repeat of bug #564824.
839 +COMMON_DEPEND="
840 + >=app-eselect/eselect-php-0.9.1[apache2?,fpm?]
841 + >=dev-libs/libpcre-8.32[unicode]
842 + apache2? ( || ( >=www-servers/apache-2.4[apache2_modules_unixd,threads=]
843 + <www-servers/apache-2.4[threads=] ) )
844 + berkdb? ( || ( sys-libs/db:5.3
845 + sys-libs/db:5.1
846 + sys-libs/db:4.8
847 + sys-libs/db:4.7
848 + sys-libs/db:4.6
849 + sys-libs/db:4.5 ) )
850 + bzip2? ( app-arch/bzip2 )
851 + cdb? ( || ( dev-db/cdb dev-db/tinycdb ) )
852 + cjk? ( !gd? (
853 + virtual/jpeg:0
854 + media-libs/libpng:0=
855 + sys-libs/zlib
856 + ) )
857 + crypt? ( >=dev-libs/libmcrypt-2.4 )
858 + curl? ( >=net-misc/curl-7.10.5 )
859 + enchant? ( app-text/enchant )
860 + exif? ( !gd? (
861 + virtual/jpeg:0
862 + media-libs/libpng:0=
863 + sys-libs/zlib
864 + ) )
865 + firebird? ( dev-db/firebird )
866 + gd? ( virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib )
867 + gdbm? ( >=sys-libs/gdbm-1.8.0 )
868 + gmp? ( dev-libs/gmp:0 )
869 + iconv? ( virtual/libiconv )
870 + imap? ( virtual/imap-c-client[ssl=] )
871 + intl? ( dev-libs/icu:= )
872 + iodbc? ( dev-db/libiodbc )
873 + kerberos? ( virtual/krb5 )
874 + ldap? ( >=net-nds/openldap-1.2.11 )
875 + ldap-sasl? ( dev-libs/cyrus-sasl >=net-nds/openldap-1.2.11 )
876 + libedit? ( || ( sys-freebsd/freebsd-lib dev-libs/libedit ) )
877 + mssql? ( dev-db/freetds[mssql] )
878 + nls? ( sys-devel/gettext )
879 + oci8-instant-client? ( dev-db/oracle-instantclient-basic )
880 + odbc? ( >=dev-db/unixODBC-1.8.13 )
881 + postgres? ( dev-db/postgresql:* )
882 + qdbm? ( dev-db/qdbm )
883 + readline? ( sys-libs/readline:0 )
884 + recode? ( app-text/recode )
885 + sharedmem? ( dev-libs/mm )
886 + simplexml? ( >=dev-libs/libxml2-2.6.8 )
887 + snmp? ( >=net-analyzer/net-snmp-5.2 )
888 + soap? ( >=dev-libs/libxml2-2.6.8 )
889 + spell? ( >=app-text/aspell-0.50 )
890 + sqlite? ( >=dev-db/sqlite-3.7.6.3 )
891 + ssl? (
892 + !libressl? ( dev-libs/openssl:0 )
893 + libressl? ( dev-libs/libressl )
894 + )
895 + tidy? ( app-text/htmltidy )
896 + truetype? (
897 + =media-libs/freetype-2*
898 + !gd? (
899 + virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib )
900 + )
901 + unicode? ( dev-libs/oniguruma )
902 + wddx? ( >=dev-libs/libxml2-2.6.8 )
903 + webp? ( media-libs/libwebp )
904 + xml? ( >=dev-libs/libxml2-2.6.8 )
905 + xmlrpc? ( >=dev-libs/libxml2-2.6.8 virtual/libiconv )
906 + xmlreader? ( >=dev-libs/libxml2-2.6.8 )
907 + xmlwriter? ( >=dev-libs/libxml2-2.6.8 )
908 + xpm? (
909 + x11-libs/libXpm
910 + virtual/jpeg:0
911 + media-libs/libpng:0= sys-libs/zlib
912 + )
913 + xslt? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 )
914 + zip? ( sys-libs/zlib )
915 + zlib? ( sys-libs/zlib )
916 +"
917 +
918 +RDEPEND="${COMMON_DEPEND}
919 + virtual/mta
920 + fpm? (
921 + selinux? ( sec-policy/selinux-phpfpm )
922 + systemd? ( sys-apps/systemd ) )"
923 +
924 +DEPEND="${COMMON_DEPEND}
925 + app-arch/xz-utils
926 + sys-devel/flex
927 + >=sys-devel/m4-1.4.3
928 + >=sys-devel/libtool-1.5.18"
929 +
930 +# Without USE=readline or libedit, the interactive "php -a" CLI will hang.
931 +REQUIRED_USE="
932 + cli? ( ^^ ( readline libedit ) )
933 + truetype? ( gd )
934 + webp? ( gd )
935 + cjk? ( gd )
936 + exif? ( gd )
937 + xpm? ( gd )
938 + gd? ( zlib )
939 + simplexml? ( xml )
940 + soap? ( xml )
941 + wddx? ( xml )
942 + xmlrpc? ( || ( xml iconv ) )
943 + xmlreader? ( xml )
944 + xslt? ( xml )
945 + ldap-sasl? ( ldap )
946 + mhash? ( hash )
947 + phar? ( hash )
948 + qdbm? ( !gdbm )
949 + readline? ( !libedit )
950 + recode? ( !imap !mysqli )
951 + sharedmem? ( !threads )
952 + mysql? ( || ( mysqli pdo ) )
953 + || ( cli cgi fpm apache2 embed phpdbg )"
954 +
955 +PHP_MV="$(get_major_version)"
956 +
957 +
958 +# Allow users to install production version if they want to
959 +if [[ "${PHP_INI_VERSION}" == "production" ]]; then
960 + PHP_INI_UPSTREAM="php.ini-production"
961 +else
962 + PHP_INI_UPSTREAM="php.ini-development"
963 +fi
964 +
965 +php_install_ini() {
966 + local phpsapi="${1}"
967 +
968 + # work out where we are installing the ini file
969 + php_set_ini_dir "${phpsapi}"
970 +
971 + local phpinisrc="${PHP_INI_UPSTREAM}-${phpsapi}"
972 + cp "${PHP_INI_UPSTREAM}" "${phpinisrc}" || die
973 +
974 + # default to /tmp for save_path, bug #282768
975 + sed -e 's|^;session.save_path .*$|session.save_path = "'"${EPREFIX}"'/tmp"|g' -i "${phpinisrc}" || die
976 +
977 + # Set the extension dir
978 + sed -e "s|^extension_dir .*$|extension_dir = ${extension_dir}|g" -i "${phpinisrc}" || die
979 +
980 + # Set the include path to point to where we want to find PEAR packages
981 + sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:'"${EPREFIX}"'/usr/share/php'${PHP_MV}':'"${EPREFIX}"'/usr/share/php"|' -i "${phpinisrc}" || die
982 +
983 + dodir "${PHP_INI_DIR#${EPREFIX}}"
984 + insinto "${PHP_INI_DIR#${EPREFIX}}"
985 + newins "${phpinisrc}" php.ini
986 +
987 + elog "Installing php.ini for ${phpsapi} into ${PHP_INI_DIR#${EPREFIX}}"
988 + elog
989 +
990 + dodir "${PHP_EXT_INI_DIR#${EPREFIX}}"
991 + dodir "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}"
992 +
993 + if use opcache; then
994 + elog "Adding opcache to $PHP_EXT_INI_DIR"
995 + echo "zend_extension=${PHP_DESTDIR}/$(get_libdir)/opcache.so" >> \
996 + "${D}/${PHP_EXT_INI_DIR}"/opcache.ini
997 + dosym "${PHP_EXT_INI_DIR#${EPREFIX}}/opcache.ini" \
998 + "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}/opcache.ini"
999 + fi
1000 +
1001 + # SAPI-specific handling
1002 + if [[ "${sapi}" == "fpm" ]] ; then
1003 + einfo "Installing FPM config files php-fpm.conf and www.conf"
1004 + insinto "${PHP_INI_DIR#${EPREFIX}}"
1005 + doins sapi/fpm/php-fpm.conf
1006 + insinto "${PHP_INI_DIR#${EPREFIX}}/fpm.d"
1007 + doins sapi/fpm/www.conf
1008 + fi
1009 +
1010 + dodoc php.ini-development
1011 + dodoc php.ini-production
1012 +}
1013 +
1014 +php_set_ini_dir() {
1015 + PHP_INI_DIR="${EPREFIX}/etc/php/${1}-php${SLOT}"
1016 + PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
1017 + PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
1018 +}
1019 +
1020 +src_prepare() {
1021 + # Change PHP branding
1022 + # Get the alpha/beta/rc version
1023 + sed -re "s|^(PHP_EXTRA_VERSION=\").*(\")|\1-pl${PR/r/}-gentoo\2|g" \
1024 + -i configure.in || die "Unable to change PHP branding"
1025 +
1026 + # Patch PHP to show Gentoo as the server platform
1027 + sed -e 's/PHP_UNAME=`uname -a | xargs`/PHP_UNAME=`uname -s -n -r -v | xargs`/g' \
1028 + -i configure.in || die "Failed to fix server platform name"
1029 +
1030 + # Patch PHP to support heimdal instead of mit-krb5
1031 + if has_version "app-crypt/heimdal" ; then
1032 + sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 \
1033 + || die "Failed to fix heimdal libname"
1034 + sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 \
1035 + || die "Failed to fix heimdal crypt library reference"
1036 + fi
1037 +
1038 + # Add user patches #357637
1039 + epatch_user
1040 +
1041 + # Force rebuilding aclocal.m4
1042 + rm -f aclocal.m4 || die
1043 + eautoreconf
1044 +
1045 + if [[ ${CHOST} == *-darwin* ]] ; then
1046 + # http://bugs.php.net/bug.php?id=48795, bug #343481
1047 + sed -i -e '/BUILD_CGI="\\$(CC)/s/CC/CXX/' configure || die
1048 + fi
1049 +
1050 + # In php-7.x, the FPM pool configuration files have been split off
1051 + # of the main config. By default the pool config files go in
1052 + # e.g. /etc/php-fpm.d, which isn't slotted. So here we move the
1053 + # include directory to a subdirectory "fpm.d" of $PHP_INI_DIR. Later
1054 + # we'll install the pool configuration file "www.conf" there.
1055 + php_set_ini_dir fpm
1056 + sed -i "s~^include=.*$~include=${PHP_INI_DIR}/fpm.d/*.conf~" \
1057 + sapi/fpm/php-fpm.conf.in \
1058 + || die 'failed to move the include directory in php-fpm.conf'
1059 +}
1060 +
1061 +src_configure() {
1062 + addpredict /usr/share/snmp/mibs/.index
1063 + addpredict /var/lib/net-snmp/mib_indexes
1064 +
1065 + PHP_DESTDIR="${EPREFIX}/usr/$(get_libdir)/php${SLOT}"
1066 +
1067 + # The php-fpm config file wants localstatedir to be ${EPREFIX}/var
1068 + # and not the Gentoo default ${EPREFIX}/var/lib. See bug 572002.
1069 + local our_conf=(
1070 + --prefix="${PHP_DESTDIR}"
1071 + --mandir="${PHP_DESTDIR}/man"
1072 + --infodir="${PHP_DESTDIR}/info"
1073 + --libdir="${PHP_DESTDIR}/lib"
1074 + --with-libdir="$(get_libdir)"
1075 + --localstatedir="${EPREFIX}/var"
1076 + --without-pear
1077 + $(use_enable threads maintainer-zts)
1078 + )
1079 +
1080 + our_conf+=(
1081 + $(use_enable bcmath bcmath)
1082 + $(use_with bzip2 bz2 "${EPREFIX}/usr")
1083 + $(use_enable calendar calendar)
1084 + $(use_enable ctype ctype)
1085 + $(use_with curl curl "${EPREFIX}/usr")
1086 + $(use_enable xml dom)
1087 + $(use_with enchant enchant "${EPREFIX}/usr")
1088 + $(use_enable exif exif)
1089 + $(use_enable fileinfo fileinfo)
1090 + $(use_enable filter filter)
1091 + $(use_enable ftp ftp)
1092 + $(use_with nls gettext "${EPREFIX}/usr")
1093 + $(use_with gmp gmp "${EPREFIX}/usr")
1094 + $(use_enable hash hash)
1095 + $(use_with mhash mhash "${EPREFIX}/usr")
1096 + $(use_with iconv iconv \
1097 + $(use elibc_glibc || use elibc_musl || echo "${EPREFIX}/usr"))
1098 + $(use_enable intl intl)
1099 + $(use_enable ipv6 ipv6)
1100 + $(use_enable json json)
1101 + $(use_with kerberos kerberos "${EPREFIX}/usr")
1102 + $(use_enable xml libxml)
1103 + $(use_with xml libxml-dir "${EPREFIX}/usr")
1104 + $(use_enable unicode mbstring)
1105 + $(use_with crypt mcrypt "${EPREFIX}/usr")
1106 + $(use_with unicode onig "${EPREFIX}/usr")
1107 + $(use_with ssl openssl "${EPREFIX}/usr")
1108 + $(use_with ssl openssl-dir "${EPREFIX}/usr")
1109 + $(use_enable pcntl pcntl)
1110 + $(use_enable phar phar)
1111 + $(use_enable pdo pdo)
1112 + $(use_enable opcache opcache)
1113 + $(use_with postgres pgsql "${EPREFIX}/usr")
1114 + $(use_enable posix posix)
1115 + $(use_with spell pspell "${EPREFIX}/usr")
1116 + $(use_with recode recode "${EPREFIX}/usr")
1117 + $(use_enable simplexml simplexml)
1118 + $(use_enable sharedmem shmop)
1119 + $(use_with snmp snmp "${EPREFIX}/usr")
1120 + $(use_enable soap soap)
1121 + $(use_enable sockets sockets)
1122 + $(use_with sqlite sqlite3 "${EPREFIX}/usr")
1123 + $(use_enable sysvipc sysvmsg)
1124 + $(use_enable sysvipc sysvsem)
1125 + $(use_enable sysvipc sysvshm)
1126 + $(use_with systemd fpm-systemd)
1127 + $(use_with tidy tidy "${EPREFIX}/usr")
1128 + $(use_enable tokenizer tokenizer)
1129 + $(use_enable wddx wddx)
1130 + $(use_enable xml xml)
1131 + $(use_enable xmlreader xmlreader)
1132 + $(use_enable xmlwriter xmlwriter)
1133 + $(use_with xmlrpc xmlrpc)
1134 + $(use_with xslt xsl "${EPREFIX}/usr")
1135 + $(use_enable zip zip)
1136 + $(use_with zlib zlib "${EPREFIX}/usr")
1137 + $(use_enable debug debug)
1138 + )
1139 +
1140 + # DBA support
1141 + if use cdb || use berkdb || use flatfile || use gdbm || use inifile \
1142 + || use qdbm ; then
1143 + our_conf+=( "--enable-dba${shared}" )
1144 + fi
1145 +
1146 + # DBA drivers support
1147 + our_conf+=(
1148 + $(use_with cdb cdb)
1149 + $(use_with berkdb db4 "${EPREFIX}/usr")
1150 + $(use_enable flatfile flatfile)
1151 + $(use_with gdbm gdbm "${EPREFIX}/usr")
1152 + $(use_enable inifile inifile)
1153 + $(use_with qdbm qdbm "${EPREFIX}/usr")
1154 + )
1155 +
1156 + # Support for the GD graphics library
1157 + our_conf+=(
1158 + $(use_with truetype freetype-dir "${EPREFIX}/usr")
1159 + $(use_enable cjk gd-jis-conv)
1160 + $(use_with gd jpeg-dir "${EPREFIX}/usr")
1161 + $(use_with gd png-dir "${EPREFIX}/usr")
1162 + $(use_with xpm xpm-dir "${EPREFIX}/usr")
1163 + )
1164 + if use webp; then
1165 + our_conf+=( --with-webp-dir="${EPREFIX}/usr" )
1166 + fi
1167 + # enable gd last, so configure can pick up the previous settings
1168 + our_conf+=( $(use_with gd gd) )
1169 +
1170 + # IMAP support
1171 + if use imap ; then
1172 + our_conf+=(
1173 + $(use_with imap imap "${EPREFIX}/usr")
1174 + $(use_with ssl imap-ssl "${EPREFIX}/usr")
1175 + )
1176 + fi
1177 +
1178 + # Interbase/firebird support
1179 + our_conf+=( $(use_with firebird interbase "${EPREFIX}/usr") )
1180 +
1181 + # LDAP support
1182 + if use ldap ; then
1183 + our_conf+=(
1184 + $(use_with ldap ldap "${EPREFIX}/usr")
1185 + $(use_with ldap-sasl ldap-sasl "${EPREFIX}/usr")
1186 + )
1187 + fi
1188 +
1189 + # MySQL support
1190 + local mysqllib="mysqlnd"
1191 + local mysqlilib="mysqlnd"
1192 +
1193 + our_conf+=( $(use_with mysqli mysqli "${mysqlilib}") )
1194 +
1195 + local mysqlsock="${EPREFIX}/var/run/mysqld/mysqld.sock"
1196 + if use mysql || use mysqli ; then
1197 + our_conf+=( $(use_with mysql mysql-sock "${mysqlsock}") )
1198 + fi
1199 +
1200 + # ODBC support
1201 + our_conf+=(
1202 + $(use_with odbc unixODBC "${EPREFIX}/usr")
1203 + $(use_with iodbc iodbc "${EPREFIX}/usr")
1204 + )
1205 +
1206 + # Oracle support
1207 + our_conf+=( $(use_with oci8-instant-client oci8) )
1208 +
1209 + # PDO support
1210 + if use pdo ; then
1211 + our_conf+=(
1212 + $(use_with mssql pdo-dblib "${EPREFIX}/usr")
1213 + $(use_with mysql pdo-mysql "${mysqllib}")
1214 + $(use_with postgres pdo-pgsql)
1215 + $(use_with sqlite pdo-sqlite "${EPREFIX}/usr")
1216 + $(use_with firebird pdo-firebird "${EPREFIX}/usr")
1217 + $(use_with odbc pdo-odbc "unixODBC,${EPREFIX}/usr")
1218 + $(use_with oci8-instant-client pdo-oci)
1219 + )
1220 + fi
1221 +
1222 + # readline/libedit support
1223 + our_conf+=(
1224 + $(use_with readline readline "${EPREFIX}/usr")
1225 + $(use_with libedit libedit "${EPREFIX}/usr")
1226 + )
1227 +
1228 + # Session support
1229 + if use session ; then
1230 + our_conf+=( $(use_with sharedmem mm "${EPREFIX}/usr") )
1231 + else
1232 + our_conf+=( $(use_enable session session) )
1233 + fi
1234 +
1235 + # Use pic for shared modules such as apache2's mod_php
1236 + our_conf+=( --with-pic )
1237 +
1238 + # we use the system copy of pcre
1239 + # --with-pcre-regex affects ext/pcre
1240 + # --with-pcre-dir affects ext/filter and ext/zip
1241 + our_conf+=(
1242 + --with-pcre-regex="${EPREFIX}/usr"
1243 + --with-pcre-dir="${EPREFIX}/usr"
1244 + )
1245 +
1246 + # Catch CFLAGS problems
1247 + # Fixes bug #14067.
1248 + # Changed order to run it in reverse for bug #32022 and #12021.
1249 + replace-cpu-flags "k6*" "i586"
1250 +
1251 + # Support user-passed configuration parameters
1252 + our_conf+=( ${EXTRA_ECONF:-} )
1253 +
1254 + # Support the Apache2 extras, they must be set globally for all
1255 + # SAPIs to work correctly, especially for external PHP extensions
1256 +
1257 + mkdir -p "${WORKDIR}/sapis-build" || die
1258 + for one_sapi in $SAPIS ; do
1259 + use "${one_sapi}" || continue
1260 + php_set_ini_dir "${one_sapi}"
1261 +
1262 + # The BUILD_DIR variable is used to determine where to output
1263 + # the files that autotools creates. This was all originally
1264 + # based on the autotools-utils eclass.
1265 + BUILD_DIR="${WORKDIR}/sapis-build/${one_sapi}"
1266 + cp -r "${S}" "${BUILD_DIR}" || die
1267 + cd "${BUILD_DIR}" || die
1268 +
1269 + local sapi_conf=(
1270 + --with-config-file-path="${PHP_INI_DIR}"
1271 + --with-config-file-scan-dir="${PHP_EXT_INI_DIR_ACTIVE}"
1272 + )
1273 +
1274 + for sapi in $SAPIS ; do
1275 + case "$sapi" in
1276 + cli|cgi|embed|fpm|phpdbg)
1277 + if [[ "${one_sapi}" == "${sapi}" ]] ; then
1278 + sapi_conf+=( "--enable-${sapi}" )
1279 + else
1280 + sapi_conf+=( "--disable-${sapi}" )
1281 + fi
1282 + ;;
1283 +
1284 + apache2)
1285 + if [[ "${one_sapi}" == "${sapi}" ]] ; then
1286 + sapi_conf+=( --with-apxs2="${EPREFIX}/usr/sbin/apxs" )
1287 + else
1288 + sapi_conf+=( --without-apxs2 )
1289 + fi
1290 + ;;
1291 + esac
1292 + done
1293 +
1294 + # Construct the $myeconfargs array by concatenating $our_conf
1295 + # (the common args) and $sapi_conf (the SAPI-specific args).
1296 + local myeconfargs=( "${our_conf[@]}" )
1297 + myeconfargs+=( "${sapi_conf[@]}" )
1298 +
1299 + pushd "${BUILD_DIR}" > /dev/null || die
1300 + econf "${myeconfargs[@]}"
1301 + popd > /dev/null || die
1302 + done
1303 +}
1304 +
1305 +src_compile() {
1306 + # snmp seems to run during src_compile, too (bug #324739)
1307 + addpredict /usr/share/snmp/mibs/.index
1308 + addpredict /var/lib/net-snmp/mib_indexes
1309 +
1310 + for sapi in ${SAPIS} ; do
1311 + if use "${sapi}"; then
1312 + cd "${WORKDIR}/sapis-build/$sapi" || \
1313 + die "Failed to change dir to ${WORKDIR}/sapis-build/$1"
1314 + emake
1315 + fi
1316 + done
1317 +}
1318 +
1319 +src_install() {
1320 + # see bug #324739 for what happens when we don't have that
1321 + addpredict /usr/share/snmp/mibs/.index
1322 +
1323 + # grab the first SAPI that got built and install common files from there
1324 + local first_sapi=""
1325 + for sapi in $SAPIS ; do
1326 + if use $sapi ; then
1327 + first_sapi=$sapi
1328 + break
1329 + fi
1330 + done
1331 +
1332 + # Makefile forgets to create this before trying to write to it...
1333 + dodir "${PHP_DESTDIR#${EPREFIX}}/bin"
1334 +
1335 + # Install php environment (without any sapis)
1336 + cd "${WORKDIR}/sapis-build/$first_sapi" || die
1337 + emake INSTALL_ROOT="${D}" \
1338 + install-build install-headers install-programs
1339 +
1340 + local extension_dir="$("${ED}/${PHP_DESTDIR#${EPREFIX}}/bin/php-config" --extension-dir)"
1341 +
1342 + # Create the directory where we'll put version-specific php scripts
1343 + keepdir "/usr/share/php${PHP_MV}"
1344 +
1345 + local sapi="", file=""
1346 + local sapi_list=""
1347 +
1348 + for sapi in ${SAPIS}; do
1349 + if use "${sapi}" ; then
1350 + einfo "Installing SAPI: ${sapi}"
1351 + cd "${WORKDIR}/sapis-build/${sapi}" || die
1352 +
1353 + if [[ "${sapi}" == "apache2" ]] ; then
1354 + # We're specifically not using emake install-sapi as libtool
1355 + # may cause unnecessary relink failures (see bug #351266)
1356 + insinto "${PHP_DESTDIR#${EPREFIX}}/apache2/"
1357 + newins ".libs/libphp${PHP_MV}$(get_libname)" \
1358 + "libphp${PHP_MV}$(get_libname)"
1359 + keepdir "/usr/$(get_libdir)/apache2/modules"
1360 + else
1361 + # needed each time, php_install_ini would reset it
1362 + local dest="${PHP_DESTDIR#${EPREFIX}}"
1363 + into "${dest}"
1364 + case "$sapi" in
1365 + cli)
1366 + source="sapi/cli/php"
1367 + ;;
1368 + cgi)
1369 + source="sapi/cgi/php-cgi"
1370 + ;;
1371 + fpm)
1372 + source="sapi/fpm/php-fpm"
1373 + ;;
1374 + embed)
1375 + source="libs/libphp${PHP_MV}$(get_libname)"
1376 + ;;
1377 + phpdbg)
1378 + source="sapi/phpdbg/phpdbg"
1379 + ;;
1380 + *)
1381 + die "unhandled sapi in src_install"
1382 + ;;
1383 + esac
1384 +
1385 + if [[ "${source}" == *"$(get_libname)" ]]; then
1386 + dolib.so "${source}"
1387 + else
1388 + dobin "${source}"
1389 + local name="$(basename ${source})"
1390 + dosym "${dest}/bin/${name}" "/usr/bin/${name}${SLOT}"
1391 + fi
1392 + fi
1393 +
1394 + php_install_ini "${sapi}"
1395 +
1396 + # construct correct SAPI string for php-config
1397 + # thanks to ferringb for the bash voodoo
1398 + if [[ "${sapi}" == "apache2" ]]; then
1399 + sapi_list="${sapi_list:+${sapi_list} }apache2handler"
1400 + else
1401 + sapi_list="${sapi_list:+${sapi_list} }${sapi}"
1402 + fi
1403 + fi
1404 + done
1405 +
1406 + # Installing opcache module
1407 + if use opcache ; then
1408 + into "${PHP_DESTDIR#${EPREFIX}}"
1409 + dolib.so "modules/opcache$(get_libname)"
1410 + fi
1411 +
1412 + # Install env.d files
1413 + newenvd "${FILESDIR}/20php5-envd" "20php${SLOT}"
1414 + sed -e "s|/lib/|/$(get_libdir)/|g" -i "${ED}/etc/env.d/20php${SLOT}" || die
1415 + sed -e "s|php5|php${SLOT}|g" -i "${ED}/etc/env.d/20php${SLOT}" || die
1416 +
1417 + # set php-config variable correctly (bug #278439)
1418 + sed -e "s:^\(php_sapis=\)\".*\"$:\1\"${sapi_list}\":" -i \
1419 + "${ED}/usr/$(get_libdir)/php${SLOT}/bin/php-config" || die
1420 +
1421 + if use fpm ; then
1422 + if use systemd; then
1423 + systemd_newunit "${FILESDIR}/php-fpm_at.service" \
1424 + "php-fpm@${SLOT}.service"
1425 + else
1426 + systemd_newunit "${FILESDIR}/php-fpm_at-simple.service" \
1427 + "php-fpm@${SLOT}.service"
1428 + fi
1429 + fi
1430 +}
1431 +
1432 +src_test() {
1433 + echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
1434 + PHP_BIN="${WORKDIR}/sapis-build/cli/sapi/cli/php"
1435 + if [[ ! -x "${PHP_BIN}" ]] ; then
1436 + ewarn "Test phase requires USE=cli, skipping"
1437 + return
1438 + else
1439 + export TEST_PHP_EXECUTABLE="${PHP_BIN}"
1440 + fi
1441 +
1442 + if [[ -x "${WORKDIR}/sapis/cgi/php-cgi" ]] ; then
1443 + export TEST_PHP_CGI_EXECUTABLE="${WORKDIR}/sapis/cgi/php-cgi"
1444 + fi
1445 +
1446 + REPORT_EXIT_STATUS=1 "${TEST_PHP_EXECUTABLE}" -n -d \
1447 + "session.save_path=${T}" \
1448 + "${WORKDIR}/sapis-build/cli/run-tests.php" -n -q -d \
1449 + "session.save_path=${T}"
1450 +
1451 + for name in ${EXPECTED_TEST_FAILURES}; do
1452 + mv "${name}.out" "${name}.out.orig" 2>/dev/null || die
1453 + done
1454 +
1455 + local failed="$(find -name '*.out')"
1456 + if [[ ${failed} != "" ]] ; then
1457 + ewarn "The following test cases failed unexpectedly:"
1458 + for name in ${failed}; do
1459 + ewarn " ${name/.out/}"
1460 + done
1461 + else
1462 + einfo "No unexpected test failures, all fine"
1463 + fi
1464 +
1465 + if [[ ${PHP_SHOW_UNEXPECTED_TEST_PASS} == "1" ]] ; then
1466 + local passed=""
1467 + for name in ${EXPECTED_TEST_FAILURES}; do
1468 + [[ -f "${name}.diff" ]] && continue
1469 + passed="${passed} ${name}"
1470 + done
1471 + if [[ ${passed} != "" ]] ; then
1472 + einfo "The following test cases passed unexpectedly:"
1473 + for name in ${passed}; do
1474 + ewarn " ${passed}"
1475 + done
1476 + else
1477 + einfo "None of the known-to-fail tests passed, all fine"
1478 + fi
1479 + fi
1480 +}
1481 +
1482 +pkg_postinst() {
1483 + # Output some general info to the user
1484 + if use apache2 ; then
1485 + elog
1486 + elog "To enable PHP in apache, you will need to add \"-D PHP\" to"
1487 + elog "your apache2 command. OpenRC users can append that string to"
1488 + elog "APACHE2_OPTS in /etc/conf.d/apache2."
1489 + elog
1490 + elog "The apache module configuration file 70_mod_php.conf is"
1491 + elog "provided (and maintained) by eselect-php."
1492 + elog
1493 + fi
1494 +
1495 + # Create the symlinks for php
1496 + for m in ${SAPIS}; do
1497 + [[ ${m} == 'embed' ]] && continue;
1498 + if use $m ; then
1499 + local ci=$(eselect php show $m)
1500 + if [[ -z $ci ]]; then
1501 + eselect php set $m php${SLOT} || die
1502 + einfo "Switched ${m} to use php:${SLOT}"
1503 + einfo
1504 + elif [[ $ci != "php${SLOT}" ]] ; then
1505 + elog "To switch $m to use php:${SLOT}, run"
1506 + elog " eselect php set $m php${SLOT}"
1507 + elog
1508 + fi
1509 + fi
1510 + done
1511 +
1512 + # Remove dead symlinks for SAPIs that were just disabled. For
1513 + # example, if the user has the cgi SAPI enabled, then he has an
1514 + # eselect-php symlink for it. If he later reinstalls PHP with
1515 + # USE="-cgi", that symlink will break. This call to eselect is
1516 + # supposed to remove that dead link per bug 572436.
1517 + eselect php cleanup || die
1518 +
1519 + if ! has "php${SLOT/./-}" ${PHP_TARGETS}; then
1520 + elog "To build extensions for this version of PHP, you will need to"
1521 + elog "add php${SLOT/./-} to your PHP_TARGETS USE_EXPAND variable."
1522 + elog
1523 + fi
1524 +
1525 + # Only mention PHP_INI_VERSION if the user doesn't have it set.
1526 + case "${PHP_INI_VERSION}" in
1527 + production|development)
1528 + ;;
1529 + *)
1530 + elog "This ebuild installed a version of php.ini based on"
1531 + elog "${PHP_INI_UPSTREAM}. You can choose which version of"
1532 + elog "php.ini to install by default by setting PHP_INI_VERSION"
1533 + elog "to either 'production' or 'development' in your make.conf."
1534 + elog "Both versions of php.ini can be found with the PHP docs in"
1535 + elog "${EPREFIX}/usr/share/doc/${PF}"
1536 + elog
1537 + ;;
1538 + esac
1539 +
1540 + elog "For details on how version slotting works, please see"
1541 + elog "the wiki:"
1542 + elog
1543 + elog " https://wiki.gentoo.org/wiki/PHP"
1544 + elog
1545 +}
1546 +
1547 +pkg_postrm() {
1548 + # This serves two purposes. First, if we have just removed the last
1549 + # installed version of PHP, then this will remove any dead symlinks
1550 + # belonging to eselect-php. Second, if a user upgrades slots from
1551 + # (say) 5.6 to 7.0 and depcleans the old slot, then this will update
1552 + # his existing symlinks to point to the new 7.0 installation. The
1553 + # latter is bug 432962.
1554 + #
1555 + # Note: the eselect-php package may not be installed at this point,
1556 + # so we can't die() if this command fails.
1557 + eselect php cleanup
1558 +}