php-7.1.3-r1.ebuild 21 KB

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