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