* [gentoo-dev] [PATCH 0/2] New revisions of PHP extension eclasses
@ 2016-06-01 16:53 Michael Orlitzky
2016-06-01 16:53 ` [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6 Michael Orlitzky
2016-06-01 16:53 ` [gentoo-dev] [PATCH 2/2] php-ext-pecl-r3.eclass: " Michael Orlitzky
0 siblings, 2 replies; 9+ messages in thread
From: Michael Orlitzky @ 2016-06-01 16:53 UTC (permalink / raw
To: gentoo-dev
I've tried to keep these two new revisions mostly compatible with the
old ones. I performed some code cleanup, but nothing that should
affect users too badly (all updates should be trivial and make your
ebuilds smaller).
Most of the meat is in php-ext-source-r3.eclass. The other eclass simply
inherits that one. A migration guide for users can be found at,
https://wiki.gentoo.org/wiki/Project:PHP/Php-ext-source-r3_migration_guide
Michael Orlitzky (2):
php-ext-source-r3.eclass: new revision supporting EAPI=6.
php-ext-pecl-r3.eclass: new revision supporting EAPI=6.
eclass/php-ext-pecl-r3.eclass | 93 ++++++++++
eclass/php-ext-source-r3.eclass | 387 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 480 insertions(+)
create mode 100644 eclass/php-ext-pecl-r3.eclass
create mode 100644 eclass/php-ext-source-r3.eclass
--
2.7.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6.
2016-06-01 16:53 [gentoo-dev] [PATCH 0/2] New revisions of PHP extension eclasses Michael Orlitzky
@ 2016-06-01 16:53 ` Michael Orlitzky
2016-06-01 17:47 ` Michał Górny
2016-06-01 16:53 ` [gentoo-dev] [PATCH 2/2] php-ext-pecl-r3.eclass: " Michael Orlitzky
1 sibling, 1 reply; 9+ messages in thread
From: Michael Orlitzky @ 2016-06-01 16:53 UTC (permalink / raw
To: gentoo-dev
This is a new revision of the php-ext-source eclass that supports
EAPI=6 (only) and cleans up some of the existing code. The list of
user-facing changes is,
* Support only EAPI=6.
* PATCHES array/variable support.
* DOCS array support (bug 512184).
* Renamed my_conf and PHPSAPILIST variables.
Some refactoring was done, but not in a way that consumers should
notice. A migration guide can be found on the wiki:
https://wiki.gentoo.org/wiki/Project:PHP/Php-ext-source-r3_migration_guide
Gentoo-Bug: 512184
---
eclass/php-ext-source-r3.eclass | 387 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 387 insertions(+)
create mode 100644 eclass/php-ext-source-r3.eclass
diff --git a/eclass/php-ext-source-r3.eclass b/eclass/php-ext-source-r3.eclass
new file mode 100644
index 0000000..f3af823
--- /dev/null
+++ b/eclass/php-ext-source-r3.eclass
@@ -0,0 +1,387 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: php-ext-source-r3.eclass
+# @MAINTAINER:
+# Gentoo PHP team <php-bugs@gentoo.org>
+# @BLURB:
+# A unified interface for compiling and installing standalone PHP
+# extensions.
+# @DESCRIPTION:
+# A unified interface for compiling and installing standalone PHP
+# extensions.
+
+inherit autotools
+
+EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
+
+DEPEND=">=sys-devel/m4-1.4.3
+ >=sys-devel/libtool-1.5.18"
+RDEPEND=""
+
+case ${EAPI} in
+ 6) ;;
+ *)
+ die "php-ext-source-r3 is not compatible with EAPI=${EAPI}"
+esac
+
+# @ECLASS-VARIABLE: PHP_EXT_NAME
+# @REQUIRED
+# @DESCRIPTION:
+# The extension name. This must be set, otherwise the eclass dies.
+# Only automagically set by php-ext-pecl-r3.eclass, so unless your ebuild
+# inherits that eclass, you must set this manually before inherit.
+[[ -z "${PHP_EXT_NAME}" ]] && \
+ die "no extension name specified for the php-ext-source-r3 eclass"
+
+# @ECLASS-VARIABLE: PHP_EXT_INI
+# @DESCRIPTION:
+# Controls whether or not to add a line to php.ini for the extension.
+# Defaults to "yes" and should not be changed in most cases.
+[[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
+
+# @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
+# @DESCRIPTION:
+# Controls whether the extension is a ZendEngine extension or not.
+# Defaults to "no". If you don't know what this is, you don't need it.
+[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
+
+# @ECLASS-VARIABLE: USE_PHP
+# @REQUIRED
+# @DESCRIPTION:
+# Lists the PHP slots compatibile the extension is compatibile with
+# Example:
+# @CODE
+# USE_PHP="php5-6 php7-0"
+# @CODE
+[[ -z "${USE_PHP}" ]] && \
+ die "USE_PHP is not set for the php-ext-source-r3 eclass"
+
+# @ECLASS-VARIABLE: PHP_EXT_OPTIONAL_USE
+# @DESCRIPTION:
+# If set, all of the dependencies added by this eclass will be
+# conditional on USE=${PHP_EXT_OPTIONAL_USE}. This is needed when
+# ebuilds have to inherit this eclass unconditionally, but only
+# actually use it when (for example) the user has USE=php.
+
+# @ECLASS-VARIABLE: PHP_EXT_S
+# @DESCRIPTION:
+# The relative location of the temporary build directory for the PHP
+# extension within the source package. This is useful for packages that
+# bundle the PHP extension. Defaults to ${S}.
+[[ -z "${PHP_EXT_S}" ]] && PHP_EXT_S="${S}"
+
+# @ECLASS-VARIABLE: PHP_EXT_SAPIS
+# @DESCRIPTION:
+# A list of SAPIs for which we'll install this extension. Formerly
+# called PHPSAPILIST.
+[[ -z "${PHP_EXT_SAPIS}" ]] && PHP_EXT_SAPIS="apache2 cli cgi fpm embed phpdbg"
+
+
+# Make sure at least one target is installed. First, start a USE
+# conditional like "php?", but only when PHP_EXT_OPTIONAL_USE is
+# non-null. The option group "|| (..." is always started here.
+REQUIRED_USE="${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }|| ( "
+for target in ${USE_PHP}; do
+ # Now loop through each USE_PHP target and add the corresponding
+ # dev-lang/php slot to PHPDEPEND.
+ IUSE="${IUSE} php_targets_${target}"
+ # Strip "+" characters from USE_PHP???
+ # target=${target/+}
+ REQUIRED_USE+="php_targets_${target} "
+ slot=${target/php}
+ slot=${slot/-/.}
+ PHPDEPEND="${PHPDEPEND}
+ php_targets_${target}? ( dev-lang/php:${slot} )"
+done
+# Finally, end the optional group that we started before the loop. Close
+# the USE-conditional if PHP_EXT_OPTIONAL_USE is non-null.
+REQUIRED_USE+=") ${PHP_EXT_OPTIONAL_USE:+ )}"
+
+RDEPEND="${RDEPEND}
+ ${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
+ ${PHPDEPEND}
+ ${PHP_EXT_OPTIONAL_USE:+ )}"
+
+DEPEND="${DEPEND}
+ ${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
+ ${PHPDEPEND}
+ ${PHP_EXT_OPTIONAL_USE:+ )}
+"
+
+# @ECLASS-VARIABLE: PHP_EXT_SKIP_PHPIZE
+# @DESCRIPTION:
+# By default, we run "phpize" in php-ext-source-r3_src_unpack(). Set
+# PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run
+# phpize (and the autoreconf that becomes necessary afterwards).
+
+# @FUNCTION: php-ext-source-r3_src_unpack
+# @DESCRIPTION:
+# Runs the default src_unpack and then makes a copy for each PHP slot.
+php-ext-source-r3_src_unpack() {
+ default_src_unpack
+
+ local slot orig_s="${PHP_EXT_S}"
+ for slot in $(php_get_slots); do
+ cp -r "${orig_s}" "${WORKDIR}/${slot}" || \
+ die "failed to copy sources from ${orig_s} to ${WORKDIR}/${slot}"
+ done
+}
+
+
+# @FUNCTION: php-ext-source-r3_src_prepare
+# @DESCRIPTION:
+# For each PHP slot, we initialize the environment, run the default
+# src_prepare() for PATCHES/eapply_user support, and then call
+# php-ext-source-r3_phpize.
+php-ext-source-r3_src_prepare() {
+ for slot in $(php_get_slots); do
+ php_init_slot_env "${slot}"
+ default
+ php-ext-source-r3_phpize
+ done
+}
+
+# @FUNCTION: php-ext-source-r3_phpize
+# @DESCRIPTION:
+# Subject to PHP_EXT_SKIP_PHPIZE, this function runs phpize and
+# autoreconf in a manner that avoids warnings.
+php-ext-source-r3_phpize() {
+ if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
+ # Create configure out of config.m4. We use autotools_run_tool
+ # to avoid some warnings about WANT_AUTOCONF and
+ # WANT_AUTOMAKE (see bugs #329071 and #549268).
+ autotools_run_tool "${PHPIZE}"
+
+ # Force libtoolize to run and regenerate autotools files (bug
+ # #220519).
+ rm aclocal.m4 || die "failed to remove aclocal.m4"
+ eautoreconf
+ fi
+}
+
+
+# @ECLASS-VARIABLE: PHP_EXT_EXTRA_ECONF
+# @DESCRIPTION:
+# Set this in the ebuild to pass configure options to econf. Formerly
+# called my_conf.
+
+# @FUNCTION: php-ext-source-r3_src_configure
+# @DESCRIPTION:
+# Takes care of standard configure for PHP extensions (modules).
+php-ext-source-r3_src_configure() {
+ # net-snmp creates these, bug #385403.
+ addpredict /usr/share/snmp/mibs/.index
+ addpredict /var/lib/net-snmp/mib_indexes
+
+ local slot
+ for slot in $(php_get_slots); do
+ php_init_slot_env "${slot}"
+ # Set the correct config options
+ econf --with-php-config=${PHPCONFIG} ${PHP_EXT_EXTRA_ECONF}
+ done
+}
+
+# @FUNCTION: php-ext-source-r3_src_compile
+# @DESCRIPTION:
+# Compile a standard standalone PHP extension.
+php-ext-source-r3_src_compile() {
+ # net-snmp creates these, bug #324739.
+ addpredict /usr/share/snmp/mibs/.index
+ addpredict /var/lib/net-snmp/mib_indexes
+
+ # shm extension creates a semaphore file, bug #173574.
+ addpredict /session_mm_cli0.sem
+ local slot
+ for slot in $(php_get_slots); do
+ php_init_slot_env "${slot}"
+ emake
+ done
+}
+
+# @FUNCTION: php-ext-source-r3_src_install
+# @DESCRIPTION:
+# Install a standard standalone PHP extension. Uses einstalldocs()
+# to support the DOCS variable/array.
+php-ext-source-r3_src_install() {
+ local slot
+ for slot in $(php_get_slots); do
+ php_init_slot_env "${slot}"
+
+ # Let's put the default module away. Strip $EPREFIX from
+ # $EXT_DIR before calling newins (which handles EPREFIX itself).
+ insinto "${EXT_DIR#$EPREFIX}"
+ newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
+
+ INSTALL_ROOT="${D}" emake install-headers
+ done
+ einstalldocs
+ php-ext-source-r3_createinifiles
+}
+
+# @FUNCTION: php_get_slots
+# @DESCRIPTION:
+# Get a list of PHP slots contained in both the ebuild's USE_PHP and the
+# user's PHP_TARGETS.
+php_get_slots() {
+ local s=""
+ local slot
+ for slot in ${USE_PHP}; do
+ use php_targets_${slot} && s+=" ${slot/-/.}"
+ done
+ echo $s
+}
+
+# @FUNCTION: php_init_slot_env
+# @DESCRIPTION:
+# Takes a slot name, and initializes some global variables to values
+# corresponding to that slot. For example, it sets the path to the "php"
+# and "phpize" binaries, which will differ for each slot. This function
+# is intended to be called while looping through a list of slots
+# obtained from php_get_slots().
+php_init_slot_env() {
+ local libdir=$(get_libdir)
+
+ PHPIZE="${EPREFIX}/usr/${libdir}/${1}/bin/phpize"
+ PHPCONFIG="${EPREFIX}/usr/${libdir}/${1}/bin/php-config"
+ PHPCLI="${EPREFIX}/usr/${libdir}/${1}/bin/php"
+ PHPCGI="${EPREFIX}/usr/${libdir}/${1}/bin/php-cgi"
+ PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
+ PHPPREFIX="${EPREFIX}/usr/${libdir}/${slot}"
+ EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
+ PHP_CURRENTSLOT=${1:3}
+
+ PHP_EXT_S="${WORKDIR}/${1}"
+ cd "${PHP_EXT_S}" || die "failed to change directory to ${PHP_EXT_S}"
+}
+
+# @FUNCTION: php_slot_ini_files
+# @INTERNAL
+# @DESCRIPTION:
+# Output a list of relative paths to INI files for the given
+# slot. Usually there will be one INI file per SAPI.
+php_slot_ini_files() {
+ local slot_ini_files=""
+ local x
+ for x in ${PHP_EXT_SAPIS} ; do
+ if [[ -f "${EPREFIX}/etc/php/${x}-${1}/php.ini" ]] ; then
+ slot_ini_files+=" etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
+ fi
+ done
+
+ echo "${slot_ini_files}"
+}
+
+# @FUNCTION: php-ext-source-r3_createinifiles
+# @DESCRIPTION:
+# Builds INI files for every enabled slot and SAPI.
+php-ext-source-r3_createinifiles() {
+ local slot
+ for slot in $(php_get_slots); do
+ php_init_slot_env "${slot}"
+
+ local file
+ for file in $(php_slot_ini_files "${slot}") ; do
+ if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
+ # Add the needed lines to the <ext>.ini files
+ php-ext-source-r3_addextension "${PHP_EXT_NAME}.so" "${file}"
+ fi
+
+ if [[ -n "${PHP_EXT_INIFILE}" ]] ; then
+ cat "${FILESDIR}/${PHP_EXT_INIFILE}" >> "${ED}/${file}"
+ einfo "Added contents of ${FILESDIR}/${PHP_EXT_INIFILE}" \
+ "to ${file}"
+ fi
+ inidir="${file/${PHP_EXT_NAME}.ini/}"
+ inidir="${inidir/ext/ext-active}"
+ dodir "/${inidir}"
+ dosym "/${file}" "/${file/ext/ext-active}"
+ done
+
+ # Add support for installing PHP files into a version dependent
+ # directory
+ PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}"
+ done
+}
+
+# @FUNCTION: php-ext-source-r3_addextension
+# @INTERNAL
+# @DESCRIPTION:
+# Add a line to an INI file that will enable the given extension. The
+# first parameter is the path to the extension (.so) file, and the
+# second parameter is the name of the INI file in which it should be
+# loaded. This function determines the setting name (either
+# "extension=..." or "zend_extension=...") and then calls
+# php-ext-source-r3_addtoinifile to do the actual work.
+php-ext-source-r3_addextension() {
+ if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
+ ext_type="zend_extension"
+ ext_file="${EXT_DIR}/${1}" # Zend extensions need the path...
+ else
+ ext_type="extension"
+ ext_file="${1}"
+ fi
+
+ php-ext-source-r3_addtoinifile "${2}" "${ext_type}" "${ext_file}"
+}
+
+# @FUNCTION: php-ext-source-r3_addtoinifile
+# @INTERNAL
+# @DESCRIPTION:
+# Add a setting=value to one INI file. The first argument is the
+# relative path to the INI file. The second argument is the setting
+# name, and the third argument is its value.
+#
+# You can also pass "[Section]" as the first parameter, to create a new
+# section in the INI file. In that case, the second parameter (which
+# would otherwise be the value of the setting) is ignored.
+php-ext-source-r3_addtoinifile() {
+ local inifile="${WORKDIR}/${1}"
+ local inidir="$(dirname ${inifile})"
+ if [[ ! -d "${inidir}" ]] ; then
+ mkdir -p "${inidir}" || die "failed to create INI directory ${inidir}"
+ fi
+
+ # Are we adding the name of a section?
+ if [[ ${2:0:1} == "[" ]] ; then
+ echo "${2}" >> "${inifile}"
+ my_added="${2}"
+ else
+ echo "${2}=${3}" >> "${inifile}"
+ my_added="${2}=${3}"
+ fi
+
+ einfo "Added '${my_added}' to /${1}"
+
+ insinto /$(dirname "${1}")
+ doins "${inifile}"
+}
+
+# @FUNCTION: php-ext-source-r3_addtoinifiles
+# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
+# @DESCRIPTION:
+# Add settings to every php.ini file installed by this extension.
+# You can also add new [Section]s -- see the example below.
+#
+# @CODE
+# Add some settings for the extension:
+#
+# php-ext-source-r3_addtoinifiles "zend_optimizer.optimization_level" "15"
+# php-ext-source-r3_addtoinifiles "zend_optimizer.enable_loader" "0"
+# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0"
+#
+# Adding values to a section in php.ini file installed by the extension:
+#
+# php-ext-source-r3_addtoinifiles "[Debugger]"
+# php-ext-source-r3_addtoinifiles "debugger.enabled" "on"
+# php-ext-source-r3_addtoinifiles "debugger.profiler_enabled" "on"
+# @CODE
+php-ext-source-r3_addtoinifiles() {
+ local slot
+ for slot in $(php_get_slots); do
+ for file in $(php_slot_ini_files "${slot}") ; do
+ php-ext-source-r3_addtoinifile "${file}" "${1}" "${2}"
+ done
+ done
+}
--
2.7.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-dev] [PATCH 2/2] php-ext-pecl-r3.eclass: new revision supporting EAPI=6.
2016-06-01 16:53 [gentoo-dev] [PATCH 0/2] New revisions of PHP extension eclasses Michael Orlitzky
2016-06-01 16:53 ` [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6 Michael Orlitzky
@ 2016-06-01 16:53 ` Michael Orlitzky
2016-06-01 17:53 ` Michał Górny
1 sibling, 1 reply; 9+ messages in thread
From: Michael Orlitzky @ 2016-06-01 16:53 UTC (permalink / raw
To: gentoo-dev
The php-ext-pecl eclasses are based mainly on the php-ext-source
eclasses. Now that we have a new revision php-ext-source-r3.eclass,
this new revision of php-ext-pecl inherits that. As a result, all of
the changes affecting that revision also affect this one. A migration
guide for users can be found on the wiki:
https://wiki.gentoo.org/wiki/Project:PHP/Php-ext-source-r3_migration_guide
Gentoo-Bug: 512184
---
eclass/php-ext-pecl-r3.eclass | 93 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
create mode 100644 eclass/php-ext-pecl-r3.eclass
diff --git a/eclass/php-ext-pecl-r3.eclass b/eclass/php-ext-pecl-r3.eclass
new file mode 100644
index 0000000..bd9c622
--- /dev/null
+++ b/eclass/php-ext-pecl-r3.eclass
@@ -0,0 +1,93 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: php-ext-pecl-r3.eclass
+# @MAINTAINER:
+# Gentoo PHP team <php-bugs@gentoo.org>
+# @BLURB: A uniform way to install PECL extensions
+# @DESCRIPTION:
+# This eclass should be used by all dev-php/pecl-* ebuilds as a uniform
+# way of installing PECL extensions. For more information about PECL,
+# see http://pecl.php.net/
+
+# @ECLASS-VARIABLE: PHP_EXT_PECL_PKG
+# @DESCRIPTION:
+# Set in ebuild before inheriting this eclass if the tarball name
+# differs from ${PN/pecl-/} so that SRC_URI and HOMEPAGE get set
+# correctly by the eclass.
+#
+# Setting this variable manually also affects PHP_EXT_NAME and ${S}
+# unless you override those in ebuild. If that is not desired, please
+# use PHP_EXT_PECL_FILENAME instead.
+[[ -z "${PHP_EXT_PECL_PKG}" ]] && PHP_EXT_PECL_PKG="${PN/pecl-/}"
+
+# @ECLASS-VARIABLE: PHP_EXT_PECL_FILENAME
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Set in ebuild before inheriting this eclass if the tarball name
+# differs from ${PN/pecl-/} so that SRC_URI gets set correctly by
+# the eclass.
+#
+# Unlike PHP_EXT_PECL_PKG, setting this variable does not affect
+# HOMEPAGE, PHP_EXT_NAME or ${S}.
+
+
+[[ -z ${MY_PV} ]] && MY_PV=${PV}
+PECL_PKG="${PHP_EXT_PECL_PKG}"
+MY_PV="${MY_PV/_/}"
+PECL_PKG_V="${PECL_PKG}-${MY_PV}"
+
+# Set PHP_EXT_NAME for php-ext-source-r3.eclass.
+[[ -z "${PHP_EXT_NAME}" ]] && PHP_EXT_NAME="${PECL_PKG}"
+
+S="${WORKDIR}/${PECL_PKG_V}"
+
+inherit php-ext-source-r3
+
+EXPORT_FUNCTIONS src_compile src_install src_test
+
+FILENAME="${PECL_PKG_V}.tgz"
+if [[ -n "${PHP_EXT_PECL_FILENAME}" ]] ; then
+ FILENAME="${PHP_EXT_PECL_FILENAME}-${MY_PV}.tgz"
+fi
+
+SRC_URI="http://pecl.php.net/get/${FILENAME}"
+HOMEPAGE="http://pecl.php.net/${PECL_PKG}"
+
+
+# @FUNCTION: php-ext-pecl-r3_src_compile
+# @DESCRIPTION:
+# Compile a standard PECL package. The process is the same as for any
+# standalone PHP extension, so we delegate to php-ext-source-r3.eclass.
+php-ext-pecl-r3_src_compile() {
+ php-ext-source-r3_src_compile
+}
+
+
+# @FUNCTION: php-ext-pecl-r3_src_install
+# @DESCRIPTION:
+# Install a standard PECL package. First we delegate to
+# php-ext-source-r3.eclass, and then we attempt to install examples
+# found in a standard location.
+php-ext-pecl-r3_src_install() {
+ php-ext-source-r3_src_install
+
+ if has examples ${IUSE} && use examples ; then
+ dodoc -r examples
+ fi
+}
+
+
+# @FUNCTION: php-ext-pecl-r3_src_test
+# @DESCRIPTION:
+# Run tests delivered with the PECL package. Phpize will have generated
+# a run-tests.php file to be executed by `make test`. We only need to
+# force the test suite to run in non-interactive mode.
+php-ext-pecl-r3_src_test() {
+ for slot in $(php_get_slots); do
+ php_init_slot_env "${slot}"
+ NO_INTERACTION="yes" emake test || \
+ die "emake test failed for slot ${slot}"
+ done
+}
--
2.7.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6.
2016-06-01 16:53 ` [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6 Michael Orlitzky
@ 2016-06-01 17:47 ` Michał Górny
2016-06-02 12:27 ` Michael Orlitzky
0 siblings, 1 reply; 9+ messages in thread
From: Michał Górny @ 2016-06-01 17:47 UTC (permalink / raw
To: Michael Orlitzky; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 16339 bytes --]
On Wed, 1 Jun 2016 12:53:37 -0400
Michael Orlitzky <mjo@gentoo.org> wrote:
> This is a new revision of the php-ext-source eclass that supports
> EAPI=6 (only) and cleans up some of the existing code. The list of
> user-facing changes is,
>
> * Support only EAPI=6.
>
> * PATCHES array/variable support.
>
> * DOCS array support (bug 512184).
>
> * Renamed my_conf and PHPSAPILIST variables.
>
> Some refactoring was done, but not in a way that consumers should
> notice. A migration guide can be found on the wiki:
>
> https://wiki.gentoo.org/wiki/Project:PHP/Php-ext-source-r3_migration_guide
>
> Gentoo-Bug: 512184
> ---
> eclass/php-ext-source-r3.eclass | 387 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 387 insertions(+)
> create mode 100644 eclass/php-ext-source-r3.eclass
>
> diff --git a/eclass/php-ext-source-r3.eclass b/eclass/php-ext-source-r3.eclass
> new file mode 100644
> index 0000000..f3af823
> --- /dev/null
> +++ b/eclass/php-ext-source-r3.eclass
> @@ -0,0 +1,387 @@
> +# Copyright 1999-2016 Gentoo Foundation
> +# Distributed under the terms of the GNU General Public License v2
> +# $Id$
> +
> +# @ECLASS: php-ext-source-r3.eclass
> +# @MAINTAINER:
> +# Gentoo PHP team <php-bugs@gentoo.org>
> +# @BLURB:
> +# A unified interface for compiling and installing standalone PHP
> +# extensions.
> +# @DESCRIPTION:
> +# A unified interface for compiling and installing standalone PHP
> +# extensions.
> +
> +inherit autotools
> +
> +EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
> +
> +DEPEND=">=sys-devel/m4-1.4.3
> + >=sys-devel/libtool-1.5.18"
> +RDEPEND=""
Please move all of this below EAPI check. And I think *DEPEND would be
better set in one place.
> +
> +case ${EAPI} in
> + 6) ;;
> + *)
> + die "php-ext-source-r3 is not compatible with EAPI=${EAPI}"
I think you can use ${ECLASS} here btw.
> +esac
> +
> +# @ECLASS-VARIABLE: PHP_EXT_NAME
> +# @REQUIRED
> +# @DESCRIPTION:
> +# The extension name. This must be set, otherwise the eclass dies.
> +# Only automagically set by php-ext-pecl-r3.eclass, so unless your ebuild
> +# inherits that eclass, you must set this manually before inherit.
> +[[ -z "${PHP_EXT_NAME}" ]] && \
> + die "no extension name specified for the php-ext-source-r3 eclass"
> +
> +# @ECLASS-VARIABLE: PHP_EXT_INI
> +# @DESCRIPTION:
> +# Controls whether or not to add a line to php.ini for the extension.
> +# Defaults to "yes" and should not be changed in most cases.
> +[[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
> +
> +# @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
> +# @DESCRIPTION:
> +# Controls whether the extension is a ZendEngine extension or not.
> +# Defaults to "no". If you don't know what this is, you don't need it.
> +[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
> +
> +# @ECLASS-VARIABLE: USE_PHP
> +# @REQUIRED
> +# @DESCRIPTION:
> +# Lists the PHP slots compatibile the extension is compatibile with
typo: compatible, and also appears twice ;-).
> +# Example:
> +# @CODE
> +# USE_PHP="php5-6 php7-0"
> +# @CODE
> +[[ -z "${USE_PHP}" ]] && \
> + die "USE_PHP is not set for the php-ext-source-r3 eclass"
> +
> +# @ECLASS-VARIABLE: PHP_EXT_OPTIONAL_USE
> +# @DESCRIPTION:
> +# If set, all of the dependencies added by this eclass will be
> +# conditional on USE=${PHP_EXT_OPTIONAL_USE}. This is needed when
> +# ebuilds have to inherit this eclass unconditionally, but only
> +# actually use it when (for example) the user has USE=php.
> +
> +# @ECLASS-VARIABLE: PHP_EXT_S
> +# @DESCRIPTION:
> +# The relative location of the temporary build directory for the PHP
> +# extension within the source package. This is useful for packages that
> +# bundle the PHP extension. Defaults to ${S}.
> +[[ -z "${PHP_EXT_S}" ]] && PHP_EXT_S="${S}"
> +
> +# @ECLASS-VARIABLE: PHP_EXT_SAPIS
> +# @DESCRIPTION:
> +# A list of SAPIs for which we'll install this extension. Formerly
> +# called PHPSAPILIST.
> +[[ -z "${PHP_EXT_SAPIS}" ]] && PHP_EXT_SAPIS="apache2 cli cgi fpm embed phpdbg"
Is this default something that might get extended in the future? I
think it might be worth noting that here.
> +
> +
> +# Make sure at least one target is installed. First, start a USE
> +# conditional like "php?", but only when PHP_EXT_OPTIONAL_USE is
> +# non-null. The option group "|| (..." is always started here.
> +REQUIRED_USE="${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }|| ( "
> +for target in ${USE_PHP}; do
Environment pollution! unset target, or make this local.
> + # Now loop through each USE_PHP target and add the corresponding
> + # dev-lang/php slot to PHPDEPEND.
> + IUSE="${IUSE} php_targets_${target}"
Any reason not to use += here as well?
> + # Strip "+" characters from USE_PHP???
> + # target=${target/+}
> + REQUIRED_USE+="php_targets_${target} "
> + slot=${target/php}
> + slot=${slot/-/.}
> + PHPDEPEND="${PHPDEPEND}
> + php_targets_${target}? ( dev-lang/php:${slot} )"
> +done
> +# Finally, end the optional group that we started before the loop. Close
> +# the USE-conditional if PHP_EXT_OPTIONAL_USE is non-null.
> +REQUIRED_USE+=") ${PHP_EXT_OPTIONAL_USE:+ )}"
> +
> +RDEPEND="${RDEPEND}
> + ${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
> + ${PHPDEPEND}
> + ${PHP_EXT_OPTIONAL_USE:+ )}"
> +
> +DEPEND="${DEPEND}
> + ${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
> + ${PHPDEPEND}
> + ${PHP_EXT_OPTIONAL_USE:+ )}
> +"
> +
> +# @ECLASS-VARIABLE: PHP_EXT_SKIP_PHPIZE
> +# @DESCRIPTION:
> +# By default, we run "phpize" in php-ext-source-r3_src_unpack(). Set
> +# PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run
> +# phpize (and the autoreconf that becomes necessary afterwards).
> +
> +# @FUNCTION: php-ext-source-r3_src_unpack
> +# @DESCRIPTION:
> +# Runs the default src_unpack and then makes a copy for each PHP slot.
> +php-ext-source-r3_src_unpack() {
> + default_src_unpack
> +
> + local slot orig_s="${PHP_EXT_S}"
> + for slot in $(php_get_slots); do
> + cp -r "${orig_s}" "${WORKDIR}/${slot}" || \
> + die "failed to copy sources from ${orig_s} to ${WORKDIR}/${slot}"
> + done
> +}
> +
> +
> +# @FUNCTION: php-ext-source-r3_src_prepare
> +# @DESCRIPTION:
> +# For each PHP slot, we initialize the environment, run the default
> +# src_prepare() for PATCHES/eapply_user support, and then call
> +# php-ext-source-r3_phpize.
> +php-ext-source-r3_src_prepare() {
> + for slot in $(php_get_slots); do
> + php_init_slot_env "${slot}"
> + default
> + php-ext-source-r3_phpize
> + done
> +}
> +
> +# @FUNCTION: php-ext-source-r3_phpize
> +# @DESCRIPTION:
> +# Subject to PHP_EXT_SKIP_PHPIZE, this function runs phpize and
> +# autoreconf in a manner that avoids warnings.
> +php-ext-source-r3_phpize() {
> + if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
> + # Create configure out of config.m4. We use autotools_run_tool
> + # to avoid some warnings about WANT_AUTOCONF and
> + # WANT_AUTOMAKE (see bugs #329071 and #549268).
> + autotools_run_tool "${PHPIZE}"
> +
> + # Force libtoolize to run and regenerate autotools files (bug
> + # #220519).
> + rm aclocal.m4 || die "failed to remove aclocal.m4"
> + eautoreconf
> + fi
> +}
> +
> +
> +# @ECLASS-VARIABLE: PHP_EXT_EXTRA_ECONF
> +# @DESCRIPTION:
> +# Set this in the ebuild to pass configure options to econf. Formerly
> +# called my_conf.
Please don't name this *EXTRA_ECONF. EXTRA_ECONF is a Portage variable
that's meant to be set by user in make.conf/env, and not ebuilds.
> +# @FUNCTION: php-ext-source-r3_src_configure
> +# @DESCRIPTION:
> +# Takes care of standard configure for PHP extensions (modules).
> +php-ext-source-r3_src_configure() {
> + # net-snmp creates these, bug #385403.
> + addpredict /usr/share/snmp/mibs/.index
> + addpredict /var/lib/net-snmp/mib_indexes
> +
> + local slot
> + for slot in $(php_get_slots); do
> + php_init_slot_env "${slot}"
> + # Set the correct config options
> + econf --with-php-config=${PHPCONFIG} ${PHP_EXT_EXTRA_ECONF}
> + done
> +}
> +
> +# @FUNCTION: php-ext-source-r3_src_compile
> +# @DESCRIPTION:
> +# Compile a standard standalone PHP extension.
> +php-ext-source-r3_src_compile() {
> + # net-snmp creates these, bug #324739.
> + addpredict /usr/share/snmp/mibs/.index
> + addpredict /var/lib/net-snmp/mib_indexes
> +
> + # shm extension creates a semaphore file, bug #173574.
> + addpredict /session_mm_cli0.sem
> + local slot
> + for slot in $(php_get_slots); do
> + php_init_slot_env "${slot}"
> + emake
> + done
> +}
> +
> +# @FUNCTION: php-ext-source-r3_src_install
> +# @DESCRIPTION:
> +# Install a standard standalone PHP extension. Uses einstalldocs()
> +# to support the DOCS variable/array.
> +php-ext-source-r3_src_install() {
> + local slot
> + for slot in $(php_get_slots); do
> + php_init_slot_env "${slot}"
> +
> + # Let's put the default module away. Strip $EPREFIX from
> + # $EXT_DIR before calling newins (which handles EPREFIX itself).
> + insinto "${EXT_DIR#$EPREFIX}"
> + newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
Wouldn't it be more appropriate to use exeinto/doexe to have the shared
libs +x?
> +
> + INSTALL_ROOT="${D}" emake install-headers
> + done
> + einstalldocs
> + php-ext-source-r3_createinifiles
> +}
> +
> +# @FUNCTION: php_get_slots
> +# @DESCRIPTION:
> +# Get a list of PHP slots contained in both the ebuild's USE_PHP and the
> +# user's PHP_TARGETS.
> +php_get_slots() {
> + local s=""
> + local slot
> + for slot in ${USE_PHP}; do
> + use php_targets_${slot} && s+=" ${slot/-/.}"
> + done
> + echo $s
> +}
> +
> +# @FUNCTION: php_init_slot_env
> +# @DESCRIPTION:
> +# Takes a slot name, and initializes some global variables to values
> +# corresponding to that slot. For example, it sets the path to the "php"
> +# and "phpize" binaries, which will differ for each slot. This function
> +# is intended to be called while looping through a list of slots
> +# obtained from php_get_slots().
Please make it explicit that it changes working directory.
> +php_init_slot_env() {
> + local libdir=$(get_libdir)
> +
> + PHPIZE="${EPREFIX}/usr/${libdir}/${1}/bin/phpize"
> + PHPCONFIG="${EPREFIX}/usr/${libdir}/${1}/bin/php-config"
> + PHPCLI="${EPREFIX}/usr/${libdir}/${1}/bin/php"
> + PHPCGI="${EPREFIX}/usr/${libdir}/${1}/bin/php-cgi"
> + PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
> + PHPPREFIX="${EPREFIX}/usr/${libdir}/${slot}"
> + EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
> + PHP_CURRENTSLOT=${1:3}
> +
> + PHP_EXT_S="${WORKDIR}/${1}"
> + cd "${PHP_EXT_S}" || die "failed to change directory to ${PHP_EXT_S}"
> +}
> +
> +# @FUNCTION: php_slot_ini_files
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Output a list of relative paths to INI files for the given
> +# slot. Usually there will be one INI file per SAPI.
Please add @USAGE to make clear what ${1} is. In fact, many functions
seem to miss @USAGE.
> +php_slot_ini_files() {
> + local slot_ini_files=""
> + local x
> + for x in ${PHP_EXT_SAPIS} ; do
> + if [[ -f "${EPREFIX}/etc/php/${x}-${1}/php.ini" ]] ; then
> + slot_ini_files+=" etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
> + fi
> + done
> +
> + echo "${slot_ini_files}"
> +}
> +
> +# @FUNCTION: php-ext-source-r3_createinifiles
> +# @DESCRIPTION:
> +# Builds INI files for every enabled slot and SAPI.
> +php-ext-source-r3_createinifiles() {
> + local slot
> + for slot in $(php_get_slots); do
> + php_init_slot_env "${slot}"
> +
> + local file
> + for file in $(php_slot_ini_files "${slot}") ; do
> + if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
> + # Add the needed lines to the <ext>.ini files
> + php-ext-source-r3_addextension "${PHP_EXT_NAME}.so" "${file}"
> + fi
> +
> + if [[ -n "${PHP_EXT_INIFILE}" ]] ; then
> + cat "${FILESDIR}/${PHP_EXT_INIFILE}" >> "${ED}/${file}"
|| die
> + einfo "Added contents of ${FILESDIR}/${PHP_EXT_INIFILE}" \
> + "to ${file}"
> + fi
> + inidir="${file/${PHP_EXT_NAME}.ini/}"
> + inidir="${inidir/ext/ext-active}"
> + dodir "/${inidir}"
> + dosym "/${file}" "/${file/ext/ext-active}"
> + done
> +
> + # Add support for installing PHP files into a version dependent
> + # directory
> + PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}"
Should this be repeated inside the loop?
> + done
> +}
> +
> +# @FUNCTION: php-ext-source-r3_addextension
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Add a line to an INI file that will enable the given extension. The
> +# first parameter is the path to the extension (.so) file, and the
> +# second parameter is the name of the INI file in which it should be
> +# loaded. This function determines the setting name (either
> +# "extension=..." or "zend_extension=...") and then calls
> +# php-ext-source-r3_addtoinifile to do the actual work.
> +php-ext-source-r3_addextension() {
> + if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
> + ext_type="zend_extension"
> + ext_file="${EXT_DIR}/${1}" # Zend extensions need the path...
> + else
> + ext_type="extension"
> + ext_file="${1}"
> + fi
I think you want those variables local.
> +
> + php-ext-source-r3_addtoinifile "${2}" "${ext_type}" "${ext_file}"
> +}
> +
> +# @FUNCTION: php-ext-source-r3_addtoinifile
> +# @INTERNAL
> +# @DESCRIPTION:
> +# Add a setting=value to one INI file. The first argument is the
> +# relative path to the INI file. The second argument is the setting
> +# name, and the third argument is its value.
> +#
> +# You can also pass "[Section]" as the first parameter, to create a new
> +# section in the INI file. In that case, the second parameter (which
> +# would otherwise be the value of the setting) is ignored.
> +php-ext-source-r3_addtoinifile() {
> + local inifile="${WORKDIR}/${1}"
> + local inidir="$(dirname ${inifile})"
I would suggest avoiding external tools like dirname when simple bash
subst can do the work (e.g. ${inifile%/*}).
> + if [[ ! -d "${inidir}" ]] ; then
> + mkdir -p "${inidir}" || die "failed to create INI directory ${inidir}"
'mkdir -p' is safe to call when the directory exists, so I don't think
you need the conditional.
> + fi
> +
> + # Are we adding the name of a section?
> + if [[ ${2:0:1} == "[" ]] ; then
> + echo "${2}" >> "${inifile}"
|| die
> + my_added="${2}"
Again, missing local.
> + else
> + echo "${2}=${3}" >> "${inifile}"
|| die
> + my_added="${2}=${3}"
> + fi
All above considered, wouldn't it be simpler to set my_added first,
and then just echo it to the file outside the conditional?
> +
> + einfo "Added '${my_added}' to /${1}"
> +
> + insinto /$(dirname "${1}")
> + doins "${inifile}"
> +}
> +
> +# @FUNCTION: php-ext-source-r3_addtoinifiles
> +# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
I think you are mixing '[]' meaning optional and meaning literal '[]'
here.
> +# @DESCRIPTION:
> +# Add settings to every php.ini file installed by this extension.
> +# You can also add new [Section]s -- see the example below.
> +#
> +# @CODE
> +# Add some settings for the extension:
> +#
> +# php-ext-source-r3_addtoinifiles "zend_optimizer.optimization_level" "15"
> +# php-ext-source-r3_addtoinifiles "zend_optimizer.enable_loader" "0"
> +# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0"
Hmm... just to make it clear... is there any reason you use two
arguments instead of the more obvious 'foo=15'?
> +#
> +# Adding values to a section in php.ini file installed by the extension:
> +#
> +# php-ext-source-r3_addtoinifiles "[Debugger]"
> +# php-ext-source-r3_addtoinifiles "debugger.enabled" "on"
> +# php-ext-source-r3_addtoinifiles "debugger.profiler_enabled" "on"
> +# @CODE
> +php-ext-source-r3_addtoinifiles() {
> + local slot
> + for slot in $(php_get_slots); do
> + for file in $(php_slot_ini_files "${slot}") ; do
> + php-ext-source-r3_addtoinifile "${file}" "${1}" "${2}"
> + done
> + done
> +}
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [PATCH 2/2] php-ext-pecl-r3.eclass: new revision supporting EAPI=6.
2016-06-01 16:53 ` [gentoo-dev] [PATCH 2/2] php-ext-pecl-r3.eclass: " Michael Orlitzky
@ 2016-06-01 17:53 ` Michał Górny
2016-06-01 21:19 ` Michael Orlitzky
0 siblings, 1 reply; 9+ messages in thread
From: Michał Górny @ 2016-06-01 17:53 UTC (permalink / raw
To: Michael Orlitzky; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 4561 bytes --]
On Wed, 1 Jun 2016 12:53:38 -0400
Michael Orlitzky <mjo@gentoo.org> wrote:
> The php-ext-pecl eclasses are based mainly on the php-ext-source
> eclasses. Now that we have a new revision php-ext-source-r3.eclass,
> this new revision of php-ext-pecl inherits that. As a result, all of
> the changes affecting that revision also affect this one. A migration
> guide for users can be found on the wiki:
>
> https://wiki.gentoo.org/wiki/Project:PHP/Php-ext-source-r3_migration_guide
>
> Gentoo-Bug: 512184
> ---
> eclass/php-ext-pecl-r3.eclass | 93 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 93 insertions(+)
> create mode 100644 eclass/php-ext-pecl-r3.eclass
>
> diff --git a/eclass/php-ext-pecl-r3.eclass b/eclass/php-ext-pecl-r3.eclass
> new file mode 100644
> index 0000000..bd9c622
> --- /dev/null
> +++ b/eclass/php-ext-pecl-r3.eclass
> @@ -0,0 +1,93 @@
> +# Copyright 1999-2016 Gentoo Foundation
> +# Distributed under the terms of the GNU General Public License v2
> +# $Id$
> +
> +# @ECLASS: php-ext-pecl-r3.eclass
> +# @MAINTAINER:
> +# Gentoo PHP team <php-bugs@gentoo.org>
> +# @BLURB: A uniform way to install PECL extensions
> +# @DESCRIPTION:
> +# This eclass should be used by all dev-php/pecl-* ebuilds as a uniform
> +# way of installing PECL extensions. For more information about PECL,
> +# see http://pecl.php.net/
> +
> +# @ECLASS-VARIABLE: PHP_EXT_PECL_PKG
> +# @DESCRIPTION:
> +# Set in ebuild before inheriting this eclass if the tarball name
> +# differs from ${PN/pecl-/} so that SRC_URI and HOMEPAGE get set
> +# correctly by the eclass.
> +#
> +# Setting this variable manually also affects PHP_EXT_NAME and ${S}
> +# unless you override those in ebuild. If that is not desired, please
> +# use PHP_EXT_PECL_FILENAME instead.
> +[[ -z "${PHP_EXT_PECL_PKG}" ]] && PHP_EXT_PECL_PKG="${PN/pecl-/}"
> +
> +# @ECLASS-VARIABLE: PHP_EXT_PECL_FILENAME
> +# @DEFAULT_UNSET
> +# @DESCRIPTION:
> +# Set in ebuild before inheriting this eclass if the tarball name
> +# differs from ${PN/pecl-/} so that SRC_URI gets set correctly by
> +# the eclass.
> +#
> +# Unlike PHP_EXT_PECL_PKG, setting this variable does not affect
> +# HOMEPAGE, PHP_EXT_NAME or ${S}.
> +
> +
> +[[ -z ${MY_PV} ]] && MY_PV=${PV}
Is MY_PV part of the API? If yes, document it, and preferably rename
into something more collision-proof. If not, you shouldn't be doing
[[ -z ...
> +PECL_PKG="${PHP_EXT_PECL_PKG}"
> +MY_PV="${MY_PV/_/}"
> +PECL_PKG_V="${PECL_PKG}-${MY_PV}"
If exported as part of the API, please document it. Otherwise, remember
to unset it after use.
> +
> +# Set PHP_EXT_NAME for php-ext-source-r3.eclass.
> +[[ -z "${PHP_EXT_NAME}" ]] && PHP_EXT_NAME="${PECL_PKG}"
> +
> +S="${WORKDIR}/${PECL_PKG_V}"
> +
> +inherit php-ext-source-r3
> +
> +EXPORT_FUNCTIONS src_compile src_install src_test
> +
> +FILENAME="${PECL_PKG_V}.tgz"
> +if [[ -n "${PHP_EXT_PECL_FILENAME}" ]] ; then
> + FILENAME="${PHP_EXT_PECL_FILENAME}-${MY_PV}.tgz"
> +fi
> +
> +SRC_URI="http://pecl.php.net/get/${FILENAME}"
> +HOMEPAGE="http://pecl.php.net/${PECL_PKG}"
> +
> +
> +# @FUNCTION: php-ext-pecl-r3_src_compile
> +# @DESCRIPTION:
> +# Compile a standard PECL package. The process is the same as for any
> +# standalone PHP extension, so we delegate to php-ext-source-r3.eclass.
> +php-ext-pecl-r3_src_compile() {
> + php-ext-source-r3_src_compile
> +}
Any reason to re-export it?
> +# @FUNCTION: php-ext-pecl-r3_src_install
> +# @DESCRIPTION:
> +# Install a standard PECL package. First we delegate to
> +# php-ext-source-r3.eclass, and then we attempt to install examples
> +# found in a standard location.
> +php-ext-pecl-r3_src_install() {
> + php-ext-source-r3_src_install
> +
> + if has examples ${IUSE} && use examples ; then
This is prohibited. Use in_iuse.
> + dodoc -r examples
> + fi
> +}
> +
> +
> +# @FUNCTION: php-ext-pecl-r3_src_test
> +# @DESCRIPTION:
> +# Run tests delivered with the PECL package. Phpize will have generated
> +# a run-tests.php file to be executed by `make test`. We only need to
> +# force the test suite to run in non-interactive mode.
> +php-ext-pecl-r3_src_test() {
> + for slot in $(php_get_slots); do
> + php_init_slot_env "${slot}"
> + NO_INTERACTION="yes" emake test || \
> + die "emake test failed for slot ${slot}"
emake dies in this EAPI, so your die will never be called.
> + done
> +}
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [PATCH 2/2] php-ext-pecl-r3.eclass: new revision supporting EAPI=6.
2016-06-01 17:53 ` Michał Górny
@ 2016-06-01 21:19 ` Michael Orlitzky
0 siblings, 0 replies; 9+ messages in thread
From: Michael Orlitzky @ 2016-06-01 21:19 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]
I'll start with the easy one first. A new version is attached.
On 06/01/2016 01:53 PM, Michał Górny wrote:
>> +
>> +[[ -z ${MY_PV} ]] && MY_PV=${PV}
>
> Is MY_PV part of the API? If yes, document it, and preferably rename
> into something more collision-proof. If not, you shouldn't be doing
> [[ -z ...
>
Uhhhh I don't think so. It's probably leaking through from some ebuilds,
but I just documented that you're going to have to fix that on the wiki
page and made the eclass ignore it.
As part of a greater campaign for sanity, I'm also requiring that the
PHP_EXT_PECL_FILENAME variable contain a file name. Previously we had
something like SRC_URI="...${PHP_EXT_PECL_FILENAME}-${MY_PV}.tgz".
>> +PECL_PKG="${PHP_EXT_PECL_PKG}"
>> +MY_PV="${MY_PV/_/}"
>> +PECL_PKG_V="${PECL_PKG}-${MY_PV}"
>
> If exported as part of the API, please document it. Otherwise, remember
> to unset it after use.
>
After the MY_PV fix, I still had one undocumented variable laying around
in global scope. I mangled the name for safety, and unset it after use.
>> +
>> +# @FUNCTION: php-ext-pecl-r3_src_compile
>> +# @DESCRIPTION:
>> +# Compile a standard PECL package. The process is the same as for any
>> +# standalone PHP extension, so we delegate to php-ext-source-r3.eclass.
>> +php-ext-pecl-r3_src_compile() {
>> + php-ext-source-r3_src_compile
>> +}
>
> Any reason to re-export it?
>
Because -r2 did =P
It's fixed.
>> +
>> + if has examples ${IUSE} && use examples ; then
>
> This is prohibited. Use in_iuse.
>
Thanks, fixed.
>> + NO_INTERACTION="yes" emake test || \
>> + die "emake test failed for slot ${slot}"
>
> emake dies in this EAPI, so your die will never be called.
>
This too, thanks.
[-- Attachment #2: php-ext-pecl-r3.eclass --]
[-- Type: text/plain, Size: 2734 bytes --]
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
# @ECLASS: php-ext-pecl-r3.eclass
# @MAINTAINER:
# Gentoo PHP team <php-bugs@gentoo.org>
# @BLURB: A uniform way to install PECL extensions
# @DESCRIPTION:
# This eclass should be used by all dev-php/pecl-* ebuilds as a uniform
# way of installing PECL extensions. For more information about PECL,
# see http://pecl.php.net/
# @ECLASS-VARIABLE: PHP_EXT_PECL_PKG
# @DESCRIPTION:
# Set in ebuild before inheriting this eclass if the tarball name
# differs from ${PN/pecl-/} so that SRC_URI and HOMEPAGE get set
# correctly by the eclass.
#
# Setting this variable manually also affects PHP_EXT_NAME and ${S}
# unless you override those in ebuild. If that is not desired, please
# use PHP_EXT_PECL_FILENAME instead.
[[ -z "${PHP_EXT_PECL_PKG}" ]] && PHP_EXT_PECL_PKG="${PN/pecl-/}"
# @ECLASS-VARIABLE: PHP_EXT_PECL_FILENAME
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set in ebuild before inheriting this eclass if the tarball name
# differs from "${PN/pecl-/}-${PV}.tgz" so that SRC_URI gets set
# correctly by the eclass.
#
# Unlike PHP_EXT_PECL_PKG, setting this variable does not affect
# HOMEPAGE, PHP_EXT_NAME or ${S}.
# Set PHP_EXT_NAME for php-ext-source-r3.eclass.
[[ -z "${PHP_EXT_NAME}" ]] && PHP_EXT_NAME="${PHP_EXT_PECL_PKG}"
# Try to guess the upstream name of the package/version. We only use
# this variable temporarily before unsetting it.
PHP_EXT_PECL_PKG_V="${PHP_EXT_PECL_PKG}-${PV/_/}"
# It's important that we determine and set $S before we inherit below.
S="${WORKDIR}/${PHP_EXT_PECL_PKG_V}"
inherit php-ext-source-r3
EXPORT_FUNCTIONS src_install src_test
if [[ -z "${PHP_EXT_PECL_FILENAME}" ]] ; then
SRC_URI="http://pecl.php.net/get/${PHP_EXT_PECL_PKG_V}.tgz"
else
SRC_URI="http://pecl.php.net/get/${PHP_EXT_PECL_FILENAME}"
fi
# Don't leave this laying around in the environment.
unset PHP_EXT_PECL_PKG_V
HOMEPAGE="http://pecl.php.net/${PHP_EXT_PECL_PKG}"
# @FUNCTION: php-ext-pecl-r3_src_install
# @DESCRIPTION:
# Install a standard PECL package. First we delegate to
# php-ext-source-r3.eclass, and then we attempt to install examples
# found in a standard location.
php-ext-pecl-r3_src_install() {
php-ext-source-r3_src_install
if in_iuse examples && use examples ; then
dodoc -r examples
fi
}
# @FUNCTION: php-ext-pecl-r3_src_test
# @DESCRIPTION:
# Run tests delivered with the PECL package. Phpize will have generated
# a run-tests.php file to be executed by `make test`. We only need to
# force the test suite to run in non-interactive mode.
php-ext-pecl-r3_src_test() {
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
NO_INTERACTION="yes" emake test
done
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6.
2016-06-01 17:47 ` Michał Górny
@ 2016-06-02 12:27 ` Michael Orlitzky
2016-06-08 19:34 ` Michał Górny
0 siblings, 1 reply; 9+ messages in thread
From: Michael Orlitzky @ 2016-06-02 12:27 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 6020 bytes --]
Thanks for the detailed review. I followed every suggestion except the
doexe thing for *.so files (only because I don't understand the
reasoning yet). The new version is attached.
On 06/01/2016 01:47 PM, Michał Górny wrote:
>> +DEPEND=">=sys-devel/m4-1.4.3
>> + >=sys-devel/libtool-1.5.18"
>> +RDEPEND=""
>
> Please move all of this below EAPI check. And I think *DEPEND would be
> better set in one place.
I moved them all after the REQUIRED_USE mess.
>> +case ${EAPI} in
>> + 6) ;;
>> + *)
>> + die "php-ext-source-r3 is not compatible with EAPI=${EAPI}"
>
> I think you can use ${ECLASS} here btw.
Done.
>> +# @DESCRIPTION:
>> +# Lists the PHP slots compatibile the extension is compatibile with
>
> typo: compatible, and also appears twice ;-).
Fixed.
>> +# @ECLASS-VARIABLE: PHP_EXT_SAPIS
>> +# @DESCRIPTION:
>> +# A list of SAPIs for which we'll install this extension. Formerly
>> +# called PHPSAPILIST.
>> +[[ -z "${PHP_EXT_SAPIS}" ]] && PHP_EXT_SAPIS="apache2 cli cgi fpm embed phpdbg"
>
> Is this default something that might get extended in the future? I
> think it might be worth noting that here.
Yeah, I think we'll keep every SAPI currently used in the tree in the
list by default. We added "phpdbg" even though php:5.5 doesn't support
it. I documented that.
>> +# Make sure at least one target is installed. First, start a USE
>> +# conditional like "php?", but only when PHP_EXT_OPTIONAL_USE is
>> +# non-null. The option group "|| (..." is always started here.
>> +REQUIRED_USE="${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }|| ( "
>> +for target in ${USE_PHP}; do
>
> Environment pollution! unset target, or make this local.
I renamed it to _php_target and unset it after the loop.
>> + # Now loop through each USE_PHP target and add the corresponding
>> + # dev-lang/php slot to PHPDEPEND.
>> + IUSE="${IUSE} php_targets_${target}"
>
> Any reason not to use += here as well?
Nope, and likewise with PHPDEPEND in the same loop. I changed them both.
>> +# @ECLASS-VARIABLE: PHP_EXT_EXTRA_ECONF
>> +# @DESCRIPTION:
>> +# Set this in the ebuild to pass configure options to econf. Formerly
>> +# called my_conf.
>
> Please don't name this *EXTRA_ECONF. EXTRA_ECONF is a Portage variable
> that's meant to be set by user in make.conf/env, and not ebuilds.
It's PHP_EXT_ECONF_ARGS now, and I updated the migration guide.
>> + # Let's put the default module away. Strip $EPREFIX from
>> + # $EXT_DIR before calling newins (which handles EPREFIX itself).
>> + insinto "${EXT_DIR#$EPREFIX}"
>> + newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
>
> Wouldn't it be more appropriate to use exeinto/doexe to have the shared
> libs +x?
I'd never heard this before... why? I suppose the only trade-off is that
having them -x prevents them from showing up in bash's tab-completion
for executables.
>> +# @FUNCTION: php_init_slot_env
>> +# @DESCRIPTION:
>> +# Takes a slot name, and initializes some global variables to values
>> +# corresponding to that slot. For example, it sets the path to the "php"
>> +# and "phpize" binaries, which will differ for each slot. This function
>> +# is intended to be called while looping through a list of slots
>> +# obtained from php_get_slots().
>
> Please make it explicit that it changes working directory.
Done.
>> +# @FUNCTION: php_slot_ini_files
>> +# @INTERNAL
>> +# @DESCRIPTION:
>> +# Output a list of relative paths to INI files for the given
>> +# slot. Usually there will be one INI file per SAPI.
>
> Please add @USAGE to make clear what ${1} is. In fact, many functions
> seem to miss @USAGE.
I added USAGE for every function that takes an argument. I also figured
out where the eclass manpages come from and made sure that the other doc
issues (like DEFAULT_UNSET) are fixed w.r.t. eclass-to-manpage.sh.
>> + cat "${FILESDIR}/${PHP_EXT_INIFILE}" >> "${ED}/${file}"
>
> || die
Fixed all of these.
>> + # Add support for installing PHP files into a version dependent
>> + # directory
>> + PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}"
>
> Should this be repeated inside the loop?
There's a longer answer to that question, but the fact that it's outside
of the loop is intentional and consistent with -r2.
>> +php-ext-source-r3_addextension() {
>> + if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
>> + ext_type="zend_extension"
>> + ext_file="${EXT_DIR}/${1}" # Zend extensions need the path...
>> + else
>> + ext_type="extension"
>> + ext_file="${1}"
>> + fi
>
> I think you want those variables local.
Fixed all of the local variable issues.
>> +php-ext-source-r3_addtoinifile() {
>> + local inifile="${WORKDIR}/${1}"
>> + local inidir="$(dirname ${inifile})"
>
> I would suggest avoiding external tools like dirname when simple bash
> subst can do the work (e.g. ${inifile%/*}).
Fixed both `dirname` calls.
>> + if [[ ! -d "${inidir}" ]] ; then
>> + mkdir -p "${inidir}" || die "failed to create INI directory ${inidir}"
>
> 'mkdir -p' is safe to call when the directory exists, so I don't think
> you need the conditional.
Fixed.
> All above considered, wouldn't it be simpler to set my_added first,
> and then just echo it to the file outside the conditional?
Yes, good catch. I cleaned that up.
>> +# @FUNCTION: php-ext-source-r3_addtoinifiles
>> +# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
>
> I think you are mixing '[]' meaning optional and meaning literal '[]'
> here.
Yeah, I changed the first parameter to <setting-or-section-name> and
made the other two optional.
>> +# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0"
>
> Hmm... just to make it clear... is there any reason you use two
> arguments instead of the more obvious 'foo=15'?
It's weird, but it's not wrong, and that's the way -r2 did it. There are
a few ebuilds (not maintained by the PHP team) that call
*addtoinifiles() themselves, and I don't want to annoy those people too
much for cosmetic changes.
[-- Attachment #2: php-ext-source-r3.eclass --]
[-- Type: text/plain, Size: 12500 bytes --]
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
# @ECLASS: php-ext-source-r3.eclass
# @MAINTAINER:
# Gentoo PHP team <php-bugs@gentoo.org>
# @BLURB: Compile and install standalone PHP extensions.
# @DESCRIPTION:
# A unified interface for compiling and installing standalone PHP
# extensions.
inherit autotools
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
case ${EAPI} in
6) ;;
*)
die "${ECLASS} is not compatible with EAPI=${EAPI}"
esac
# @ECLASS-VARIABLE: PHP_EXT_NAME
# @REQUIRED
# @DESCRIPTION:
# The extension name. This must be set, otherwise the eclass dies.
# Only automagically set by php-ext-pecl-r3.eclass, so unless your ebuild
# inherits that eclass, you must set this manually before inherit.
[[ -z "${PHP_EXT_NAME}" ]] && \
die "no extension name specified for the php-ext-source-r3 eclass"
# @ECLASS-VARIABLE: PHP_EXT_INI
# @DESCRIPTION:
# Controls whether or not to add a line to php.ini for the extension.
# Defaults to "yes" and should not be changed in most cases.
[[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
# @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
# @DESCRIPTION:
# Controls whether the extension is a ZendEngine extension or not.
# Defaults to "no". If you don't know what this is, you don't need it.
[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
# @ECLASS-VARIABLE: USE_PHP
# @REQUIRED
# @DESCRIPTION:
# Lists the PHP slots compatible the extension is compatible with.
# Example:
# @CODE
# USE_PHP="php5-6 php7-0"
# @CODE
[[ -z "${USE_PHP}" ]] && \
die "USE_PHP is not set for the php-ext-source-r3 eclass"
# @ECLASS-VARIABLE: PHP_EXT_OPTIONAL_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
# If set, all of the dependencies added by this eclass will be
# conditional on USE=${PHP_EXT_OPTIONAL_USE}. This is needed when
# ebuilds have to inherit this eclass unconditionally, but only
# actually use it when (for example) the user has USE=php.
# @ECLASS-VARIABLE: PHP_EXT_S
# @DESCRIPTION:
# The relative location of the temporary build directory for the PHP
# extension within the source package. This is useful for packages that
# bundle the PHP extension. Defaults to ${S}.
[[ -z "${PHP_EXT_S}" ]] && PHP_EXT_S="${S}"
# @ECLASS-VARIABLE: PHP_EXT_SAPIS
# @DESCRIPTION:
# A list of SAPIs for which we will install this extension. Formerly
# called PHPSAPILIST. The default includes every SAPI currently used in
# the tree.
[[ -z "${PHP_EXT_SAPIS}" ]] && PHP_EXT_SAPIS="apache2 cli cgi fpm embed phpdbg"
# Make sure at least one target is installed. First, start a USE
# conditional like "php?", but only when PHP_EXT_OPTIONAL_USE is
# non-null. The option group "|| (..." is always started here.
REQUIRED_USE="${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }|| ( "
for _php_target in ${USE_PHP}; do
# Now loop through each USE_PHP target and add the corresponding
# dev-lang/php slot to PHPDEPEND.
IUSE+=" php_targets_${_php_target}"
REQUIRED_USE+="php_targets_${_php_target} "
slot=${_php_target/php}
slot=${slot/-/.}
PHPDEPEND+=" php_targets_${_php_target}? ( dev-lang/php:${slot} )"
done
# Don't pollute the environment with our loop variable...
unset _php_target
# Finally, end the optional group that we started before the loop. Close
# the USE-conditional if PHP_EXT_OPTIONAL_USE is non-null.
REQUIRED_USE+=") ${PHP_EXT_OPTIONAL_USE:+ )}"
RDEPEND="${RDEPEND}
${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
${PHPDEPEND}
${PHP_EXT_OPTIONAL_USE:+ )}"
DEPEND="${DEPEND}
sys-devel/m4
sys-devel/libtool
${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
${PHPDEPEND}
${PHP_EXT_OPTIONAL_USE:+ )}
"
# @ECLASS-VARIABLE: PHP_EXT_SKIP_PHPIZE
# @DEFAULT_UNSET
# @DESCRIPTION:
# By default, we run "phpize" in php-ext-source-r3_src_unpack(). Set
# PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run
# phpize (and the autoreconf that becomes necessary afterwards).
# @FUNCTION: php-ext-source-r3_src_unpack
# @DESCRIPTION:
# Runs the default src_unpack and then makes a copy for each PHP slot.
php-ext-source-r3_src_unpack() {
default
local slot orig_s="${PHP_EXT_S}"
for slot in $(php_get_slots); do
cp -r "${orig_s}" "${WORKDIR}/${slot}" || \
die "failed to copy sources from ${orig_s} to ${WORKDIR}/${slot}"
done
}
# @FUNCTION: php-ext-source-r3_src_prepare
# @DESCRIPTION:
# For each PHP slot, we initialize the environment, run the default
# src_prepare() for PATCHES/eapply_user support, and then call
# php-ext-source-r3_phpize.
php-ext-source-r3_src_prepare() {
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
default
php-ext-source-r3_phpize
done
}
# @FUNCTION: php-ext-source-r3_phpize
# @DESCRIPTION:
# Subject to PHP_EXT_SKIP_PHPIZE, this function runs phpize and
# autoreconf in a manner that avoids warnings.
php-ext-source-r3_phpize() {
if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
# Create configure out of config.m4. We use autotools_run_tool
# to avoid some warnings about WANT_AUTOCONF and
# WANT_AUTOMAKE (see bugs #329071 and #549268).
autotools_run_tool "${PHPIZE}"
# Force libtoolize to run and regenerate autotools files (bug
# #220519).
rm aclocal.m4 || die "failed to remove aclocal.m4"
eautoreconf
fi
}
# @ECLASS-VARIABLE: PHP_EXT_ECONF_ARGS
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set this in the ebuild to pass additional configure options to
# econf. Formerly called my_conf.
# @FUNCTION: php-ext-source-r3_src_configure
# @DESCRIPTION:
# Takes care of standard configure for PHP extensions (modules).
php-ext-source-r3_src_configure() {
# net-snmp creates these, bug #385403.
addpredict /usr/share/snmp/mibs/.index
addpredict /var/lib/net-snmp/mib_indexes
local slot
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
# Set the correct config options
econf --with-php-config=${PHPCONFIG} ${PHP_EXT_ECONF_ARGS}
done
}
# @FUNCTION: php-ext-source-r3_src_compile
# @DESCRIPTION:
# Compile a standard standalone PHP extension.
php-ext-source-r3_src_compile() {
# net-snmp creates these, bug #324739.
addpredict /usr/share/snmp/mibs/.index
addpredict /var/lib/net-snmp/mib_indexes
# shm extension creates a semaphore file, bug #173574.
addpredict /session_mm_cli0.sem
local slot
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
emake
done
}
# @FUNCTION: php-ext-source-r3_src_install
# @DESCRIPTION:
# Install a standard standalone PHP extension. Uses einstalldocs()
# to support the DOCS variable/array.
php-ext-source-r3_src_install() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
# Let's put the default module away. Strip $EPREFIX from
# $EXT_DIR before calling newins (which handles EPREFIX itself).
insinto "${EXT_DIR#$EPREFIX}"
newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
INSTALL_ROOT="${D}" emake install-headers
done
einstalldocs
php-ext-source-r3_createinifiles
}
# @FUNCTION: php_get_slots
# @DESCRIPTION:
# Get a list of PHP slots contained in both the ebuild's USE_PHP and the
# user's PHP_TARGETS.
php_get_slots() {
local s=""
local slot
for slot in ${USE_PHP}; do
use php_targets_${slot} && s+=" ${slot/-/.}"
done
echo $s
}
# @FUNCTION: php_init_slot_env
# @USAGE: <slot>
# @DESCRIPTION:
# Takes a slot name, and initializes some global variables to values
# corresponding to that slot. For example, it sets the path to the "php"
# and "phpize" binaries, which will differ for each slot. This function
# is intended to be called while looping through a list of slots
# obtained from php_get_slots().
#
# Calling this function will change the working directory to the
# temporary build directory for the given slot.
php_init_slot_env() {
local libdir=$(get_libdir)
PHPIZE="${EPREFIX}/usr/${libdir}/${1}/bin/phpize"
PHPCONFIG="${EPREFIX}/usr/${libdir}/${1}/bin/php-config"
PHPCLI="${EPREFIX}/usr/${libdir}/${1}/bin/php"
PHPCGI="${EPREFIX}/usr/${libdir}/${1}/bin/php-cgi"
PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
PHPPREFIX="${EPREFIX}/usr/${libdir}/${slot}"
EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
PHP_CURRENTSLOT=${1:3}
PHP_EXT_S="${WORKDIR}/${1}"
cd "${PHP_EXT_S}" || die "failed to change directory to ${PHP_EXT_S}"
}
# @FUNCTION: php_slot_ini_files
# @USAGE: <slot>
# @INTERNAL
# @DESCRIPTION:
# Output a list of relative paths to INI files for the given
# slot. Usually there will be one INI file per SAPI.
php_slot_ini_files() {
local slot_ini_files=""
local x
for x in ${PHP_EXT_SAPIS} ; do
if [[ -f "${EPREFIX}/etc/php/${x}-${1}/php.ini" ]] ; then
slot_ini_files+=" etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
fi
done
echo "${slot_ini_files}"
}
# @FUNCTION: php-ext-source-r3_createinifiles
# @DESCRIPTION:
# Builds INI files for every enabled slot and SAPI.
php-ext-source-r3_createinifiles() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
local file
for file in $(php_slot_ini_files "${slot}") ; do
if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
# Add the needed lines to the <ext>.ini files
php-ext-source-r3_addextension "${PHP_EXT_NAME}.so" "${file}"
fi
if [[ -n "${PHP_EXT_INIFILE}" ]] ; then
cat "${FILESDIR}/${PHP_EXT_INIFILE}" >> "${ED}/${file}" \
|| die "failed to append to ${ED}/${file}"
einfo "Added contents of ${FILESDIR}/${PHP_EXT_INIFILE}" \
"to ${file}"
fi
inidir="${file/${PHP_EXT_NAME}.ini/}"
inidir="${inidir/ext/ext-active}"
dodir "/${inidir}"
dosym "/${file}" "/${file/ext/ext-active}"
done
# Add support for installing PHP files into a version dependent
# directory
PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}"
done
}
# @FUNCTION: php-ext-source-r3_addextension
# @USAGE: <extension-path> <ini-file>
# @INTERNAL
# @DESCRIPTION:
# Add a line to an INI file that will enable the given extension. The
# first parameter is the path to the extension (.so) file, and the
# second parameter is the name of the INI file in which it should be
# loaded. This function determines the setting name (either
# "extension=..." or "zend_extension=...") and then calls
# php-ext-source-r3_addtoinifile to do the actual work.
php-ext-source-r3_addextension() {
local ext_type="extension"
local ext_file="${1}"
if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
ext_type="zend_extension"
ext_file="${EXT_DIR}/${1}" # Zend extensions need the path...
fi
php-ext-source-r3_addtoinifile "${2}" "${ext_type}" "${ext_file}"
}
# @FUNCTION: php-ext-source-r3_addtoinifile
# @USAGE: <relative-ini-path> <setting-or-section-name> [setting-value]
# @INTERNAL
# @DESCRIPTION:
# Add a setting=value to one INI file. The first argument is the
# relative path to the INI file. The second argument is the setting
# name, and the third argument is its value.
#
# You can also pass "[Section]" as the second parameter, to create a new
# section in the INI file. In that case, the third parameter (which
# would otherwise be the value of the setting) is ignored.
php-ext-source-r3_addtoinifile() {
local inifile="${WORKDIR}/${1}"
local inidir="${inifile%/*}"
mkdir -p "${inidir}" || die "failed to create INI directory ${inidir}"
# Are we adding the name of a section? Assume not by default.
local my_added="${2}=${3}"
if [[ ${2:0:1} == "[" ]] ; then
# Ok, it's a section name.
my_added="${2}"
fi
echo "${my_added}" >> "${inifile}" || die "failed to append to ${inifile}"
einfo "Added '${my_added}' to /${1}"
insinto "/${1%/*}"
doins "${inifile}"
}
# @FUNCTION: php-ext-source-r3_addtoinifiles
# @USAGE: <setting-or-section-name> [setting-value] [message]
# @DESCRIPTION:
# Add settings to every php.ini file installed by this extension.
# You can also add new [Section]s -- see the example below.
#
# @CODE
# Add some settings for the extension:
#
# php-ext-source-r3_addtoinifiles "zend_optimizer.optimization_level" "15"
# php-ext-source-r3_addtoinifiles "zend_optimizer.enable_loader" "0"
# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0"
#
# Adding values to a section in php.ini file installed by the extension:
#
# php-ext-source-r3_addtoinifiles "[Debugger]"
# php-ext-source-r3_addtoinifiles "debugger.enabled" "on"
# php-ext-source-r3_addtoinifiles "debugger.profiler_enabled" "on"
# @CODE
php-ext-source-r3_addtoinifiles() {
local slot
for slot in $(php_get_slots); do
for file in $(php_slot_ini_files "${slot}") ; do
php-ext-source-r3_addtoinifile "${file}" "${1}" "${2}"
done
done
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6.
2016-06-02 12:27 ` Michael Orlitzky
@ 2016-06-08 19:34 ` Michał Górny
2016-06-20 23:41 ` Michael Orlitzky
0 siblings, 1 reply; 9+ messages in thread
From: Michał Górny @ 2016-06-08 19:34 UTC (permalink / raw
To: Michael Orlitzky; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 7906 bytes --]
On Thu, 2 Jun 2016 08:27:06 -0400
Michael Orlitzky <mjo@gentoo.org> wrote:
> Thanks for the detailed review. I followed every suggestion except the
> doexe thing for *.so files (only because I don't understand the
> reasoning yet). The new version is attached.
Next time, please inline and don't attach. It's awfully hard to reply
to both the reply and the attachment.
> >> + # Let's put the default module away. Strip $EPREFIX from
> >> + # $EXT_DIR before calling newins (which handles EPREFIX itself).
> >> + insinto "${EXT_DIR#$EPREFIX}"
> >> + newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
> >
> > Wouldn't it be more appropriate to use exeinto/doexe to have the shared
> > libs +x?
>
> I'd never heard this before... why? I suppose the only trade-off is that
> having them -x prevents them from showing up in bash's tab-completion
> for executables.
To be honest, I never dived into figuring out why it's like that -- but
all libraries on my system are +x, and that's how the compiler creates
them. So I'd rather follow that.
> >> + # Add support for installing PHP files into a version dependent
> >> + # directory
> >> + PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}"
> >
> > Should this be repeated inside the loop?
>
> There's a longer answer to that question, but the fact that it's outside
> of the loop is intentional and consistent with -r2.
Sorry, I wasn't clear. I was asking why it's inside the outer loop,
rather than at the end of the function, after both loops?
> >> +# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0"
> >
> > Hmm... just to make it clear... is there any reason you use two
> > arguments instead of the more obvious 'foo=15'?
>
> It's weird, but it's not wrong, and that's the way -r2 did it. There are
> a few ebuilds (not maintained by the PHP team) that call
> *addtoinifiles() themselves, and I don't want to annoy those people too
> much for cosmetic changes.
I'd say you could support both, and prefer the simpler ;-).
Now, for the code:
> # @FUNCTION: php-ext-source-r3_src_unpack
> # @DESCRIPTION:
> # Runs the default src_unpack and then makes a copy for each PHP slot.
> php-ext-source-r3_src_unpack() {
> default
>
> local slot orig_s="${PHP_EXT_S}"
> for slot in $(php_get_slots); do
> cp -r "${orig_s}" "${WORKDIR}/${slot}" || \
> die "failed to copy sources from ${orig_s} to ${WORKDIR}/${slot}"
Not sure if this is relevant but I think this breaks mtime guarantees.
In other words, output files may end up being 'earlier' than input files
depending on copy order.
In multibuild.eclass, I used 'cp -p -R' to preserve timestamps and modes.
> done
> }
>
>
> # @FUNCTION: php-ext-source-r3_src_prepare
> # @DESCRIPTION:
> # For each PHP slot, we initialize the environment, run the default
> # src_prepare() for PATCHES/eapply_user support, and then call
> # php-ext-source-r3_phpize.
> php-ext-source-r3_src_prepare() {
> for slot in $(php_get_slots); do
> php_init_slot_env "${slot}"
> default
> php-ext-source-r3_phpize
> done
> }
Thinking about it... wouldn't it be better to:
a. stop overriding unpack,
b. run 'default' on ${S},
c. then copy sources in src_prepare()?
In other words, apply patches first, then copy; rather than copying, then
applying patches to each copy separately.
> # @ECLASS-VARIABLE: PHP_EXT_ECONF_ARGS
> # @DEFAULT_UNSET
> # @DESCRIPTION:
> # Set this in the ebuild to pass additional configure options to
> # econf. Formerly called my_conf.
>
> # @FUNCTION: php-ext-source-r3_src_configure
> # @DESCRIPTION:
> # Takes care of standard configure for PHP extensions (modules).
> php-ext-source-r3_src_configure() {
> # net-snmp creates these, bug #385403.
> addpredict /usr/share/snmp/mibs/.index
> addpredict /var/lib/net-snmp/mib_indexes
>
> local slot
> for slot in $(php_get_slots); do
> php_init_slot_env "${slot}"
> # Set the correct config options
> econf --with-php-config=${PHPCONFIG} ${PHP_EXT_ECONF_ARGS}
I think PHPCONFIG would be better off quoted, and it would be good to
support PHP_EXT_ECONF_ARGS as an array in case someone needs to pass
whitespace there.
> done
> }
> # @FUNCTION: php-ext-source-r3_src_install
> # @DESCRIPTION:
> # Install a standard standalone PHP extension. Uses einstalldocs()
> # to support the DOCS variable/array.
> php-ext-source-r3_src_install() {
> local slot
> for slot in $(php_get_slots); do
> php_init_slot_env "${slot}"
>
> # Let's put the default module away. Strip $EPREFIX from
> # $EXT_DIR before calling newins (which handles EPREFIX itself).
> insinto "${EXT_DIR#$EPREFIX}"
> newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
Wouldn't doins/doexe do the same btw? It seems to be that the name is
not changed.
>
> INSTALL_ROOT="${D}" emake install-headers
> done
> einstalldocs
> php-ext-source-r3_createinifiles
> }
>
> # @FUNCTION: php_get_slots
> # @DESCRIPTION:
> # Get a list of PHP slots contained in both the ebuild's USE_PHP and the
> # user's PHP_TARGETS.
> php_get_slots() {
> local s=""
> local slot
> for slot in ${USE_PHP}; do
> use php_targets_${slot} && s+=" ${slot/-/.}"
> done
> echo $s
> }
>
> # @FUNCTION: php_init_slot_env
> # @USAGE: <slot>
> # @DESCRIPTION:
> # Takes a slot name, and initializes some global variables to values
> # corresponding to that slot. For example, it sets the path to the "php"
> # and "phpize" binaries, which will differ for each slot. This function
> # is intended to be called while looping through a list of slots
> # obtained from php_get_slots().
> #
> # Calling this function will change the working directory to the
> # temporary build directory for the given slot.
> php_init_slot_env() {
> local libdir=$(get_libdir)
>
> PHPIZE="${EPREFIX}/usr/${libdir}/${1}/bin/phpize"
> PHPCONFIG="${EPREFIX}/usr/${libdir}/${1}/bin/php-config"
> PHPCLI="${EPREFIX}/usr/${libdir}/${1}/bin/php"
> PHPCGI="${EPREFIX}/usr/${libdir}/${1}/bin/php-cgi"
> PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
> PHPPREFIX="${EPREFIX}/usr/${libdir}/${slot}"
A reason why you are using ${1} before, and ${slot} here?
> EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
> PHP_CURRENTSLOT=${1:3}
>
> PHP_EXT_S="${WORKDIR}/${1}"
> cd "${PHP_EXT_S}" || die "failed to change directory to ${PHP_EXT_S}"
> }
> # @FUNCTION: php-ext-source-r3_addtoinifile
> # @USAGE: <relative-ini-path> <setting-or-section-name> [setting-value]
> # @INTERNAL
> # @DESCRIPTION:
> # Add a setting=value to one INI file. The first argument is the
> # relative path to the INI file. The second argument is the setting
> # name, and the third argument is its value.
> #
> # You can also pass "[Section]" as the second parameter, to create a new
> # section in the INI file. In that case, the third parameter (which
> # would otherwise be the value of the setting) is ignored.
> php-ext-source-r3_addtoinifile() {
> local inifile="${WORKDIR}/${1}"
> local inidir="${inifile%/*}"
>
> mkdir -p "${inidir}" || die "failed to create INI directory ${inidir}"
>
> # Are we adding the name of a section? Assume not by default.
> local my_added="${2}=${3}"
> if [[ ${2:0:1} == "[" ]] ; then
> # Ok, it's a section name.
> my_added="${2}"
> fi
How about:
my_added=${2}${3+=${3}}
?
> echo "${my_added}" >> "${inifile}" || die "failed to append to ${inifile}"
> einfo "Added '${my_added}' to /${1}"
>
> insinto "/${1%/*}"
> doins "${inifile}"
Not that I like re-doinsing the files every time a line is inserted,
but I guess improving this is not worth the effort.
> }
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6.
2016-06-08 19:34 ` Michał Górny
@ 2016-06-20 23:41 ` Michael Orlitzky
0 siblings, 0 replies; 9+ messages in thread
From: Michael Orlitzky @ 2016-06-20 23:41 UTC (permalink / raw
To: gentoo-dev
On 06/08/2016 03:34 PM, Michał Górny wrote:
>
> Next time, please inline and don't attach. It's awfully hard to reply
> to both the reply and the attachment.
Sorry, I was trying to hide the fact that I can't work Thunderbird.
>>>> + newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
>>>
>>> Wouldn't it be more appropriate to use exeinto/doexe to have the shared
>>> libs +x?
>>
>> I'd never heard this before... why? I suppose the only trade-off is that
>> having them -x prevents them from showing up in bash's tab-completion
>> for executables.
>
> To be honest, I never dived into figuring out why it's like that -- but
> all libraries on my system are +x, and that's how the compiler creates
> them. So I'd rather follow that.
*shrug* done.
>>>> + PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}"
>>>
>>> Should this be repeated inside the loop?
>>
>> There's a longer answer to that question, but the fact that it's outside
>> of the loop is intentional and consistent with -r2.
>
> Sorry, I wasn't clear. I was asking why it's inside the outer loop,
> rather than at the end of the function, after both loops?
Oh, right. That variable doesn't belong in that function at all, but for now
I've moved it out of the loops. I collected all of the improvements that I'm
opting not to make at this time in,
https://bugs.gentoo.org/show_bug.cgi?id=586446
>>>> +# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0"
>>>
>>> Hmm... just to make it clear... is there any reason you use two
>>> arguments instead of the more obvious 'foo=15'?
>>
>> It's weird, but it's not wrong, and that's the way -r2 did it. There are
>> a few ebuilds (not maintained by the PHP team) that call
>> *addtoinifiles() themselves, and I don't want to annoy those people too
>> much for cosmetic changes.
>
> I'd say you could support both, and prefer the simpler ;-).
But that function is already a mess, and I don't want to make it worse. We'll
fix this properly in the future by making addtoinifiles() take a string and
simply add that string to the INI files. It's noted on that bug above.
>> cp -r "${orig_s}" "${WORKDIR}/${slot}" || \
>> die "failed to copy sources from ${orig_s} to ${WORKDIR}/${slot}"
>
> Not sure if this is relevant but I think this breaks mtime guarantees.
> In other words, output files may end up being 'earlier' than input files
> depending on copy order.
>
> In multibuild.eclass, I used 'cp -p -R' to preserve timestamps and modes.
>
Fixed.
>> # @FUNCTION: php-ext-source-r3_src_prepare
>> # @DESCRIPTION:
>> # For each PHP slot, we initialize the environment, run the default
>> # src_prepare() for PATCHES/eapply_user support, and then call
>> # php-ext-source-r3_phpize.
>> php-ext-source-r3_src_prepare() {
>> for slot in $(php_get_slots); do
>> php_init_slot_env "${slot}"
>> default
>> php-ext-source-r3_phpize
>> done
>> }
>
> Thinking about it... wouldn't it be better to:
>
> ...
>
> apply patches first, then copy; rather than copying, then
> applying patches to each copy separately.
>
Yeah, but this is another change that will annoy people. Ebuilds that
override src_unpack/src_prepare would need to be rewritten. We'll fix
it in a later revision.
>> econf --with-php-config=${PHPCONFIG} ${PHP_EXT_ECONF_ARGS}
>
> I think PHPCONFIG would be better off quoted, and it would be good to
> support PHP_EXT_ECONF_ARGS as an array in case someone needs to pass
> whitespace there.
Both done. Please check the hack I used to support both arrays/strings.
>> newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
>
> Wouldn't doins/doexe do the same btw? It seems to be that the name is
> not changed.
Yup, fixed.
>> php_init_slot_env() {
>> local libdir=$(get_libdir)
>>
>> PHPIZE="${EPREFIX}/usr/${libdir}/${1}/bin/phpize"
>> PHPCONFIG="${EPREFIX}/usr/${libdir}/${1}/bin/php-config"
>> PHPCLI="${EPREFIX}/usr/${libdir}/${1}/bin/php"
>> PHPCGI="${EPREFIX}/usr/${libdir}/${1}/bin/php-cgi"
>> PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
>> PHPPREFIX="${EPREFIX}/usr/${libdir}/${slot}"
>
> A reason why you are using ${1} before, and ${slot} here?
No, that's just broken. I think it's picking up $slot from the REQUIRED_USE
loop at the top, so this involves two fixes. First, I make PHPPREFIX use the
function argument instead of the global $slot. And second, I don't pollute
the environment with a global $slot in the first place -- I namespaced that
variable and unset it afterwards.
>> local my_added="${2}=${3}"
>> if [[ ${2:0:1} == "[" ]] ; then
>> # Ok, it's a section name.
>> my_added="${2}"
>> fi
>
> How about:
>
> my_added=${2}${3+=${3}}
Sure, done.
>> echo "${my_added}" >> "${inifile}" || die "failed to append to ${inifile}"
>> einfo "Added '${my_added}' to /${1}"
>>
>> insinto "/${1%/*}"
>> doins "${inifile}"
>
> Not that I like re-doinsing the files every time a line is inserted,
> but I guess improving this is not worth the effort.
I'll need to think a little bit about this, I added it to the bug.
Here's the latest revision.
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
# @ECLASS: php-ext-source-r3.eclass
# @MAINTAINER:
# Gentoo PHP team <php-bugs@gentoo.org>
# @BLURB: Compile and install standalone PHP extensions.
# @DESCRIPTION:
# A unified interface for compiling and installing standalone PHP
# extensions.
inherit autotools
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
case ${EAPI} in
6) ;;
*)
die "${ECLASS} is not compatible with EAPI=${EAPI}"
esac
# @ECLASS-VARIABLE: PHP_EXT_NAME
# @REQUIRED
# @DESCRIPTION:
# The extension name. This must be set, otherwise the eclass dies.
# Only automagically set by php-ext-pecl-r3.eclass, so unless your ebuild
# inherits that eclass, you must set this manually before inherit.
[[ -z "${PHP_EXT_NAME}" ]] && \
die "no extension name specified for the php-ext-source-r3 eclass"
# @ECLASS-VARIABLE: PHP_EXT_INI
# @DESCRIPTION:
# Controls whether or not to add a line to php.ini for the extension.
# Defaults to "yes" and should not be changed in most cases.
[[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
# @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
# @DESCRIPTION:
# Controls whether the extension is a ZendEngine extension or not.
# Defaults to "no". If you don't know what this is, you don't need it.
[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
# @ECLASS-VARIABLE: USE_PHP
# @REQUIRED
# @DESCRIPTION:
# Lists the PHP slots compatible the extension is compatible with.
# Example:
# @CODE
# USE_PHP="php5-6 php7-0"
# @CODE
[[ -z "${USE_PHP}" ]] && \
die "USE_PHP is not set for the php-ext-source-r3 eclass"
# @ECLASS-VARIABLE: PHP_EXT_OPTIONAL_USE
# @DEFAULT_UNSET
# @DESCRIPTION:
# If set, all of the dependencies added by this eclass will be
# conditional on USE=${PHP_EXT_OPTIONAL_USE}. This is needed when
# ebuilds have to inherit this eclass unconditionally, but only
# actually use it when (for example) the user has USE=php.
# @ECLASS-VARIABLE: PHP_EXT_S
# @DESCRIPTION:
# The relative location of the temporary build directory for the PHP
# extension within the source package. This is useful for packages that
# bundle the PHP extension. Defaults to ${S}.
[[ -z "${PHP_EXT_S}" ]] && PHP_EXT_S="${S}"
# @ECLASS-VARIABLE: PHP_EXT_SAPIS
# @DESCRIPTION:
# A list of SAPIs for which we will install this extension. Formerly
# called PHPSAPILIST. The default includes every SAPI currently used in
# the tree.
[[ -z "${PHP_EXT_SAPIS}" ]] && PHP_EXT_SAPIS="apache2 cli cgi fpm embed phpdbg"
# Make sure at least one target is installed. First, start a USE
# conditional like "php?", but only when PHP_EXT_OPTIONAL_USE is
# non-null. The option group "|| (..." is always started here.
REQUIRED_USE="${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }|| ( "
for _php_target in ${USE_PHP}; do
# Now loop through each USE_PHP target and add the corresponding
# dev-lang/php slot to PHPDEPEND.
IUSE+=" php_targets_${_php_target}"
REQUIRED_USE+="php_targets_${_php_target} "
_php_slot=${_php_target/php}
_php_slot=${_php_slot/-/.}
PHPDEPEND+=" php_targets_${_php_target}? ( dev-lang/php:${_php_slot} )"
done
# Don't pollute the environment with our loop variables.
unset _php_slot _php_target
# Finally, end the optional group that we started before the loop. Close
# the USE-conditional if PHP_EXT_OPTIONAL_USE is non-null.
REQUIRED_USE+=") ${PHP_EXT_OPTIONAL_USE:+ )}"
RDEPEND="${RDEPEND}
${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
${PHPDEPEND}
${PHP_EXT_OPTIONAL_USE:+ )}"
DEPEND="${DEPEND}
sys-devel/m4
sys-devel/libtool
${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
${PHPDEPEND}
${PHP_EXT_OPTIONAL_USE:+ )}
"
# @ECLASS-VARIABLE: PHP_EXT_SKIP_PHPIZE
# @DEFAULT_UNSET
# @DESCRIPTION:
# By default, we run "phpize" in php-ext-source-r3_src_unpack(). Set
# PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run
# phpize (and the autoreconf that becomes necessary afterwards).
# @FUNCTION: php-ext-source-r3_src_unpack
# @DESCRIPTION:
# Runs the default src_unpack and then makes a copy for each PHP slot.
php-ext-source-r3_src_unpack() {
default
local slot orig_s="${PHP_EXT_S}"
for slot in $(php_get_slots); do
cp --recursive --preserve "${orig_s}" "${WORKDIR}/${slot}" || \
die "failed to copy sources from ${orig_s} to ${WORKDIR}/${slot}"
done
}
# @FUNCTION: php-ext-source-r3_src_prepare
# @DESCRIPTION:
# For each PHP slot, we initialize the environment, run the default
# src_prepare() for PATCHES/eapply_user support, and then call
# php-ext-source-r3_phpize.
php-ext-source-r3_src_prepare() {
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
default
php-ext-source-r3_phpize
done
}
# @FUNCTION: php-ext-source-r3_phpize
# @DESCRIPTION:
# Subject to PHP_EXT_SKIP_PHPIZE, this function runs phpize and
# autoreconf in a manner that avoids warnings.
php-ext-source-r3_phpize() {
if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
# Create configure out of config.m4. We use autotools_run_tool
# to avoid some warnings about WANT_AUTOCONF and
# WANT_AUTOMAKE (see bugs #329071 and #549268).
autotools_run_tool "${PHPIZE}"
# Force libtoolize to run and regenerate autotools files (bug
# #220519).
rm aclocal.m4 || die "failed to remove aclocal.m4"
eautoreconf
fi
}
# @ECLASS-VARIABLE: PHP_EXT_ECONF_ARGS
# @DEFAULT_UNSET
# @DESCRIPTION:
# Set this in the ebuild to pass additional configure options to
# econf. Formerly called my_conf. Either a string or an array of
# --flag=value parameters is supported.
# @FUNCTION: php-ext-source-r3_src_configure
# @DESCRIPTION:
# Takes care of standard configure for PHP extensions (modules).
php-ext-source-r3_src_configure() {
# net-snmp creates these, bug #385403.
addpredict /usr/share/snmp/mibs/.index
addpredict /var/lib/net-snmp/mib_indexes
# Support either a string or an array for PHP_EXT_ECONF_ARGS.
local econf_args
if [[ $(declare -p PHP_EXT_ECONF_ARGS) == "declare -a"* ]]; then
econf_args=( "${PHP_EXT_ECONF_ARGS[@]}" )
else
econf_args=( ${PHP_EXT_ECONF_ARGS} )
fi
local slot
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
econf --with-php-config="${PHPCONFIG}" "${econf_args[@]}"
done
}
# @FUNCTION: php-ext-source-r3_src_compile
# @DESCRIPTION:
# Compile a standard standalone PHP extension.
php-ext-source-r3_src_compile() {
# net-snmp creates these, bug #324739.
addpredict /usr/share/snmp/mibs/.index
addpredict /var/lib/net-snmp/mib_indexes
# shm extension creates a semaphore file, bug #173574.
addpredict /session_mm_cli0.sem
local slot
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
emake
done
}
# @FUNCTION: php-ext-source-r3_src_install
# @DESCRIPTION:
# Install a standard standalone PHP extension. Uses einstalldocs()
# to support the DOCS variable/array.
php-ext-source-r3_src_install() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
# Strip $EPREFIX from $EXT_DIR before calling doexe (which
# handles EPREFIX itself). Shared libs are +x by convention,
# although nothing seems to depend on that.
exeinto "${EXT_DIR#$EPREFIX}"
doexe "modules/${PHP_EXT_NAME}.so"
INSTALL_ROOT="${D}" emake install-headers
done
einstalldocs
php-ext-source-r3_createinifiles
}
# @FUNCTION: php_get_slots
# @DESCRIPTION:
# Get a list of PHP slots contained in both the ebuild's USE_PHP and the
# user's PHP_TARGETS.
php_get_slots() {
local s=""
local slot
for slot in ${USE_PHP}; do
use php_targets_${slot} && s+=" ${slot/-/.}"
done
echo $s
}
# @FUNCTION: php_init_slot_env
# @USAGE: <slot>
# @DESCRIPTION:
# Takes a slot name, and initializes some global variables to values
# corresponding to that slot. For example, it sets the path to the "php"
# and "phpize" binaries, which will differ for each slot. This function
# is intended to be called while looping through a list of slots
# obtained from php_get_slots().
#
# Calling this function will change the working directory to the
# temporary build directory for the given slot.
php_init_slot_env() {
local libdir=$(get_libdir)
local slot="${1}"
PHPPREFIX="${EPREFIX}/usr/${libdir}/${slot}"
PHPIZE="${PHPPREFIX}/bin/phpize"
PHPCONFIG="${PHPPREFIX}/bin/php-config"
PHPCLI="${PHPPREFIX}/bin/php"
PHPCGI="${PHPPREFIX}/bin/php-cgi"
PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
PHP_CURRENTSLOT=${1:3}
PHP_EXT_S="${WORKDIR}/${slot}"
cd "${PHP_EXT_S}" || die "failed to change directory to ${PHP_EXT_S}"
}
# @FUNCTION: php_slot_ini_files
# @USAGE: <slot>
# @INTERNAL
# @DESCRIPTION:
# Output a list of relative paths to INI files for the given
# slot. Usually there will be one INI file per SAPI.
php_slot_ini_files() {
local slot_ini_files=""
local x
for x in ${PHP_EXT_SAPIS} ; do
if [[ -f "${EPREFIX}/etc/php/${x}-${1}/php.ini" ]] ; then
slot_ini_files+=" etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
fi
done
echo "${slot_ini_files}"
}
# @FUNCTION: php-ext-source-r3_createinifiles
# @DESCRIPTION:
# Builds INI files for every enabled slot and SAPI.
php-ext-source-r3_createinifiles() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env "${slot}"
local file
for file in $(php_slot_ini_files "${slot}") ; do
if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
# Add the needed lines to the <ext>.ini files
php-ext-source-r3_addextension "${PHP_EXT_NAME}.so" "${file}"
fi
if [[ -n "${PHP_EXT_INIFILE}" ]] ; then
cat "${FILESDIR}/${PHP_EXT_INIFILE}" >> "${ED}/${file}" \
|| die "failed to append to ${ED}/${file}"
einfo "Added contents of ${FILESDIR}/${PHP_EXT_INIFILE}" \
"to ${file}"
fi
inidir="${file/${PHP_EXT_NAME}.ini/}"
inidir="${inidir/ext/ext-active}"
dodir "/${inidir}"
dosym "/${file}" "/${file/ext/ext-active}"
done
done
# A location where PHP code for this extension can be stored,
# independent of the PHP or extension versions. This will be part of
# PHP's include_path, configured in php.ini. For example, pecl-apcu
# installs an "apc.php" file which you are supposed to load with
#
# require('apcu/apc.php');
#
PHP_EXT_SHARED_DIR="${EPREFIX}/usr/share/php/${PHP_EXT_NAME}"
}
# @FUNCTION: php-ext-source-r3_addextension
# @USAGE: <extension-path> <ini-file>
# @INTERNAL
# @DESCRIPTION:
# Add a line to an INI file that will enable the given extension. The
# first parameter is the path to the extension (.so) file, and the
# second parameter is the name of the INI file in which it should be
# loaded. This function determines the setting name (either
# "extension=..." or "zend_extension=...") and then calls
# php-ext-source-r3_addtoinifile to do the actual work.
php-ext-source-r3_addextension() {
local ext_type="extension"
local ext_file="${1}"
if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
ext_type="zend_extension"
ext_file="${EXT_DIR}/${1}" # Zend extensions need the path...
fi
php-ext-source-r3_addtoinifile "${2}" "${ext_type}" "${ext_file}"
}
# @FUNCTION: php-ext-source-r3_addtoinifile
# @USAGE: <relative-ini-path> <setting-or-section-name> [setting-value]
# @INTERNAL
# @DESCRIPTION:
# Add a setting=value to one INI file. The first argument is the
# relative path to the INI file. The second argument is the setting
# name, and the third argument is its value.
#
# You can also pass "[Section]" as the second parameter, to create a new
# section in the INI file. In that case, the third parameter (which
# would otherwise be the value of the setting) is ignored.
php-ext-source-r3_addtoinifile() {
local inifile="${WORKDIR}/${1}"
local inidir="${inifile%/*}"
mkdir -p "${inidir}" || die "failed to create INI directory ${inidir}"
# Are we adding the name of a section? Assume not by default.
local my_added="${2}=${3}"
if [[ ${2:0:1} == "[" ]] ; then
# Ok, it's a section name.
my_added="${2}"
fi
echo "${my_added}" >> "${inifile}" || die "failed to append to ${inifile}"
einfo "Added '${my_added}' to /${1}"
insinto "/${1%/*}"
doins "${inifile}"
}
# @FUNCTION: php-ext-source-r3_addtoinifiles
# @USAGE: <setting-or-section-name> [setting-value] [message]
# @DESCRIPTION:
# Add settings to every php.ini file installed by this extension.
# You can also add new [Section]s -- see the example below.
#
# @CODE
# Add some settings for the extension:
#
# php-ext-source-r3_addtoinifiles "zend_optimizer.optimization_level" "15"
# php-ext-source-r3_addtoinifiles "zend_optimizer.enable_loader" "0"
# php-ext-source-r3_addtoinifiles "zend_optimizer.disable_licensing" "0"
#
# Adding values to a section in php.ini file installed by the extension:
#
# php-ext-source-r3_addtoinifiles "[Debugger]"
# php-ext-source-r3_addtoinifiles "debugger.enabled" "on"
# php-ext-source-r3_addtoinifiles "debugger.profiler_enabled" "on"
# @CODE
php-ext-source-r3_addtoinifiles() {
local slot
for slot in $(php_get_slots); do
for file in $(php_slot_ini_files "${slot}") ; do
php-ext-source-r3_addtoinifile "${file}" "${1}" "${2}"
done
done
}
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-06-20 23:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-01 16:53 [gentoo-dev] [PATCH 0/2] New revisions of PHP extension eclasses Michael Orlitzky
2016-06-01 16:53 ` [gentoo-dev] [PATCH 1/2] php-ext-source-r3.eclass: new revision supporting EAPI=6 Michael Orlitzky
2016-06-01 17:47 ` Michał Górny
2016-06-02 12:27 ` Michael Orlitzky
2016-06-08 19:34 ` Michał Górny
2016-06-20 23:41 ` Michael Orlitzky
2016-06-01 16:53 ` [gentoo-dev] [PATCH 2/2] php-ext-pecl-r3.eclass: " Michael Orlitzky
2016-06-01 17:53 ` Michał Górny
2016-06-01 21:19 ` Michael Orlitzky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox