# SliTaz package receipt.

PACKAGE="php-pear"
VERSION="5.2.17"
CATEGORY="development"
SHORT_DESC="PHP web programming language pear libs."
MAINTAINER="pascal.bellard@slitaz.org"
DEPENDS="php-cli"
WEB_SITE="http://www.php.net/"
WANTED="php"

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
        mkdir -p $fs/usr/share $fs/usr/bin $fs/etc
        cp -a $_pkg/usr/share/php $fs/usr/share
        cp $_pkg/etc/pear.conf $fs/etc
        cp $_pkg/usr/bin/pe* $fs/usr/bin
}

# Pre and post install commands for Tazpkg.
pre_install()
{
	while read daemon file; do
		if [ -z "$1" -a -f "/var/run/$file" ]; then
			/etc/init.d/$daemon stop
		fi
	done <<EOT
apache apache/httpd.pid
lighttpd lighttpd.pid
EOT
}

post_install()
{
	grep ^include_path $1/etc/php.ini
	sed -i 's|/php/includes"|/php/includes"\ninclude_path = ".:/usr/share/php"|' $1/etc/php.ini
	# Restart Web server.
	while read daemon file; do
		[ -z "$1" ] || continue
		if [ -f "/var/run/$file" ]; then
			/etc/init.d/$daemon stop
			sleep 2
		fi
		if [ -f /etc/init.d/$daemon ]; then
			/etc/init.d/$daemon start
		fi
	done <<EOT
apache apache/httpd.pid
lighttpd lighttpd.pid
EOT
}