~alpine/aports

[alpine-aports] [PATCH 2/2] main/php5: reuse community/php7 APKBUILD to build this one

Details
Message ID
<20161209144602.12503-1-valery.kartel@gmail.com>
Sender timestamp
1481294762
DKIM signature
missing
Download raw message
Patch: +877 -505
--
synchronized with php7 APKBUILD
php5 specific extensions: mssql, mysql are there
all features implemented in php7 are now in php5

to switch system-default php binary just run:
'apk fix php5-common'
'apk fix php7-common'
---
 main/php5/APKBUILD                                 | 671 ++++++++-------------
 main/php5/gd-iconv.patch                           |  45 --
 main/php5/includedir.patch                         |  41 ++
 ...p-install-pear-xml.patch => install-pear.patch} |   0
 main/php5/php-fpm.patch                            | 534 ++++++++++++++++
 main/php5/php5-common.pre-deinstall                |   5 +
 main/php5/php5-common.pre-upgrade                  |   7 +
 main/php5/php5-common.trigger                      |   9 +
 main/php5/{php-fpm.initd => php5-fpm.initd}        |  35 +-
 main/php5/php5-fpm.logrotate                       |  13 +
 main/php5/php5.post-upgrade                        |  11 -
 main/php5/tidy-buffio.patch                        |  11 +
 12 files changed, 877 insertions(+), 505 deletions(-)
 delete mode 100644 main/php5/gd-iconv.patch
 create mode 100644 main/php5/includedir.patch
 rename main/php5/{php-install-pear-xml.patch => install-pear.patch} (100%)
 create mode 100644 main/php5/php-fpm.patch
 create mode 100644 main/php5/php5-common.pre-deinstall
 create mode 100644 main/php5/php5-common.pre-upgrade
 create mode 100644 main/php5/php5-common.trigger
 rename main/php5/{php-fpm.initd => php5-fpm.initd} (73%)
 create mode 100644 main/php5/php5-fpm.logrotate
 delete mode 100644 main/php5/php5.post-upgrade
 create mode 100644 main/php5/tidy-buffio.patch

diff --git a/main/php5/APKBUILD b/main/php5/APKBUILD
index 69cda09009..89c3faaf12 100644
--- a/main/php5/APKBUILD
+++ b/main/php5/APKBUILD
@@ -1,518 +1,337 @@
# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Andy Blyler <andy@blyler.cc>
# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Matt Smith <mcs@darkregion.net>
provides=php
pkgname=php5
pkgver=5.6.29
pkgrel=0
pkgdesc="The PHP language runtime engine"
_apiver="20131106"
pkgdesc="The PHP language runtime engine - 5th branch"
url="http://www.php.net/"
arch="all"
license="PHP-3"
depends="$pkgname-cli"
depends_dev="$pkgname-cli pcre-dev"
install="$pkgname.post-upgrade"
provides="php"
makedepends="
	$depends_dev
	apache2-dev
	apr-dev
	apr-util-dev
	aspell-dev
	bzip2-dev
	curl-dev
	db-dev
	enchant-dev
	expat-dev
	freetds-dev
	freetype-dev
	gdbm-dev
	gettext-dev
	gmp-dev
	icu-dev
	imap-dev
	libevent-dev
	libgcrypt-dev
	libjpeg-turbo-dev
	libmcrypt-dev
	libpng-dev
	libtool
	libxml2-dev
	libxslt-dev
	mariadb-dev
	net-snmp-dev
	openldap-dev
	libressl-dev
	postgresql-dev
	readline-dev
	sqlite-dev
	unixodbc-dev
	zlib-dev
	autoconf
	bison
options=""
install="$pkgname-common.pre-upgrade $pkgname-common.pre-deinstall"
triggers="$pkgname-common.trigger=/usr/bin"
depends="$pkgname-common"
depends_dev="$pkgname-pear"
depends_imap="-- $depends_recode"
depends_mysql="-- $depends_recode"
depends_mysqlnd="$pkgname-mysqli $depends_mysqli"
depends_pdo_mysql="$pkgname-pdo $depends_pdo"
depends_pdo_odbc="$pkgname-pdo $depends_pdo"
depends_pdo_pgsql="$pkgname-pdo $depends_pdo"
depends_pdo_sqlite="$pkgname-pdo $depends_pdo"
depends_dom="$pkgname-xml $depends_xml"
depends_soap="$pkgname-xml $depends_xml"
depends_wddx="$pkgname-xml $depends_xml"
depends_xmlrpc="$pkgname-xml $depends_xml"
depends_xmlreader="$pkgname-dom $depends_dom"
depends_xsl="$pkgname-dom $depends_dom"
_prefix_opcache="zend_"
makedepends="autoconf bison re2c apache2-dev libxml2-dev libxslt-dev libzip-dev bzip2-dev zlib-dev
	aspell-dev enchant-dev expat-dev pcre-dev curl-dev gmp-dev icu-dev imap-dev
	libical-dev libressl-dev openldap-dev net-snmp-dev db-dev krb5-dev gdbm-dev sqlite-dev
	freetds-dev mariadb-dev postgresql-dev unixodbc-dev freetype-dev tidyhtml-dev libxpm-dev
	libpng-dev libwebp-dev libjpeg-turbo-dev libmcrypt-dev gsoap-dev recode-dev
	readline-dev gettext-dev
	"
subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-common::noarch $pkgname-cgi
	$pkgname-cli $pkgname-fpm $pkgname-apache2 $pkgname-embed
	$pkgname-phpdbg

	$pkgname-pear::noarch
	$pkgname-bcmath
	$pkgname-bz2
	$pkgname-calendar
	$pkgname-ctype
	$pkgname-curl:_curl
	$pkgname-dba
	$pkgname-dom
	$pkgname-enchant
	$pkgname-exif
	$pkgname-ftp
	$pkgname-gd
	$pkgname-gettext
	$pkgname-gmp
	$pkgname-iconv
	$pkgname-imap
	$pkgname-intl
	$pkgname-json
	$pkgname-ldap
	$pkgname-mcrypt
	$pkgname-mysql
	$pkgname-mysqli
	$pkgname-odbc
	$pkgname-openssl
	$pkgname-pcntl
	$pkgname-pdo
	$pkgname-pdo_mysql
	$pkgname-pdo_odbc
	$pkgname-pdo_pgsql
	$pkgname-pdo_sqlite
	$pkgname-pgsql
	$pkgname-phar
	$pkgname-posix
	$pkgname-pspell
	$pkgname-shmop
	$pkgname-snmp
	$pkgname-soap
	$pkgname-sockets
	$pkgname-sqlite3
	$pkgname-sysvmsg
	$pkgname-sysvsem
	$pkgname-sysvshm
	$pkgname-xml
	$pkgname-xmlreader
	$pkgname-xmlrpc
	$pkgname-xsl
	$pkgname-zip
	$pkgname-zlib
	$pkgname-mssql
	$pkgname-pdo_dblib
	$pkgname-wddx
	$pkgname-opcache
source="http://php.net/distributions/$provides-$pkgver.tar.bz2
	$pkgname-fpm.initd
	$pkgname-fpm.logrotate
	$pkgname-module.conf
	install-pear.patch
	tidy-buffio.patch
	includedir.patch
	php-fpm.patch
	"

source="http://php.net/distributions/php-$pkgver.tar.bz2
	php-fpm.initd
	php5-module.conf
	php-install-pear-xml.patch
	gd-iconv.patch
_exts5="mssql mysql"
_exts="bcmath bz2 calendar ctype curl dba dom enchant exif ftp gd gettext gmp iconv imap intl json
	ldap mbstring mcrypt mysqli mysqlnd odbc opcache openssl pcntl pdo pdo_dblib pdo_mysql
	pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell recode session shmop snmp soap
	sockets sqlite3 sysvmsg sysvsem sysvshm tidy wddx xml xmlreader xmlrpc xsl zip zlib
	"

_apiver="20131106"
_extdir="/usr/lib/$pkgname/modules"
_srcdir="$srcdir"/php-$pkgver
_confdir=/etc/$pkgname

# seems like pear hardcode /usr/share/pear directory
_peardir=/usr/share/pear
subpackages="$pkgname-dev $pkgname-doc $pkgname-apache2 $pkgname-phpdbg $pkgname-embed
	$pkgname-litespeed $pkgname-cgi $pkgname-fpm $pkgname-pear::noarch
	"
for _ext in $_exts $_exts5; do
	subpackages="$subpackages $pkgname-$_ext:_default_ext"
done
subpackages="$subpackages $pkgname-common::noarch"
builddir="$srcdir"/$provides-$pkgver

prepare() {
	cd "$_srcdir"
	update_config_sub
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done

	# safty check for api changes
	cd "$builddir"
	default_prepare || return 1
	update_config_sub || return 1
	local vapi=$(sed -n '/#define PHP_API_VERSION/{s/.* //;p}' main/php.h)
	if [ "$vapi" != "$_apiver" ]; then
		error "Upstreram API version is now $vapi. Expecting $_vapi"
		error "Upstreram API version is now $vapi. Expecting $_apiver"
		return 1
	fi
	autoconf
}

_do_build() {
	local _flavor="$1"
	shift
	local _builddir="$srcdir"/build-$_flavor
	mkdir -p "$_builddir"
	cd "$_builddir"
	export EXTENSION_DIR=$_extdir
	export PEAR_INSTALLDIR="$_peardir"
	"$_srcdir"/configure $@ || return 1
	sed -ri "s/^(EXTRA_LDFLAGS[ ]*\=.*)/\1 -lpthread/" Makefile  # see #183
	make || return 1
}

build() {
	_phpconfig="\
_build() {
	export EXTENSION_DIR=/usr/lib/$pkgname/modules
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=$_confdir \
		--libdir=/usr/lib/$pkgname \
		--datadir=/usr/share/$pkgname \
		--sysconfdir=/etc/$pkgname \
		--localstatedir=/var \
		--with-layout=GNU \
		--with-config-file-path=$_confdir \
		--with-config-file-scan-dir=$_confdir/conf.d \
		--enable-inline-optimization \
		--disable-debug \
		--disable-rpath \
		--disable-static \
		--enable-shared \
		--mandir=/usr/share/man \
		--with-pic \
		"

	_phpextensions=" \
		--with-pear=/usr/share/$provides \
		--with-config-file-path=/etc/$pkgname \
		--with-config-file-scan-dir=/etc/$pkgname/conf.d \
		--disable-short-tags \
		--with-openssl=shared --with-kerberos --with-system-ciphers \
		--with-pcre-regex --with-pcre-dir \
		--with-zlib=shared --with-zlib-dir \
		--enable-bcmath=shared \
		  --with-bz2=shared \
		--with-bz2=shared \
		--enable-calendar=shared \
		  --with-cdb \
		--enable-ctype=shared \
		  --with-curl=shared \
		--enable-dba=shared \
		  --with-db4=shared \
		--with-curl=shared \
		--enable-dba=shared --with-gdbm --with-db4 \
		--enable-dom=shared \
		  --with-enchant=shared \
		--with-enchant=shared \
		--enable-exif=shared \
		  --with-freetype-dir=shared,/usr \
		--enable-ftp=shared \
		  --with-gd=shared \
		--enable-gd-native-ttf \
		  --with-gdbm=shared \
		  --with-gettext=shared \
		  --with-gmp=shared \
		  --with-iconv=shared \
		  --with-icu-dir=/usr \
		  --with-imap=shared \
		  --with-imap-ssl=shared \
		--enable-intl=shared \
		  --with-jpeg-dir=shared,/usr \
		--with-gd=shared --with-webp-dir=shared --with-jpeg-dir=shared --with-png-dir=shared --with-xpm-dir=shared \
		--with-freetype-dir=shared --enable-gd-native-ttf --enable-gd-jis-conv \
		--with-gettext=shared \
		--with-gmp=shared \
		--with-iconv=shared \
		--enable-intl=shared --with-icu-dir=/usr \
		--enable-json=shared \
		  --with-ldap=shared \
		--enable-libxml=shared \
		--enable-mbregex \
		--enable-mbstring=all \
		  --with-mcrypt=shared \
		  --with-mysql=shared,mysqlnd \
		  --with-mysql-sock=/var/run/mysqld/mysqld.sock \
		  --with-mysqli=shared,mysqlnd \
		  --with-openssl=shared \
		  --with-pcre-regex=/usr \
		--enable-pcntl=shared \
		--enable-libxml=shared --with-libxml-dir=shared --with-libexpat-dir=shared \
		--with-ldap=shared --with-ldap-sasl \
		--enable-mbstring=shared --enable-mbregex \
		--with-mssql=shared \
		--with-mcrypt=shared \
		--with-sqlite3=shared,/usr --with-pdo-sqlite=shared,/usr \
		--with-pdo-dblib=shared \
		--with-mysql=shared,mysqlnd \
		--with-mysqli=shared,/usr/bin/mysql_config \
		--enable-mysqlnd=shared --with-pdo-mysql=shared,/usr/bin/mysql_config --with-mysql-sock=/run/mysqld/mysqld.sock \
		--with-pgsql=shared --with-pdo-pgsql=shared \
		--with-unixODBC=shared,/usr -with-pdo-odbc=shared,unixODBC,/usr \
		--with-dbmaker=shared \
		--enable-opcache=shared \
		--enable-pdo=shared \
		  --with-pdo-mysql=shared,mysqlnd \
		  --with-pdo-odbc=shared,unixODBC,/usr \
		  --with-pdo-pgsql=shared \
		  --with-pdo-sqlite=shared,/usr \
		  --with-pgsql=shared \
		--enable-phar=shared \
		  --with-png-dir=shared,/usr \
		--enable-pcntl=shared \
		--enable-posix=shared \
		  --with-pspell=shared \
		  --with-regex=php \
		--enable-session \
		--enable-phar=shared \
		--with-pspell=shared \
		--enable-session=shared \
		--enable-shmop=shared \
		  --with-snmp=shared \
		--with-snmp=shared \
		--enable-soap=shared \
		--enable-sockets=shared \
		  --with-sqlite3=shared,/usr \
		--enable-sysvmsg=shared \
		--enable-sysvsem=shared \
		--enable-sysvshm=shared \
		  --with-unixODBC=shared,/usr \
		--with-tidy=shared \
		--enable-xml=shared \
		--enable-xmlreader=shared \
		  --with-xmlrpc=shared \
		  --with-xsl=shared \
		--with-xmlrpc=shared \
		--with-xsl=shared \
		--enable-wddx=shared \
		--enable-zip=shared \
		  --with-zlib=shared \
		--without-db1 \
		--without-db2 \
		--without-db3 \
		--without-qdbm \
		--with-mssql=shared \
		--with-pdo-dblib=shared \
		--enable-opcache \
		"

	# cgi, fcgi, cli, pear and extensions
	_do_build cgi \
		${_phpconfig} \
		--disable-cli \
		--enable-cgi \
		--enable-cli \
		--with-pear \
		--enable-zip=shared --with-libzip=shared \
		--with-readline \
		--enable-phpdbg \
		${_phpextensions} \
		|| return 1
		$@ || return 1
	sed -ri "s/^(EXTRA_LDFLAGS[ ]*\=.*)/\1 -lpthread/" Makefile  # see #183
	make || return 1
}

	# fpm
	cp -a "$srcdir"/build-cgi "$srcdir"/build-fpm
	_do_build fpm \
		${_phpconfig} \
build() {
	cd "$builddir"
	# build phpdbg
	_build --enable-phpdbg \
		--enable-phpdbg-webhelper \
		--disable-cgi \
		--disable-cli \
		--enable-fpm \
		${_phpextensions} \
		|| return 1

	# apache2
	cp -a "$srcdir"/build-cgi "$srcdir"/build-apache2
	_do_build apache2 \
		${_phpconfig} \
	# build apache2 module
	_build --disable-phpdbg \
		--disable-cgi \
		--disable-cli \
		--with-apxs2 \
		${_phpextensions} \
		|| return 1

	# embed
	cp -a "$srcdir"/build-cgi "$srcdir"/build-embed
	_do_build embed \
		${_phpconfig} \
		--disable-cli \
		--enable-embed=shared \
		${_phpextensions} \
	mv libs/lib$pkgname.so sapi/apache2handler/
	# common build - with recode
	_build --disable-phpdbg \
		--enable-fpm \
		--enable-embed \
		--with-litespeed \
		--with-recode=shared \
		|| return 1
	# common build - with imap
	_build --disable-phpdbg \
		--enable-fpm \
		--enable-embed \
		--with-litespeed \
		--with-imap=shared --with-imap-ssl \
		|| return 1
}

package() {
	cd "$srcdir"/build-cgi
	# install php-cgi, cli, pear and modules
	make -j1 install install-pear INSTALL_ROOT="$pkgdir" || return 1

	# cleanup after pear
	find "$pkgdir" -name '.*' | xargs rm -rf || return 1

	# install embed
	install -D -m755 "$srcdir"/build-embed/libs/libphp5.so \
		"$pkgdir"/usr/lib/libphp5.so || return 1
	install -D -m644 "$_srcdir"/sapi/embed/php_embed.h \
		"$pkgdir"/usr/include/php/sapi/embed/php_embed.h || return 1

	# Create symlink with version suffix, parallel to php7 package,
	# to simplify multiversion aports and prepare us for future.
	local f; for f in php php-cgi php-config phpdbg phpize; do
		ln -s $f "$pkgdir"/usr/bin/${f}5 || return 1
	done
	cd "$builddir"
	make -j1 INSTALL_ROOT="$pkgdir" install || return 1
	rm -fr "$pkgdir"/.[[:alpha:]]* "$pkgdir"/var || return 1
	mv "$pkgdir"/usr/share/man/man1/php.1 \
		"$pkgdir"/usr/share/man/man1/$pkgname.1
	mv "$pkgdir"/usr/share/man/man1/php-cgi.1 \
		"$pkgdir"/usr/share/man/man1/$pkgname-cgi.1
	mv "$pkgdir"/usr/share/man/man8/php-fpm.8 \
		"$pkgdir"/usr/share/man/man8/$pkgname-fpm.8
	mv "$pkgdir"/usr/bin/php "$pkgdir"/usr/bin/$pkgname
}

dev() {
	default_dev || return 1

	mkdir -p "$subpkgdir"/usr/lib/php
	mv "$pkgdir"/usr/lib/php/build \
		"$subpkgdir"/usr/lib/php/ || return 1
	mv "$pkgdir"/usr/bin/php-config5 "$subpkgdir"/usr/bin/
	default_dev
	replaces="php7-dev"
	provides="php-dev"
	depends="$depends $pkgname-phar"
	mv "$pkgdir"/usr/bin/phpize \
		"$pkgdir"/usr/bin/peardev \
		"$pkgdir"/usr/bin/phar* \
		"$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/lib/$pkgname/build "$subpkgdir"/usr/lib/$pkgname/
}

doc() {
	# man pages
	default_doc || return 1
	cd "$srcdir"/php-$pkgver

	# doc files
	_docs="CODING_STANDARDS CREDITS EXTENSIONS INSTALL LICENSE NEWS \
	UPGRADING UPGRADING.INTERNALS"
	for _doc in $_docs README.*; do
		install -Dm644 "$srcdir"/php-$pkgver/$_doc \
			"$subpkgdir"/usr/share/doc/$pkgname/$_doc || return 1
	default_doc
	install_if="docs $pkgname-common=$pkgver-r$pkgrel"
	cd "$builddir"
	for file in $(ls CODING_STANDARDS CREDITS EXTENSIONS INSTALL LICENSE NEWS README* UPGRADING*); do
		install -Dm644 $file "$subpkgdir"/usr/share/doc/$pkgname/$file || return 1
	done
}

common() {
	pkgdesc="PHP Common Files"
	depends=""
	cd "$srcdir"/php-$pkgver
	install -D -m644 php.ini-production "$subpkgdir"$_confdir/php.ini
	sed -i -e "s:^; extension_dir = \"./\":extension_dir = \"$_extdir\":" "$subpkgdir"/etc/php/php.ini
	sed -ri 's/;(date.timezone =)/\1 UTC/' "$subpkgdir"$_confdir/php.ini
	sed -ri "s~^([;]*cgi\.rfc2616_headers.*)$~\1\n\n\; If this is enabled, the PHP CGI binary can safely be placed outside of the\n; web tree and people will not be able to circumvent .htaccess security.\ncgi\.discard_path = 1~" "$subpkgdir"$_confdir/php.ini
apache2() {
	pkgdesc="$pkgname module for Apache2"
	depends="$pkgname-common apache2"
	install -Dm755 "$builddir"/sapi/apache2handler/lib$pkgname.so \
		"$subpkgdir"/usr/lib/apache2/lib$pkgname.so || return 1
	install -Dm644 "$srcdir"/$pkgname-module.conf \
		"$subpkgdir"/etc/apache2/conf.d/$pkgname-module.conf
}

cgi() {
	pkgdesc="PHP Common Gateway Interface (CGI)"
phpdbg() {
	pkgdesc="$pkgname interactive debugger"
	depends="$pkgname-common"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/php-cgi* "$subpkgdir"/usr/bin/
	install -Dm755 "$builddir"/sapi/phpdbg/phpdbg \
		 "$subpkgdir"/usr/bin/${pkgname}dbg
}

cli() {
	pkgdesc="PHP Command Line Interface (CLI)"
embed() {
	pkgdesc="$pkgname embedded library"
	depends="$pkgname-common"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/php "$subpkgdir"/usr/bin/ || return 1
	mv "$pkgdir"/usr/bin/php5 "$subpkgdir"/usr/bin/ || return 1
	# provide phpize here instead of -dev due to pecl command
	mv "$pkgdir"/usr/bin/phpize* "$subpkgdir"/usr/bin/ || return 1
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/lib$pkgname.so "$subpkgdir"/usr/lib/
}

fpm() {
	pkgdesc="PHP FastCGI Process Manager (FPM)"
litespeed() {
	pkgdesc="$pkgname litespeed SAPI"
	depends="$pkgname-common"
	mkdir -p "$subpkgdir"$_confdir/fpm.d
	install -D -m755 "$srcdir"/build-fpm/sapi/fpm/php-fpm \
		"$subpkgdir"/usr/bin/php-fpm || return 1
	install -D -m644 "$srcdir"/build-fpm/sapi/fpm/php-fpm.conf \
		"$subpkgdir"$_confdir/php-fpm.conf || return 1
	install -D -m755 "$srcdir"/php-fpm.initd "$subpkgdir"/etc/init.d/php-fpm
	# enable some default options
	sed -ri	-e "s~^;(error_log)(.*)~\1 = /var/log/php-fpm.log~" \
		-e "s~^;(include)(.*)~\1 = $_confdir/fpm.d/*.conf~" \
		-e "s/^;(pm.start_servers)/\1/" \
		-e "s/^;(pm.min_spare_servers)/\1/" \
		-e "s/^;(pm.max_spare_servers)/\1/" \
		"$subpkgdir"$_confdir/php-fpm.conf || return 1
	ln -s php-fpm "$subpkgdir"/usr/bin/php-fpm5
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/lsphp "$subpkgdir"/usr/bin/ls$pkgname
}

apache2() {
	pkgdesc="PHP Module for Apache2"
	depends="$pkgname-common apache2"
	install -D -m755 "$srcdir"/build-apache2/libs/libphp5.so \
		"$subpkgdir"/usr/lib/apache2/libphp5.so || return 1
	install -D -m644 "$srcdir"/php5-module.conf \
		"$subpkgdir"/etc/apache2/conf.d/php5-module.conf || return 1
cgi() {
	pkgdesc="$pkgname common gateway interface"
	depends="$pkgname-common"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/php-cgi "$subpkgdir"/usr/bin/$pkgname-cgi
}

embed() {
	pkgdesc="PHP Embed Library"
fpm() {
	pkgdesc="$pkgname FastCGI process manager"
	depends="$pkgname-common"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libphp5.so "$subpkgdir"/usr/lib/
	mkdir -p "$subpkgdir"/etc/$pkgname \
		"$subpkgdir"/usr \
		"$subpkgdir"/var/lib \
		"$subpkgdir"/var/log/$pkgname
	mv "$pkgdir"/usr/share/$pkgname/fpm "$subpkgdir"/var/lib/$pkgname || return 1
	mv "$pkgdir"/usr/sbin "$subpkgdir"/usr/
	mv "$subpkgdir"/usr/sbin/php-fpm "$subpkgdir"/usr/sbin/$pkgname-fpm || return 1
	mv "$pkgdir"/etc/$pkgname/php-fpm* "$subpkgdir"/etc/$pkgname/ || return 1
	find "$subpkgdir"/etc/$pkgname -name *.default -exec sh -c 'f={}; mv $f ${f%.default}' \;
	install -D -m755 "$srcdir"/$pkgname-fpm.initd "$subpkgdir"/etc/init.d/$pkgname-fpm
	install -D -m644 "$srcdir"/$pkgname-fpm.logrotate "$subpkgdir"/etc/logrotate.d/$pkgname-fpm
}

pear() {
	pkgdesc="PHP Extension and Application Repository (PEAR)"
	depends="$pkgname-cli $pkgname-xml"
	mkdir -p "$subpkgdir"/usr/share "$subpkgdir"$_confdir \
		"$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/pecl \
		"$pkgdir"/usr/bin/pear \
		"$pkgdir"/usr/bin/peardev \
		"$subpkgdir"/usr/bin/ || return 1
	mv "$pkgdir"$_confdir/pear.conf \
		"$subpkgdir"$_confdir/ || return 1
	mv "$pkgdir"${_peardir} \
		"$subpkgdir"/usr/share/ || return 1
	replaces="php7-pear"
	provides="php-pear"
	pkgdesc="$pkgname extension and application repository"
	depends="$pkgname $pkgname-xml"
	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/etc/$pkgname
	mv "$pkgdir"/usr/bin/pecl "$pkgdir"/usr/bin/pear "$subpkgdir"/usr/bin/
	mv "$pkgdir"/etc/$pkgname/pear.conf "$subpkgdir"/etc/$pkgname/ || return 1
	mv "$pkgdir"/usr/share "$subpkgdir"/usr/
	rmdir "$subpkgdir"/usr/share/$pkgname || return 1
}

phpdbg() {
	pkgdesc="Interactive PHP debugger"
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/phpdbg* "$subpkgdir"/usr/bin/
common() {
	pkgdesc="$pkgname common config"
	depends=
	install -Dm644 "$builddir"/php.ini-production \
		"$subpkgdir"/etc/$pkgname/php.ini || return 1
	# exit with an error if there is any configs
	# or if some modules were not in subpackages
	rmdir "$pkgdir"/usr/lib/$pkgname/modules \
		"$pkgdir"/etc/$pkgname || return 1
	rm -fr "$pkgdir"/etc "$pkgdir"/usr/lib
}

_mv_ext() {
	local ext=$1
	local ini=$ext.ini
	pkgdesc="${ext} extension for PHP"

	# extension dependencies
	if [ -n "${2-}" ]; then
		depends="${2-}"
	fi
	depends="${pkgname} ${depends}"

	# work around dependency issue
	# https://bugs.alpinelinux.org/issues/1848
	if [ "$ext" = "wddx" ]; then
		ini=xml_$ext.ini
	fi

	mkdir -p "$subpkgdir"/$_extdir
	mv "$pkgdir"/$_extdir/${ext}.so "$subpkgdir"/$_extdir/ || return 1
	mkdir -p "$subpkgdir"$_confdir/conf.d
	case "$1" in
		opcache)
			echo "zend_extension=${ext}.so" > "$subpkgdir"$_confdir/conf.d/$ini
			;;
		*)
			echo "extension=${ext}.so" > "$subpkgdir"$_confdir/conf.d/$ini
			;;
	esac
_default_ext() {
	local dep=
	local sep=
	local elo=0
	local extname=${subpkgname#$pkgname-}
	pkgdesc="$pkgname extension: $extname"
	for dep in $(eval echo \$depends_$extname); do
		elo=$(expr $elo + 1)
		[ "$dep" = "--" ] && sep=$dep
		[ "$sep" = "--" ] || depends="$depends $dep"
	done
	mkdir -p "$subpkgdir"/usr/lib/$pkgname/modules \
		"$subpkgdir"/etc/$pkgname/conf.d
	mv "$pkgdir"/usr/lib/$pkgname/modules/$extname.so \
		"$subpkgdir"/usr/lib/$pkgname/modules/ || return 1
	echo $(eval echo \$_prefix_$extname)extension=$extname.so >\
		"$subpkgdir"/etc/$pkgname/conf.d/$(printf %02d $elo)_${extname}.ini
}

bcmath()	{ _mv_ext bcmath; }
bz2()		{ _mv_ext bz2; }
calendar()	{ _mv_ext calendar; }
ctype()		{ _mv_ext ctype; }
_curl()		{ _mv_ext curl; }
dba()		{ _mv_ext dba; }
dom()		{ _mv_ext dom; }
enchant()	{ _mv_ext enchant; }
exif()		{ _mv_ext exif; }
ftp()		{ _mv_ext ftp; }
gd()		{ _mv_ext gd; }
gettext()	{ _mv_ext gettext; }
gmp()		{ _mv_ext gmp; }
iconv()		{ _mv_ext iconv; }
imap()		{ _mv_ext imap; }
intl()		{ _mv_ext intl; }
json()		{ _mv_ext json; }
ldap()		{ _mv_ext ldap; }
mcrypt()	{ _mv_ext mcrypt; }
mysql()		{ _mv_ext mysql; }
mysqli()	{ _mv_ext mysqli; }
odbc()		{ _mv_ext odbc unixodbc; }
openssl()	{ _mv_ext openssl; }
pcntl()		{ _mv_ext pcntl; }
pdo()		{ _mv_ext pdo; }
pdo_mysql()	{ _mv_ext pdo_mysql $pkgname-pdo; }
pdo_odbc()	{ _mv_ext pdo_odbc $pkgname-pdo; }
pdo_pgsql()	{ _mv_ext pdo_pgsql $pkgname-pdo; }
pdo_sqlite()	{ _mv_ext pdo_sqlite $pkgname-pdo; }
pgsql()		{ _mv_ext pgsql; }
phar()		{
			_mv_ext phar
			mkdir -p "$subpkgdir"/usr/bin
			mv "$pkgdir"/usr/bin/phar* "$subpkgdir"/usr/bin/
		}
posix()		{ _mv_ext posix; }
pspell()	{ _mv_ext pspell; }
shmop()		{ _mv_ext shmop; }
snmp()		{ _mv_ext snmp; }
soap()		{ _mv_ext soap; }
sockets()	{ _mv_ext sockets; }
sqlite3()	{ _mv_ext sqlite3; }
sysvmsg()	{ _mv_ext sysvmsg; }
sysvsem()	{ _mv_ext sysvsem; }
sysvshm()	{ _mv_ext sysvshm; }
xml()		{ _mv_ext xml; }
xmlreader()	{ _mv_ext xmlreader $pkgname-dom; }
xmlrpc()	{ _mv_ext xmlrpc $pkgname-xml; }
xsl()		{ _mv_ext xsl $pkgname-dom; }
zip()		{ _mv_ext zip; }
zlib()		{ _mv_ext zlib; }
mssql()		{ _mv_ext mssql; }
pdo_dblib()	{ _mv_ext pdo_dblib "$pkgname-pdo freetds"; }
wddx()		{ _mv_ext wddx; }
opcache()	{ _mv_ext opcache; }

md5sums="56758fdb5ff156a36fb600950b7999aa  php-5.6.28.tar.bz2
63b16caff0d7aa881a31a1e02f3080c3  php-fpm.initd
md5sums="b2772a0bdada0e20f4e1937f71416bcc  php-5.6.29.tar.bz2
387c70cebc8c32ea547f52e2b8e24534  php5-fpm.initd
5d858ed3471b3445f422fae87f2b5101  php5-fpm.logrotate
67719f428f44ec004da18705cbabe2ee  php5-module.conf
483bc0a85c50a9a9aedbe14a19ed4526  php-install-pear-xml.patch
7200972a23adae799921c4ca20ff0074  gd-iconv.patch"
sha256sums="c55ea3f4aad5a0b65631d01c4468930fd981ad208ffcd242acdf731bcb47548f  php-5.6.28.tar.bz2
be9bfdab10a994fe553119b181be7015325a7618de454a58bdee06bcfb711454  php-fpm.initd
483bc0a85c50a9a9aedbe14a19ed4526  install-pear.patch
66f0037a029f9eed2b31d2e1d50f1860  tidy-buffio.patch
f216e041b6e10c9881904970b1d19ed2  includedir.patch
f31de64b4d4df9ce768517b6422b0987  php-fpm.patch"
sha256sums="499b844c8aa7be064c111692e51a093ba94e54d2d9abb01e70ea76183a1825bb  php-5.6.29.tar.bz2
97d15cf42e03a9883401caddd5c5166ae1cfb52125539b238ebd5c36e0a7fdbf  php5-fpm.initd
298708d0f0e4518bcddc287acd204bafa449625c5bf5694d22bab818f714247e  php5-fpm.logrotate
ceec4d5b2a128c6a97e49830af604f0bb555bca1a86a9cd0366b828ba392257f  php5-module.conf
f739ca427a1dd53a388bad0823565299c5d4a5796b1171b892884e4d7d099bab  php-install-pear-xml.patch
98de37c650a36870a543225f6a6b81813ccd447a484f0881511be4eb6e901844  gd-iconv.patch"
sha512sums="57efbbf422b74d74cdbc701ada03e3eb517bbc543169de642bada5843f612e2f1a43f1654b0ab92d015d3d1e777ac15c630d05f98f0ee259f2e3c0ba63b9dbc2  php-5.6.28.tar.bz2
1f5cb18f85a2e279e24344d993f5c51c7bfbcbecc0e9bfcf075bebd1b0b893e2ffb793d95a632c9333033597d4b4f74840bfd00520a6dc700444d1a054225da1  php-fpm.initd
f739ca427a1dd53a388bad0823565299c5d4a5796b1171b892884e4d7d099bab  install-pear.patch
5dc8f32e5e2b1cd6317ada5a5adb9b5f0802ed6e0dbe065d7bfcc0f55d47e0d5  tidy-buffio.patch
ce8aabb99c75145124193393d8534d2dfec64ba539c31fd58d089b1a6f26e245  includedir.patch
88731a5638bd0acba2ab1cf60f80022cb007a6f5bfd22730a133f3b9aea0f1ad  php-fpm.patch"
sha512sums="305049ab9ece8fd5b61f2b2beeaf8bbe994aa325911d90b5fcf8be1dbc43dcdf2528296aa017b8c73cfc3b4614e306a1741fd7c69f90fb23477ca6bf13c10d44  php-5.6.29.tar.bz2
2800a3913638e58916d1f61d55f1ff4cdf1fe594d3a78a566aea4abebdbc1caf3b3cdb8d1ae66da29a6820d084f8db826b13f3d926066c0ef8251a9647edadfd  php5-fpm.initd
72c19414362d7262e7dfc828dec3814a93f1c0de369c747967b33cfd8b18e2b340232308f3baf20b9458ee62d668963fa31cb2d981d5587da9b7162e3bb1f0fa  php5-fpm.logrotate
895e94c791bd82060ad820fef049d366a09c932097faa6b7b9a2c2e9e00a18cb7c0f9b128679c7659b404379266fd0f95dba5c0333f626194cf60f7bf6044102  php5-module.conf
f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505  php-install-pear-xml.patch
6ecd0be2da1dc5b1d7512e46a2a5cd107a8b2a8c364efc9c624a7d6b2ab081685a329c94c22c970dc14c5c1115f702c512e97ae858da1bc69c6423323dbeeba2  gd-iconv.patch"
f1177cbf6b1f44402f421c3d317aab1a2a40d0b1209c11519c1158df337c8945f3a313d689c939768584f3e4edbe52e8bd6103fb6777462326a9d94e8ab1f505  install-pear.patch
6894c9cba7752a3406e774d9efc0e058c37433493c1c20101e9563bf247c112157a67e306b06b9517b0422eca521f543d637a6cbd2cea7639e43f13d773b3d2b  tidy-buffio.patch
8fc56dc52b8eb2c88c69b445dd667ceefc5407017ba323701134bda9cd4f6b154db86442e5285817b5eb9799bf9e9dd11523e75006760fba80b334991d477088  includedir.patch
5d62c12d43595f71a230022c26b96faecbec149926c417bea17a7eb44c4fbff436e907beaf74c356fe301a77fbe2d207697ecdb84a0bddd12f2be8a8d20e648c  php-fpm.patch"
diff --git a/main/php5/gd-iconv.patch b/main/php5/gd-iconv.patch
deleted file mode 100644
index 7f7bd0e196..0000000000
--- a/main/php5/gd-iconv.patch
@@ -1,45 +0,0 @@
diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
index e643e52..fc41ab9 100644
--- a/ext/gd/config.m4
+++ b/ext/gd/config.m4
@@ -6,6 +6,9 @@ dnl
 dnl Configure options
 dnl
 
+PHP_ARG_WITH(iconv-dir, iconv dir for GD and XMLRPC-EPI,
+[  --with-iconv-dir=DIR      GD/XMLRPC-EPI: iconv dir for GD/XMLRPC-EPI],no,no)
+
 PHP_ARG_WITH(gd, for GD support,
 [  --with-gd[=DIR]           Include GD support.  DIR is the GD library base
                           install directory [BUNDLED]])
@@ -329,6 +332,18 @@ dnl enable the support in bundled GD library
     GDLIB_CFLAGS="$GDLIB_CFLAGS -DJISX0208"
   fi
 
+  dnl link to iconv if needed
+  if test "$PHP_ICONV_DIR" != "no"; then
+    PHP_ICONV=$PHP_ICONV_DIR
+  fi
+
+  if test -z "$PHP_ICONV" || test "$PHP_ICONV" = "no"; then
+    PHP_ICONV=yes
+  fi
+
+  PHP_SETUP_ICONV(GD_SHARED_LIBADD, [], [
+    AC_MSG_ERROR([iconv not found, in order to build gd you need the iconv library])
+  ])
 else
 
  if test "$PHP_GD" != "no"; then
--- a/ext/xmlrpc/config.m4
+++ b/ext/xmlrpc/config.m4
@@ -18,9 +18,6 @@
 PHP_ARG_WITH(libexpat-dir, libexpat dir for XMLRPC-EPI,
 [  --with-libexpat-dir=DIR XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)],no,no)
 
-PHP_ARG_WITH(iconv-dir, iconv dir for XMLRPC-EPI,
-[  --with-iconv-dir=DIR    XMLRPC-EPI: iconv dir for XMLRPC-EPI],no,no)
--
 if test "$PHP_XMLRPC" != "no"; then
 
   PHP_ADD_EXTENSION_DEP(xmlrpc, libxml)
diff --git a/main/php5/includedir.patch b/main/php5/includedir.patch
new file mode 100644
index 0000000000..68d953e222
--- /dev/null
+++ b/main/php5/includedir.patch
@@ -0,0 +1,41 @@
--- a/scripts/Makefile.frag
+++ b/scripts/Makefile.frag
@@ -3,7 +3,7 @@
 # Build environment install
 #
 
-phpincludedir = $(includedir)/php
+phpincludedir = $(includedir)/php5
 phpbuilddir = $(libdir)/build
 
 BUILD_FILES = \
--- a/ext/pdo/Makefile.frag
+++ b/ext/pdo/Makefile.frag
@@ -1,4 +1,4 @@
-phpincludedir=$(prefix)/include/php
+phpincludedir=$(prefix)/include/php5
 
 PDO_HEADER_FILES= \
 	php_pdo.h \
--- a/scripts/php-config.in
+++ b/scripts/php-config.in
@@ -6,7 +6,7 @@
 exec_prefix="@exec_prefix@"
 version="@PHP_VERSION@"
 vernum="@PHP_VERSION_ID@"
-include_dir="@includedir@/php"
+include_dir="@includedir@/php5"
 includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
 ldflags="@PHP_LDFLAGS@"
 libs="@EXTRA_LIBS@"
--- a/scripts/phpize.in
+++ b/scripts/phpize.in
@@ -5,7 +5,7 @@
 datarootdir='@datarootdir@'
 exec_prefix="`eval echo @exec_prefix@`"
 phpdir="`eval echo @libdir@`/build"
-includedir="`eval echo @includedir@`/php"
+includedir="`eval echo @includedir@`/php5"
 builddir="`pwd`"
 SED="@SED@"
 
diff --git a/main/php5/php-install-pear-xml.patch b/main/php5/install-pear.patch
similarity index 100%
rename from main/php5/php-install-pear-xml.patch
rename to main/php5/install-pear.patch
diff --git a/main/php5/php-fpm.patch b/main/php5/php-fpm.patch
new file mode 100644
index 0000000000..0a45112289
--- /dev/null
+++ b/main/php5/php-fpm.patch
@@ -0,0 +1,534 @@
--- a/sapi/fpm/fpm/fpm_conf.c
+++ b/sapi/fpm/fpm/fpm_conf.c
@@ -1178,7 +1178,7 @@
 	}
 
 	if (!fpm_global_config.error_log) {
-		fpm_global_config.error_log = strdup("log/php-fpm.log");
+		fpm_global_config.error_log = strdup("log/php5/error.log");
 	}
 
 #ifdef HAVE_SYSTEMD
@@ -1189,7 +1189,7 @@
 
 #ifdef HAVE_SYSLOG_H
 	if (!fpm_global_config.syslog_ident) {
-		fpm_global_config.syslog_ident = strdup("php-fpm");
+		fpm_global_config.syslog_ident = strdup("php5-fpm");
 	}
 
 	if (fpm_global_config.syslog_facility < 0) {
@@ -1663,7 +1663,7 @@
 		if (fpm_globals.prefix == NULL) {
 			spprintf(&tmp, 0, "%s/php-fpm.conf", PHP_SYSCONFDIR);
 		} else {
-			spprintf(&tmp, 0, "%s/etc/php-fpm.conf", fpm_globals.prefix);
+			spprintf(&tmp, 0, "%s/etc/php5/php-fpm.conf", fpm_globals.prefix);
 		}
 
 		if (!tmp) {
--- a/sapi/fpm/php-fpm.conf.in
+++ b/sapi/fpm/php-fpm.conf.in
@@ -22,14 +22,14 @@
 ; Pid file
 ; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
 ; Default Value: none
-;pid = run/php-fpm.pid
+;pid = run/php5-fpm.pid
 
 ; Error log file
 ; If it's set to "syslog", log is sent to syslogd instead of being written
 ; in a local file.
 ; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
-; Default Value: log/php-fpm.log
-;error_log = log/php-fpm.log
+; Default Value: log/php5/error.log
+;error_log = log/php5/error.log
 
 ; syslog_facility is used to specify what type of program is logging the
 ; message. This lets syslogd specify that messages from different facilities
@@ -41,8 +41,8 @@
 ; syslog_ident is prepended to every message. If you have multiple FPM
 ; instances running on the same server, you can change the default value
 ; which must suit common needs.
-; Default Value: php-fpm
-;syslog.ident = php-fpm
+; Default Value: php5-fpm
+;syslog.ident = php5-fpm
 
 ; Log level
 ; Possible Values: alert, error, warning, notice, debug
@@ -124,414 +124,10 @@
 ; used in logs and stats. There is no limitation on the number of pools which
 ; FPM can handle. Your system will tell you anyway :)
 
-; Start a new pool named 'www'.
-; the variable $pool can we used in any directive and will be replaced by the
-; pool name ('www' here)
-[www]
-
-; Per pool prefix
-; It only applies on the following directives:
-; - 'access.log'
-; - 'slowlog'
-; - 'listen' (unixsocket)
-; - 'chroot'
-; - 'chdir'
-; - 'php_values'
-; - 'php_admin_values'
-; When not set, the global prefix (or @php_fpm_prefix@) applies instead.
-; Note: This directive can also be relative to the global prefix.
-; Default Value: none
-;prefix = /path/to/pools/$pool
-
-; Unix user/group of processes
-; Note: The user is mandatory. If the group is not set, the default user's group
-;       will be used.
-user = @php_fpm_user@
-group = @php_fpm_group@
-
-; The address on which to accept FastCGI requests.
-; Valid syntaxes are:
-;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
-;                            a specific port;
-;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
-;                            a specific port;
-;   'port'                 - to listen on a TCP socket to all IPv4 addresses on a
-;                            specific port;
-;   '[::]:port'            - to listen on a TCP socket to all addresses
-;                            (IPv6 and IPv4-mapped) on a specific port;
-;   '/path/to/unix/socket' - to listen on a unix socket.
-; Note: This value is mandatory.
-listen = 127.0.0.1:9000
-
-; Set listen(2) backlog.
-; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
-;listen.backlog = 65535
-
-; Set permissions for unix socket, if one is used. In Linux, read/write
-; permissions must be set in order to allow connections from a web server. Many
-; BSD-derived systems allow connections regardless of permissions. 
-; Default Values: user and group are set as the running user
-;                 mode is set to 0660
-;listen.owner = @php_fpm_user@
-;listen.group = @php_fpm_group@
-;listen.mode = 0660
-; When POSIX Access Control Lists are supported you can set them using
-; these options, value is a comma separated list of user/group names.
-; When set, listen.owner and listen.group are ignored
-;listen.acl_users =
-;listen.acl_groups =
- 
-; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
-; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
-; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
-; must be separated by a comma. If this value is left blank, connections will be
-; accepted from any ip address.
-; Default Value: any
-;listen.allowed_clients = 127.0.0.1
-
-; Specify the nice(2) priority to apply to the pool processes (only if set)
-; The value can vary from -19 (highest priority) to 20 (lower priority)
-; Note: - It will only work if the FPM master process is launched as root
-;       - The pool processes will inherit the master process priority
-;         unless it specified otherwise
-; Default Value: no set
-; process.priority = -19
-
-; Choose how the process manager will control the number of child processes.
-; Possible Values:
-;   static  - a fixed number (pm.max_children) of child processes;
-;   dynamic - the number of child processes are set dynamically based on the
-;             following directives. With this process management, there will be
-;             always at least 1 children.
-;             pm.max_children      - the maximum number of children that can
-;                                    be alive at the same time.
-;             pm.start_servers     - the number of children created on startup.
-;             pm.min_spare_servers - the minimum number of children in 'idle'
-;                                    state (waiting to process). If the number
-;                                    of 'idle' processes is less than this
-;                                    number then some children will be created.
-;             pm.max_spare_servers - the maximum number of children in 'idle'
-;                                    state (waiting to process). If the number
-;                                    of 'idle' processes is greater than this
-;                                    number then some children will be killed.
-;  ondemand - no children are created at startup. Children will be forked when
-;             new requests will connect. The following parameter are used:
-;             pm.max_children           - the maximum number of children that
-;                                         can be alive at the same time.
-;             pm.process_idle_timeout   - The number of seconds after which
-;                                         an idle process will be killed.
-; Note: This value is mandatory.
-pm = dynamic
-
-; The number of child processes to be created when pm is set to 'static' and the
-; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
-; This value sets the limit on the number of simultaneous requests that will be
-; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
-; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
-; CGI. The below defaults are based on a server without much resources. Don't
-; forget to tweak pm.* to fit your needs.
-; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
-; Note: This value is mandatory.
-pm.max_children = 5
-
-; The number of child processes created on startup.
-; Note: Used only when pm is set to 'dynamic'
-; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
-pm.start_servers = 2
-
-; The desired minimum number of idle server processes.
-; Note: Used only when pm is set to 'dynamic'
-; Note: Mandatory when pm is set to 'dynamic'
-pm.min_spare_servers = 1
-
-; The desired maximum number of idle server processes.
-; Note: Used only when pm is set to 'dynamic'
-; Note: Mandatory when pm is set to 'dynamic'
-pm.max_spare_servers = 3
-
-; The number of seconds after which an idle process will be killed.
-; Note: Used only when pm is set to 'ondemand'
-; Default Value: 10s
-;pm.process_idle_timeout = 10s;
- 
-; The number of requests each child process should execute before respawning.
-; This can be useful to work around memory leaks in 3rd party libraries. For
-; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
-; Default Value: 0
-;pm.max_requests = 500
-
-; The URI to view the FPM status page. If this value is not set, no URI will be
-; recognized as a status page. It shows the following informations:
-;   pool                 - the name of the pool;
-;   process manager      - static, dynamic or ondemand;
-;   start time           - the date and time FPM has started;
-;   start since          - number of seconds since FPM has started;
-;   accepted conn        - the number of request accepted by the pool;
-;   listen queue         - the number of request in the queue of pending
-;                          connections (see backlog in listen(2));
-;   max listen queue     - the maximum number of requests in the queue
-;                          of pending connections since FPM has started;
-;   listen queue len     - the size of the socket queue of pending connections;
-;   idle processes       - the number of idle processes;
-;   active processes     - the number of active processes;
-;   total processes      - the number of idle + active processes;
-;   max active processes - the maximum number of active processes since FPM
-;                          has started;
-;   max children reached - number of times, the process limit has been reached,
-;                          when pm tries to start more children (works only for
-;                          pm 'dynamic' and 'ondemand');
-; Value are updated in real time.
-; Example output:
-;   pool:                 www
-;   process manager:      static
-;   start time:           01/Jul/2011:17:53:49 +0200
-;   start since:          62636
-;   accepted conn:        190460
-;   listen queue:         0
-;   max listen queue:     1
-;   listen queue len:     42
-;   idle processes:       4
-;   active processes:     11
-;   total processes:      15
-;   max active processes: 12
-;   max children reached: 0
-;
-; By default the status page output is formatted as text/plain. Passing either
-; 'html', 'xml' or 'json' in the query string will return the corresponding
-; output syntax. Example:
-;   http://www.foo.bar/status
-;   http://www.foo.bar/status?json
-;   http://www.foo.bar/status?html
-;   http://www.foo.bar/status?xml
-;
-; By default the status page only outputs short status. Passing 'full' in the
-; query string will also return status for each pool process.
-; Example: 
-;   http://www.foo.bar/status?full
-;   http://www.foo.bar/status?json&full
-;   http://www.foo.bar/status?html&full
-;   http://www.foo.bar/status?xml&full
-; The Full status returns for each process:
-;   pid                  - the PID of the process;
-;   state                - the state of the process (Idle, Running, ...);
-;   start time           - the date and time the process has started;
-;   start since          - the number of seconds since the process has started;
-;   requests             - the number of requests the process has served;
-;   request duration     - the duration in µs of the requests;
-;   request method       - the request method (GET, POST, ...);
-;   request URI          - the request URI with the query string;
-;   content length       - the content length of the request (only with POST);
-;   user                 - the user (PHP_AUTH_USER) (or '-' if not set);
-;   script               - the main script called (or '-' if not set);
-;   last request cpu     - the %cpu the last request consumed
-;                          it's always 0 if the process is not in Idle state
-;                          because CPU calculation is done when the request
-;                          processing has terminated;
-;   last request memory  - the max amount of memory the last request consumed
-;                          it's always 0 if the process is not in Idle state
-;                          because memory calculation is done when the request
-;                          processing has terminated;
-; If the process is in Idle state, then informations are related to the
-; last request the process has served. Otherwise informations are related to
-; the current request being served.
-; Example output:
-;   ************************
-;   pid:                  31330
-;   state:                Running
-;   start time:           01/Jul/2011:17:53:49 +0200
-;   start since:          63087
-;   requests:             12808
-;   request duration:     1250261
-;   request method:       GET
-;   request URI:          /test_mem.php?N=10000
-;   content length:       0
-;   user:                 -
-;   script:               /home/fat/web/docs/php/test_mem.php
-;   last request cpu:     0.00
-;   last request memory:  0
-;
-; Note: There is a real-time FPM status monitoring sample web page available
-;       It's available in: @EXPANDED_DATADIR@/fpm/status.html
-;
-; Note: The value must start with a leading slash (/). The value can be
-;       anything, but it may not be a good idea to use the .php extension or it
-;       may conflict with a real PHP file.
-; Default Value: not set 
-;pm.status_path = /status
- 
-; The ping URI to call the monitoring page of FPM. If this value is not set, no
-; URI will be recognized as a ping page. This could be used to test from outside
-; that FPM is alive and responding, or to
-; - create a graph of FPM availability (rrd or such);
-; - remove a server from a group if it is not responding (load balancing);
-; - trigger alerts for the operating team (24/7).
-; Note: The value must start with a leading slash (/). The value can be
-;       anything, but it may not be a good idea to use the .php extension or it
-;       may conflict with a real PHP file.
-; Default Value: not set
-;ping.path = /ping
-
-; This directive may be used to customize the response of a ping request. The
-; response is formatted as text/plain with a 200 response code.
-; Default Value: pong
-;ping.response = pong
-
-; The access log file
-; Default: not set
-;access.log = log/$pool.access.log
-
-; The access log format.
-; The following syntax is allowed
-;  %%: the '%' character
-;  %C: %CPU used by the request
-;      it can accept the following format:
-;      - %{user}C for user CPU only
-;      - %{system}C for system CPU only
-;      - %{total}C  for user + system CPU (default)
-;  %d: time taken to serve the request
-;      it can accept the following format:
-;      - %{seconds}d (default)
-;      - %{miliseconds}d
-;      - %{mili}d
-;      - %{microseconds}d
-;      - %{micro}d
-;  %e: an environment variable (same as $_ENV or $_SERVER)
-;      it must be associated with embraces to specify the name of the env
-;      variable. Some exemples:
-;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
-;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
-;  %f: script filename
-;  %l: content-length of the request (for POST request only)
-;  %m: request method
-;  %M: peak of memory allocated by PHP
-;      it can accept the following format:
-;      - %{bytes}M (default)
-;      - %{kilobytes}M
-;      - %{kilo}M
-;      - %{megabytes}M
-;      - %{mega}M
-;  %n: pool name
-;  %o: output header
-;      it must be associated with embraces to specify the name of the header:
-;      - %{Content-Type}o
-;      - %{X-Powered-By}o
-;      - %{Transfert-Encoding}o
-;      - ....
-;  %p: PID of the child that serviced the request
-;  %P: PID of the parent of the child that serviced the request
-;  %q: the query string 
-;  %Q: the '?' character if query string exists
-;  %r: the request URI (without the query string, see %q and %Q)
-;  %R: remote IP address
-;  %s: status (response code)
-;  %t: server time the request was received
-;      it can accept a strftime(3) format:
-;      %d/%b/%Y:%H:%M:%S %z (default)
-;  %T: time the log has been written (the request has finished)
-;      it can accept a strftime(3) format:
-;      %d/%b/%Y:%H:%M:%S %z (default)
-;  %u: remote user
-;
-; Default: "%R - %u %t \"%m %r\" %s"
-;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
- 
-; The log file for slow requests
-; Default Value: not set
-; Note: slowlog is mandatory if request_slowlog_timeout is set
-;slowlog = log/$pool.log.slow
- 
-; The timeout for serving a single request after which a PHP backtrace will be
-; dumped to the 'slowlog' file. A value of '0s' means 'off'.
-; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
-; Default Value: 0
-;request_slowlog_timeout = 0
- 
-; The timeout for serving a single request after which the worker process will
-; be killed. This option should be used when the 'max_execution_time' ini option
-; does not stop script execution for some reason. A value of '0' means 'off'.
-; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
-; Default Value: 0
-;request_terminate_timeout = 0
- 
-; Set open file descriptor rlimit.
-; Default Value: system defined value
-;rlimit_files = 1024
- 
-; Set max core size rlimit.
-; Possible Values: 'unlimited' or an integer greater or equal to 0
-; Default Value: system defined value
-;rlimit_core = 0
- 
-; Chroot to this directory at the start. This value must be defined as an
-; absolute path. When this value is not set, chroot is not used.
-; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
-; of its subdirectories. If the pool prefix is not set, the global prefix
-; will be used instead.
-; Note: chrooting is a great security feature and should be used whenever 
-;       possible. However, all PHP paths will be relative to the chroot
-;       (error_log, sessions.save_path, ...).
-; Default Value: not set
-;chroot = 
- 
-; Chdir to this directory at the start.
-; Note: relative path can be used.
-; Default Value: current directory or / when chroot
-;chdir = /var/www
- 
-; Redirect worker stdout and stderr into main error log. If not set, stdout and
-; stderr will be redirected to /dev/null according to FastCGI specs.
-; Note: on highloaded environement, this can cause some delay in the page
-; process time (several ms).
-; Default Value: no
-;catch_workers_output = yes
-
-; Clear environment in FPM workers
-; Prevents arbitrary environment variables from reaching FPM worker processes
-; by clearing the environment in workers before env vars specified in this
-; pool configuration are added.
-; Setting to "no" will make all environment variables available to PHP code
-; via getenv(), $_ENV and $_SERVER.
-; Default Value: yes
-;clear_env = no
-
-; Limits the extensions of the main script FPM will allow to parse. This can
-; prevent configuration mistakes on the web server side. You should only limit
-; FPM to .php extensions to prevent malicious users to use other extensions to
-; exectute php code.
-; Note: set an empty value to allow all extensions.
-; Default Value: .php
-;security.limit_extensions = .php .php3 .php4 .php5
- 
-; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
-; the current environment.
-; Default Value: clean env
-;env[HOSTNAME] = $HOSTNAME
-;env[PATH] = /usr/local/bin:/usr/bin:/bin
-;env[TMP] = /tmp
-;env[TMPDIR] = /tmp
-;env[TEMP] = /tmp
-
-; Additional php.ini defines, specific to this pool of workers. These settings
-; overwrite the values previously defined in the php.ini. The directives are the
-; same as the PHP SAPI:
-;   php_value/php_flag             - you can set classic ini defines which can
-;                                    be overwritten from PHP call 'ini_set'. 
-;   php_admin_value/php_admin_flag - these directives won't be overwritten by
-;                                     PHP call 'ini_set'
-; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
-
-; Defining 'extension' will load the corresponding shared extension from
-; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
-; overwrite previously defined php.ini values, but will append the new value
-; instead.
-
-; Note: path INI options can be relative and will be expanded with the prefix
-; (pool, global or @prefix@)
-
-; Default Value: nothing is defined by default except the values in php.ini and
-;                specified at startup with the -d argument
-;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
-;php_flag[display_errors] = off
-;php_admin_value[error_log] = /var/log/fpm-php.www.log
-;php_admin_flag[log_errors] = on
-;php_admin_value[memory_limit] = 32M
+; Include one or more files. If glob(3) exists, it is used to include a bunch of
+; files from a glob(3) pattern. This directive can be used everywhere in the
+; file.
+; Relative path can also be used. They will be prefixed by:
+;  - the global prefix if it's been set (-p argument)
+;  - @prefix@ otherwise
+include=@php_fpm_sysconfdir@/php-fpm.d/*.conf
--- a/sapi/fpm/www.conf.in
+++ b/sapi/fpm/www.conf.in
@@ -250,7 +250,7 @@
 
 ; The access log file
 ; Default: not set
-;access.log = log/$pool.access.log
+;access.log = log/php5/$pool.access.log
 
 ; The access log format.
 ; The following syntax is allowed
@@ -314,7 +314,7 @@
 ; The log file for slow requests
 ; Default Value: not set
 ; Note: slowlog is mandatory if request_slowlog_timeout is set
-;slowlog = log/$pool.log.slow
+;slowlog = log/php5/$pool.slow.log
 
 ; The timeout for serving a single request after which a PHP backtrace will be
 ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
@@ -408,6 +408,6 @@
 ;                specified at startup with the -d argument
 ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
 ;php_flag[display_errors] = off
-;php_admin_value[error_log] = /var/log/fpm-php.www.log
+;php_admin_value[error_log] = /var/log/php5/$pool.error.log
 ;php_admin_flag[log_errors] = on
 ;php_admin_value[memory_limit] = 32M
--- a/sapi/fpm/config.m4
+++ b/sapi/fpm/config.m4
@@ -667,7 +667,7 @@
 
   PHP_ADD_BUILD_DIR(sapi/fpm/fpm)
   PHP_ADD_BUILD_DIR(sapi/fpm/fpm/events)
-  PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html)
+  PHP_OUTPUT(sapi/fpm/php-fpm.conf sapi/fpm/www.conf sapi/fpm/init.d.php-fpm sapi/fpm/php-fpm.service sapi/fpm/php-fpm.8 sapi/fpm/status.html)
   PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/fpm/Makefile.frag])
 
   SAPI_FPM_PATH=sapi/fpm/php-fpm
--- a/sapi/fpm/Makefile.frag
+++ b/sapi/fpm/Makefile.frag
@@ -11,8 +11,9 @@
 	@$(INSTALL) -m 0755 $(SAPI_FPM_PATH) $(INSTALL_ROOT)$(sbindir)/$(program_prefix)php-fpm$(program_suffix)$(EXEEXT)
 
 	@echo "Installing PHP FPM config:        $(INSTALL_ROOT)$(sysconfdir)/" && \
-	$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir) || :
+	$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d || :
 	@$(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf.default || :
+	@$(INSTALL_DATA) sapi/fpm/www.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d/www.conf.default || :
 
 	@echo "Installing PHP FPM man page:      $(INSTALL_ROOT)$(mandir)/man8/"
 	@$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man8
diff --git a/main/php5/php5-common.pre-deinstall b/main/php5/php5-common.pre-deinstall
new file mode 100644
index 0000000000..cec8da2a94
--- /dev/null
+++ b/main/php5/php5-common.pre-deinstall
@@ -0,0 +1,5 @@
#!/bin/sh

find -L /usr/bin -type l -name "*php*" -delete

exit 0
diff --git a/main/php5/php5-common.pre-upgrade b/main/php5/php5-common.pre-upgrade
new file mode 100644
index 0000000000..96a08da734
--- /dev/null
+++ b/main/php5/php5-common.pre-upgrade
@@ -0,0 +1,7 @@
#!/bin/sh

for file in $(find /usr/bin -type f -name "*php5*"); do
	[ ! -e ${file/5/} -o -L ${file/5/} ] && ln -sf $file ${file/5/}
done

exit 0
diff --git a/main/php5/php5-common.trigger b/main/php5/php5-common.trigger
new file mode 100644
index 0000000000..dcdad55fb6
--- /dev/null
+++ b/main/php5/php5-common.trigger
@@ -0,0 +1,9 @@
#!/bin/sh

find -L /usr/bin -type l -name "*php*" -delete

for file in $(find /usr/bin -type f -name "*php5*"); do
	[ ! -e ${file/5/} ] && ln -sf $file ${file/5/}
done

exit 0
diff --git a/main/php5/php-fpm.initd b/main/php5/php5-fpm.initd
similarity index 73%
rename from main/php5/php-fpm.initd
rename to main/php5/php5-fpm.initd
index 9f091e7645..cd3939ab6f 100644
--- a/main/php5/php-fpm.initd
+++ b/main/php5/php5-fpm.initd
@@ -6,18 +6,17 @@
# variable "user" and optionally "group" in conf.d file, or in the $fpm_config
# file (the former has precedence).

: ${name:="PHP FastCGI Process Manager"}

command="/usr/bin/php-fpm"
command="/usr/bin/php5-fpm"
command_background="yes"
start_stop_daemon_args="--quiet"
pidfile="/run/$RC_SVCNAME/php-fpm.pid"
pidfile="/run/$RC_SVCNAME/php5-fpm.pid"
retry="SIGTERM/20"

# configtest is here only for backward compatibility
extra_commands="checkconfig configtest"
extra_commands="checkconfig"
extra_started_commands="reload reopen"
description_checkconfig="Run php-fpm config check"
description="PHP5 FastCGI Process Manager"
description_checkconfig="Run config check"
description_reload="Gracefully reload workers and config"
description_reopen="Reopen log files"

@@ -25,47 +24,43 @@ required_files="$fpm_config"

depend() {
	need net
	use apache2 lighttpd nginx
	before apache2 lighttpd nginx
}

init_vars() {
	# Defaults for single master process with multiple pools
	if [ "$RC_SVCNAME" = "php-fpm" ]; then
	if [ "$RC_SVCNAME" = "php5-fpm" ]; then
		: ${fpm_config:="/etc/php5/php-fpm.conf"}
		: ${user:="root"}
	# Defaults for master process per pool
	else
		: ${fpm_config="/etc/php5/fpm.d/${RC_SVCNAME#php-fpm.}.conf"}
		: ${fpm_config="/etc/php5/php-fpm.d/${RC_SVCNAME#php5-fpm.}.conf"}
		: ${user:="$(conf_get user)"}
		: ${user:="nobody"}
		: ${group:="$(conf_get group)"}
	fi
	command_args="--nodaemonize --fpm-config $fpm_config"
	command_args="--nodaemonize --fpm-config $fpm_config --pid $pidfile"
	start_stop_daemon_args="$start_stop_daemon_args
		--user $user ${group:+"--group $group"}"
}

start_pre() {
	checkconfig || return 1

	# If unix socket is used (instead of TCP/IP), then ensure that the
	# directory exists and has correct privileges.
	local listen="$(conf_get listen)"
	if [ "${listen:0:1}" = "/" ]; then
		checkpath -d -o $user:$group "$(dirname "$listen")"
	fi

	[ "${listen:0:1}" = "/" ] && checkpath -d -o $user:$group "$(dirname "$listen")"
	checkpath -d "$(dirname "$pidfile")"
}

reload() {
	ebegin "Reloading $name"
	ebegin "Reloading $RC_SVCNAME"
	start-stop-daemon --signal USR2 --pidfile "$pidfile"
	eend $?
}

reopen() {
	ebegin "Reopening $name log files"
	ebegin "Reopening $RC_SVCNAME log files"
	start-stop-daemon --signal USR1 --pidfile "$pidfile"
	eend $?
}
@@ -73,7 +68,6 @@ reopen() {
checkconfig() {
	init_vars
	ebegin "Checking $fpm_config"

	local out
	out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || {
		printf "%s\n" "$out"
@@ -82,11 +76,6 @@ checkconfig() {
	}
}

configtest() {
	ewarn "configtest is deprecated, use checkconfig instead"
	checkconfig
}

conf_get() {
	local key="$1"
	sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1
diff --git a/main/php5/php5-fpm.logrotate b/main/php5/php5-fpm.logrotate
new file mode 100644
index 0000000000..7f3c42ea00
--- /dev/null
+++ b/main/php5/php5-fpm.logrotate
@@ -0,0 +1,13 @@
/var/log/php5/*.log {
	rotate 7
	daily
	missingok
	notifempty
	delaycompress
	compress
	dateext
	sharedscripts
	postrotate
		/etc/init.d/php5-fpm --ifstarted --quiet reopen
	endscript
}
diff --git a/main/php5/php5.post-upgrade b/main/php5/php5.post-upgrade
deleted file mode 100644
index 98c959958c..0000000000
--- a/main/php5/php5.post-upgrade
@@ -1,11 +0,0 @@
#!/bin/sh

new=$1
old=$2

if [ "$(apk version -t $old 5.3)" = "<" ]; then
	echo "*"
	echo "* Please see migration notes here: http://php.net/migration53"
	echo "*"
fi

diff --git a/main/php5/tidy-buffio.patch b/main/php5/tidy-buffio.patch
new file mode 100644
index 0000000000..c15f9540a4
--- /dev/null
+++ b/main/php5/tidy-buffio.patch
@@ -0,0 +1,11 @@
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -31,7 +31,7 @@
 #include "ext/standard/info.h"
 
 #include "tidy.h"
-#include "buffio.h"
+#include "tidybuffio.h"
 
 /* compatibility with older versions of libtidy */
 #ifndef TIDY_CALL
-- 
2.11.0



---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)