FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 10-03-2010, 11:41 AM
Ole Markus With
 
Default Revbumped php-ext-* eclasses

Hi all,

As a step towards minor version slotting of PHP, we need allow PHP
extensions to compile against multiple versions of PHP and the attached
eclasses allow for just that. In addition, there are numerous cleanups,
such as the merging of php-ext-base and php-ext-source, dropping
dependency on the depend.php eclass.

The eclass goes together with the minor version slotted ebuilds and an
eselect module that can currently be found in the gentoo overlay[1].
Once these revised eclasses have been accepted, the ebuilds and the
eselect module will enter the tree in a masked state and we will
gradually rewrite PHP extension ebuilds to support minor version slotting.

Since we want to use USE_EXPAND, adding these eclasses also involves
adding the PHP_TARGETS variable to USE_EXPAND.

The eclasses have mostly been revised by me, and I do not have that much
experience writing eclasses/ebuilds, so any comments are highly appreciated.

[1] http://git.overlays.gentoo.org/gitweb/?p=proj/php.git

Cheers,
Ole Markus
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-pecl-r1.eclass,v 1.11 2008/01/06 19:30:24 swegener Exp $
#
# Author: Tal Peer <coredumb@gentoo.org>
# Author: Luca Longinotti <chtekk@gentoo.org>
# Author: Jakub Moc <jakub@gentoo.org>

# @ECLASS: php-ext-pecl-r1.eclass
# @MAINTAINER:
# Gentoo PHP team <php-bugs@gentoo.org>
# @BLURB: A uniform way of installing PECL extensions
# @DESCRIPTION:
# This eclass should be used by all dev-php[45]/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 gets set
# correctly by the eclass.
#
# Setting this variable manually also affects PHP_EXT_NAME and ${S}
# unless you override those in ebuild. Also see PHP_EXT_PECL_FILENAME
# if this is not desired for whatever reason.

# @ECLASS-VARIABLE: PHP_EXT_PECL_FILENAME
# @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 "${PHP_EXT_PECL_PKG}" ]] && PHP_EXT_PECL_PKG="${PN/pecl-/}"

PECL_PKG="${PHP_EXT_PECL_PKG}"
MY_PV="${PV/_/}"
PECL_PKG_V="${PECL_PKG}-${MY_PV}"

[[ -z "${PHP_EXT_NAME}" ]] && PHP_EXT_NAME="${PECL_PKG}"

inherit php-ext-source-r2

EXPORT_FUNCTIONS src_compile src_install src_test

if [[ -n "${PHP_EXT_PECL_FILENAME}" ]] ; then
FILENAME="${PHP_EXT_PECL_FILENAME}-${MY_PV}.tgz"
else
FILENAME="${PECL_PKG_V}.tgz"
fi

SRC_URI="http://pecl.php.net/get/${FILENAME}"
HOMEPAGE="http://pecl.php.net/${PECL_PKG}"

S="${WORKDIR}/${PECL_PKG_V}"

# @FUNCTION: php-ext-pecl-r1_src_compile
# @DESCRIPTION:
# Takes care of standard compile for PECL packages.
php-ext-pecl-r2_src_compile() {
php-ext-source-r2_src_compile
}

# @FUNCTION: php-ext-pecl-r1_src_install
# @DESCRIPTION:
# Takes care of standard install for PECL packages.
# You can also simply add examples to IUSE to automagically install
# examples supplied with the package.

# @VARIABLE: DOCS
# @DESCRIPTION:
# Set in ebuild if you wish to install additional, package-specific documentation.
php-ext-pecl-r2_src_install() {
php-ext-source-r2_src_install

for doc in ${DOCS} "${WORKDIR}"/package.xml CREDITS ; do
[[ -s ${doc} ]] && dodoc ${doc}
done

if has examples ${IUSE} && use examples ; then
insinto /usr/share/doc/${CATEGORY}/${PF}/examples
doins -r examples/*
fi
}


# @FUNCTION: php-ext-pecl-r2_src_test
# @DESCRIPTION:
# Takes care of running any tests delivered with the PECL package.
# Testing is somewhat standardized across pecl extensions through phpize's
# run-tests.php - unfortunatly there are some quirks we need to work around
php-ext-pecl-r2_src_test() {

for slot in `php_get_slots`; do
NO_INTERACTION="yes" emake test
done

}
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-source-r1.eclass,v 1.19 2008/05/09 13:02:04 hoffie Exp $
#
# Author: Tal Peer <coredumb@gentoo.org>
# Author: Stuart Herbert <stuart@gentoo.org>
# Author: Luca Longinotti <chtekk@gentoo.org>
# Author: Jakub Moc <jakub@gentoo.org> (documentation)
# Author: Ole Markus With <olemarkus@gentoo.org>

# @ECLASS: php-ext-source-r2.eclass
# @MAINTAINER:
# Gentoo PHP team <php-bugs@gentoo.org>
# @BLURB: A unified interface for compiling and installing standalone PHP extensions.
# @DESCRIPTION:
# This eclass provides a unified interface for compiling and installing standalone
# PHP extensions (modules).

inherit flag-o-matic autotools

EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install

# @ECLASS-VARIABLE: PHP_EXT_NAME
# @DESCRIPTION:
# The extension name. This must be set, otherwise the eclass dies.
# Only automagically set by php-ext-pecl-r1.eclass, so unless your ebuild
# inherits that eclass, you must set this manually before inherit.
[[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"

DEPEND=">=sys-devel/m4-1.4.3
>=sys-devel/libtool-1.5.18"
RDEPEND=""

# Because of USE deps, we require at least EAPI 2
case ${EAPI} in
2|3) ;;
*)
die "php-ext-source-r2 is not compatible with EAPI=${EAPI}"
esac

# @ECLASS-VARIABLE: PHP_EXT_NAME
# @DESCRIPTION:
# The extension name. This must be set, otherwise the eclass dies.
# Only automagically set by php-ext-pecl-r2.eclass, so unless your ebuild
# inherits that eclass, you must set this manually before inherit.
[[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 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" and if you don't know what is it, you don't need it.
[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"

# @ECLASS-VARIABLE: USE_PHP
# @DESCRIPTION:
# Lists the PHP slots compatibile the extension is compatibile with
[[ -z "$USE_PHP" ]] && USE_PHP="php5-2 php5-3"

for target in $USE_PHP; do
IUSE="${IUSE} php_targets_$target"
done

#Make sure at least one target is installed. Abuses USE dependencies.
for target in $USE_PHP; do
target=${target/+}
SELFDEPEND="$SELFDEPEND =$CATEGORY/$PF[php_targets_$target]"
slot=${target/php}
slot=${slot/-/.}
PHPDEPEND="$PHPDEPEND php_target_$target? ( dev-lang/php:${slot} )"
done

RDEPEND="${RDEPEND}
|| ( $SELFDEPEND )
$PHPDEPEND"


# @FUNCTION: php-ext-source-r2_src_unpack
# @DESCRIPTION:
# runs standard src_unpack + _phpize
#
# @VARIABLE: PHP_EXT_SKIP_PHPIZE
# @DESCRIPTION:
# phpize will be run by default for all ebuilds that use
# php-ext-source-r1_src_unpack
# Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize.
php-ext-source-r2_src_unpack() {
unpack ${A}
local slot orig_s="$S"
for slot in $(php_get_slots); do
cp -r "$orig_s" "${WORKDIR}/$slot"
php_init_slot_env $slot
if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
php-ext-source-r2_phpize
fi
done
}

# @FUNCTION php-ext-source-r2_phpize
# @DESCRIPTION:
# Runs phpize and autotools in addition to the standard src_unpack
php-ext-source-r2_phpize() {
# Create configure out of config.m4
# I wish I could run this to solve #329071, but I cannot
#autotools_run_tool ${PHPIZE}
${PHPIZE}
# force run of libtoolize and regeneration of related autotools
# files (bug 220519)
rm aclocal.m4
eautoreconf
}

# @FUNCTION: php-ext-source-r2_src_configure
# @DESCRIPTION:
# Takes care of standard configure for PHP extensions (modules).
#
# @VARIABLE: my_conf
# @DESCRIPTION:
# Set this in the ebuild to pass configure options to econf.
php-ext-source-r2_src_configure() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env $slot
# Set the correct config options
# We cannot use econf here, phpize/php-config deals with setting
# --prefix etc to whatever the php slot was configured to use
./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile"
done
}

# @FUNCTION: php-ext-source-r2_src_compile
# @DESCRIPTION:
# Takes care of standard compile for PHP extensions (modules).
php-ext-source-r2_src_compile() {
# net-snmp creates this file #324739
addpredict /usr/share/snmp/mibs/.index
# shm extension createss a semaphore file #173574
addpredict /session_mm_cli0.sem
local slot
for slot in $(php_get_slots); do
php_init_slot_env $slot
emake || die "Unable to make code"

done
}

# @FUNCTION: php-ext-source-r1_src_install
# @DESCRIPTION:
# Takes care of standard install for PHP extensions (modules).

# @VARIABLE: DOCS
# @DESCRIPTION:
# Set in ebuild if you wish to install additional, package-specific documentation.
php-ext-source-r2_src_install() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env $slot

# Let's put the default module away
insinto "${EXT_DIR}"
newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension"

for doc in ${DOCS} ; do
[[ -s ${doc} ]] && dodoc ${doc}
done

done
php-ext-source-r2_createinifiles
}


php_get_slots() {
local s
local slot
for slot in $USE_PHP; do
use php_targets_$slot && s+=" ${slot/-/.}"
done
echo $s
}

php_init_slot_env() {
libdir=$(get_libdir)

PHPIZE="/usr/${libdir}/$1/bin/phpize"
PHPCONFIG="/usr/${libdir}/$1/bin/php-config"
PHPCLI="/usr/${libdir}/$1/bin/php"
PHPCGI="/usr/${libdir}/$1/bin/php-cgi"
PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
PHPPREFIX="/usr/${libdir}/$slot"
EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"

S="${WORKDIR}/$1"
cd $S
}

php-ext-source-r2_buildinilist() {
# Work out the list of <ext>.ini files to edit/add to
if [[ -z "${PHPSAPILIST}" ]] ; then
PHPSAPILIST="apache2 cli cgi fpm"
fi

PHPINIFILELIST=""

for x in ${PHPSAPILIST} ; do
if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then
PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
fi
done
}

# @FUNCTION: php-ext-source-r2_createinifiles
# @DESCRIPTION:
# Builds ini files for every enabled slot and SAPI
php-ext-source-r2_createinifiles() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env $slot
# Pull in the PHP settings

# Build the list of <ext>.ini files to edit/add to
php-ext-source-r2_buildinilist $slot

# Add the needed lines to the <ext>.ini files
if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
php-ext-source-r2_addextension "${PHP_EXT_NAME}.so"
fi

# Symlink the <ext>.ini files from ext/ to ext-active/
for inifile in ${PHPINIFILELIST} ; do
inidir="${inifile/${PHP_EXT_NAME}.ini/}"
inidir="${inidir/ext/ext-active}"
dodir "/${inidir}"
dosym "/${inifile}" "/${inifile/ext/ext-active}"
done

# Add support for installing PHP files into a version dependant directory
PHP_EXT_SHARED_DIR="/usr/share/php/${PHP_EXT_NAME}"
done
}

php-ext-source-r2_addextension() {
if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
# We need the full path for ZendEngine extensions
# and we need to check for debugging enabled!
if has_zts ; then
if has_debug ; then
ext_type="zend_extension_debug_ts"
else
ext_type="zend_extension_ts"
fi
ext_file="${EXT_DIR}/$1"
else
if has_debug ; then
ext_type="zend_extension_debug"
else
ext_type="zend_extension"
fi
ext_file="${EXT_DIR}/$1"
fi

# php-5.3 unifies zend_extension loading and just requires the
# zend_extension keyword with no suffix
# TODO: drop previous code and this check once <php-5.3 support is
# discontinued
if has_version '>=dev-lang/php-5.3' ; then
ext_type="zend_extension"
fi
else
# We don't need the full path for normal extensions!
ext_type="extension"
ext_file="$1"
fi

php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added"
}

# $1 - Setting name
# $2 - Setting value
# $3 - File to add to
# $4 - Sanitized text to output
php-ext-source-r2_addtoinifile() {
if [[ ! -d $(dirname $3) ]] ; then
mkdir -p $(dirname $3)
fi

# Are we adding the name of a section?
if [[ ${1:0:1} == "[" ]] ; then
echo "$1" >> "$3"
my_added="$1"
else
echo "$1=$2" >> "$3"
my_added="$1=$2"
fi

if [[ -z "$4" ]] ; then
einfo "Added '$my_added' to /$3"
else
einfo "$4 to /$3"
fi

insinto /$(dirname $3)
doins "$3"
}

# @FUNCTION: php-ext-source-r2_addtoinifiles
# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
# @DESCRIPTION:
# Add value settings to php.ini file installed by the extension (module).
# You can also add a [section], see examples below.
#
# @CODE
# Add some settings for the extension:
#
# php-ext-source-r2_addtoinifiles "zend_optimizer.optimization_level" "15"
# php-ext-source-r2_addtoinifiles "zend_optimizer.enable_loader" "0"
# php-ext-source-r2_addtoinifiles "zend_optimizer.disable_licensing" "0"
#
# Adding values to a section in php.ini file installed by the extension:
#
# php-ext-source-r2_addtoinifiles "[Debugger]"
# php-ext-source-r2_addtoinifiles "debugger.enabled" "on"
# php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on"
# @CODE
php-ext-source-r2_addtoinifiles() {
for x in ${PHPINIFILELIST} ; do
php-ext-source-r2_addtoinifile "$1" "$2" "$x" "$3"
done
}
 
Old 10-06-2010, 06:06 PM
Donnie Berkholz
 
Default Revbumped php-ext-* eclasses

On 13:41 Sun 03 Oct , Ole Markus With wrote:
> The eclasses have mostly been revised by me, and I do not have that much
> experience writing eclasses/ebuilds, so any comments are highly appreciated.

> php-ext-pecl-r2_src_install() {
> php-ext-source-r2_src_install
>
> for doc in ${DOCS} "${WORKDIR}"/package.xml CREDITS ; do
> [[ -s ${doc} ]] && dodoc ${doc}
> done
>
> if has examples ${IUSE} && use examples ; then
> insinto /usr/share/doc/${CATEGORY}/${PF}/examples
> doins -r examples/*
> fi
> }

Do you want to die if this stuff fails?

> # @FUNCTION: php-ext-pecl-r2_src_test
> # @DESCRIPTION:
> # Takes care of running any tests delivered with the PECL package.
> # Testing is somewhat standardized across pecl extensions through phpize's
> # run-tests.php - unfortunatly there are some quirks we need to work around
> php-ext-pecl-r2_src_test() {
>
> for slot in `php_get_slots`; do
> NO_INTERACTION="yes" emake test
> done

emake doesn't die on failure.

> for target in $USE_PHP; do
> IUSE="${IUSE} php_targets_$target"
> done
>
> #Make sure at least one target is installed. Abuses USE dependencies.
> for target in $USE_PHP; do
> target=${target/+}
> SELFDEPEND="$SELFDEPEND =$CATEGORY/$PF[php_targets_$target]"
> slot=${target/php}
> slot=${slot/-/.}
> PHPDEPEND="$PHPDEPEND php_target_$target? ( dev-lang/php:${slot} )"
> done

Why do you iterate over the same list twice? You can just add one more
line to the second one and do it all in the same loop.

> RDEPEND="${RDEPEND}
> || ( $SELFDEPEND )
> $PHPDEPEND"

Is that || valid syntax if only one token is in SELFDEPEND? Is it
possible for an ebuild to use this eclass without setting USE_PHP?

--
Thanks,
Donnie

Donnie Berkholz
Sr. Developer, Gentoo Linux
Blog: http://dberkholz.wordpress.com
 
Old 10-06-2010, 07:36 PM
Ole Markus With
 
Default Revbumped php-ext-* eclasses

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Donnie!

Thanks for the input

On 06/10/10 20:06, Donnie Berkholz wrote:
> On 13:41 Sun 03 Oct , Ole Markus With wrote:
>> The eclasses have mostly been revised by me, and I do not have that much
>> experience writing eclasses/ebuilds, so any comments are highly appreciated.
>
>> php-ext-pecl-r2_src_install() {
>> php-ext-source-r2_src_install
>>
>> for doc in ${DOCS} "${WORKDIR}"/package.xml CREDITS ; do
>> [[ -s ${doc} ]] && dodoc ${doc}
>> done
>>
>> if has examples ${IUSE} && use examples ; then
>> insinto /usr/share/doc/${CATEGORY}/${PF}/examples
>> doins -r examples/*
>> fi
>> }
>
> Do you want to die if this stuff fails?
>

Sure.

>> # @FUNCTION: php-ext-pecl-r2_src_test
>> # @DESCRIPTION:
>> # Takes care of running any tests delivered with the PECL package.
>> # Testing is somewhat standardized across pecl extensions through phpize's
>> # run-tests.php - unfortunatly there are some quirks we need to work around
>> php-ext-pecl-r2_src_test() {
>>
>> for slot in `php_get_slots`; do
>> NO_INTERACTION="yes" emake test
>> done
>
> emake doesn't die on failure.
>

Will add die here then.

>> for target in $USE_PHP; do
>> IUSE="${IUSE} php_targets_$target"
>> done
>>
>> #Make sure at least one target is installed. Abuses USE dependencies.
>> for target in $USE_PHP; do
>> target=${target/+}
>> SELFDEPEND="$SELFDEPEND =$CATEGORY/$PF[php_targets_$target]"
>> slot=${target/php}
>> slot=${slot/-/.}
>> PHPDEPEND="$PHPDEPEND php_target_$target? ( dev-lang/php:${slot} )"
>> done
>
> Why do you iterate over the same list twice? You can just add one more
> line to the second one and do it all in the same loop.
>

I can certainly merge these loops. No particular reason for having two
loops.

>> RDEPEND="${RDEPEND}
>> || ( $SELFDEPEND )
>> $PHPDEPEND"
>
> Is that || valid syntax if only one token is in SELFDEPEND? Is it
> possible for an ebuild to use this eclass without setting USE_PHP?
>


When I have tested this, nothing has complained by having only one atom
inside || ( ). It may not make much sense semantically, but it works.
Naturally, it could be that other package managers doesn't like this
syntax, and if so, there should be no problem to do add a test for
whether $USE_PHP contains either 1 or >=2 words.

The eclass sets a default value for $USE_PHP if unset somewhere in the
top of the eclass. Most ebuilds will not set USE_PHP.


Thanks for your time reviewing this eclass.

- --
Ole Markus
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMrM+nAAoJEGurSuXEqSv1Ho4IAK/wUnSdYX3fLQJ7zhm6iamG
Sx00/XWnmk/6T6skzlxI4HaTWc4mp1zBNQndni3WtGai/d60FeKw0uMmN6ynk19o
vcg8zWmaUlgva5U91jz8ryiKgTv5xngWCb7SqH67Ce1GthAhPs apyK7DTRkCYwyx
mJIW4YlJ4+fVV8OONG1y7UGIjcdvTkXHFr1at6tITkK72kgxgB QDVWRfZAdVomBr
5hdVkRDEht8So9ov2TPPOrmBoKHpE5LmJPTPm9GDNHN+J7W24i WornArtQ8xbfPT
RPTgsBZxkCrxwEpNiiEKteVioZb/I/5gfPFbW9a5hZt6ScMQAbBf+pulplQxkEw=
=mQiJ
-----END PGP SIGNATURE-----
 
Old 10-09-2010, 04:19 PM
Peter Volkov
 
Default Revbumped php-ext-* eclasses

Hi!

В Вск, 03/10/2010 в 13:41 +0200, Ole Markus With пишет:
> for slot in `php_get_slots`; do

It's better use $() instead of backticks:
http://mywiki.wooledge.org/BashFAQ/082

> [[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
>
...
> [[ -z "$USE_PHP" ]] && USE_PHP="php5-2 php5-3"

In some places eclass uses ${var} syntax but here and later it uses
$var. I'm not sure which syntax is better but in Gentoo we use ${var}
and for readability it's better to stick to single style.

> php_get_slots() {
> local s
> local slot

single $(local s slot) is enough here.

> php_init_slot_env() {
...
> S="${WORKDIR}/$1"
> cd $S

S is unquoted, and ${}

> php-ext-source-r2_buildinilist() {
...
> for x in ${PHPSAPILIST} ; do

local x?

--
Peter.
 

Thread Tools




All times are GMT. The time now is 05:21 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org