# Contributor: Carlo Landmeter # Maintainer: Matt Smith pkgname=php pkgver=5.3.10 _suhosinver=5.3.9-0.9.10 pkgrel=3 pkgdesc="The PHP language runtime engine" url="http://www.php.net/" arch="all" license="PHP-3" depends="$pkgname-cgi" install="$pkgname.post-upgrade" makedepends="pcre-dev libxml2-dev libiconv-dev openssl-dev zlib-dev bzip2-dev curl-dev libpng-dev jpeg-dev freetype-dev libmcrypt-dev mysql-dev sqlite-dev libtool libltdl postgresql-dev db-dev unixodbc-dev icu-dev gd-dev gmp-dev gettext-dev imap-dev aspell-dev net-snmp-dev libxslt-dev openldap-dev pkgconfig libgcrypt-dev apache2-dev apr-dev apr-util-dev libevent-dev readline-dev enchant-dev gdbm-dev freetds-dev" subpackages="$pkgname-dev $pkgname-doc $pkgname-common $pkgname-cgi $pkgname-cli $pkgname-fpm $pkgname-apache2 $pkgname-embed $pkgname-pear $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-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-sqlite $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 " source="http://www.php.net/distributions/${pkgname}-${pkgver}.tar.bz2 http://download.suhosin.org/suhosin-patch-${_suhosinver}.patch.gz php-install-pear-xml.patch pcre_info.patch php-fpm.initd php5-module.conf " _apiver="20090626" _extdir="/usr/lib/php/$_apiver" _srcdir="$srcdir"/$pkgname-$pkgver prepare() { cd "$_srcdir" 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 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" return 1 fi } _do_build() { local _flavor="$1" shift local _builddir="$srcdir"/build-$_flavor mkdir -p "$_builddir" cd "$_builddir" "$_srcdir"/configure $@ || return 1 sed -ri "s/^(EXTRA_LDFLAGS[ ]*\=.*)/\1 -lpthread/" Makefile # see #183 make || return 1 } build() { _phpconfig="--build=${CHOST:-i486-alpine-linux-uclibc} \ --prefix=/usr \ --sysconfdir=/etc/php \ --with-layout=GNU \ --with-config-file-path=/etc/php \ --with-config-file-scan-dir=/etc/php/conf.d \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --disable-static \ --enable-shared \ --mandir=/usr/share/man \ --with-pic \ " _phpextensions=" \ --enable-bcmath=shared \ --with-bz2=shared \ --enable-calendar=shared \ --with-cdb \ --enable-ctype=shared \ --with-curl=shared \ --with-curlwrappers \ --enable-dba=shared \ --with-db4=shared \ --enable-dom=shared \ --with-enchant=shared \ --enable-exif=shared \ --with-freetype-dir=shared,/usr \ --enable-ftp=shared \ --with-gd=shared,/usr \ --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 \ --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-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-posix=shared \ --with-pspell=shared \ --with-regex=php \ --enable-session \ --enable-shmop=shared \ --with-snmp=shared \ --enable-soap=shared \ --enable-sockets=shared \ --with-sqlite=shared \ --enable-sqlite-utf8 \ --with-sqlite3=shared,/usr \ --enable-sysvmsg=shared \ --enable-sysvsem=shared \ --enable-sysvshm=shared \ --with-unixODBC=shared,/usr \ --enable-xml=shared \ --enable-xmlreader=shared \ --with-xmlrpc=shared \ --with-xsl=shared \ --enable-zip=shared \ --with-zlib=shared \ --without-db1 \ --without-db2 \ --without-db3 \ --without-qdbm \ --with-mssql=shared \ --with-pdo-dblib=shared \ --enable-mailparse \ " # cgi, fcgi, cli, pear and extensions _do_build cgi \ ${_phpconfig} \ --disable-cli \ --enable-cgi \ --enable-cli \ --with-pear \ ${_phpextensions} \ || return 1 # fpm cp -a "$srcdir"/build-cgi "$srcdir"/build-fpm _do_build fpm \ ${_phpconfig} \ --disable-cli \ --enable-fpm \ ${_phpextensions} \ || return 1 # apache2 cp -a "$srcdir"/build-cgi "$srcdir"/build-apache2 _do_build apache2 \ ${_phpconfig} \ --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} \ || 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 fpm install -D -m755 "$srcdir"/build-fpm/sapi/fpm/php-fpm \ "$pkgdir"/usr/bin/php-fpm || return 1 install -D -m644 "$srcdir"/build-fpm/sapi/fpm/php-fpm.conf \ "$pkgdir"/etc/php/php-fpm.conf || return 1 install -D -m755 "$srcdir"/php-fpm.initd "$pkgdir"/etc/init.d/php-fpm # enable some default options sed -ri -e "s~^;(error_log)(.*)~\1 = /var/log/php-fpm.log~" \ -e "s/^;(pm.start_servers)/\1/" \ -e "s/^;(pm.min_spare_servers)/\1/" \ -e "s/^;(pm.max_spare_servers)/\1/" \ "$pkgdir"/etc/php/php-fpm.conf || return 1 # install apache2 install -D -m755 "$srcdir"/build-apache2/libs/libphp5.so \ "$pkgdir"/usr/lib/apache2/libphp5.so || return 1 install -D -m644 "$srcdir"/php5-module.conf \ "$pkgdir"/etc/apache2/conf.d/php5-module.conf || 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 } dev() { default_dev mkdir -p "$subpkgdir"/usr/lib/php mv "$pkgdir"/usr/lib/php/build \ "$subpkgdir"/usr/lib/php/ || return 1 } doc() { # man pages mkdir -p "$subpkgdir"/usr/share/man || return 1 mv "$pkgdir"/usr/share/man/man* "$subpkgdir"/usr/share/man/ \ || return 1 # doc files _docs="CODING_STANDARDS CREDITS EXTENSIONS INSTALL LICENSE NEWS \ README.EXTENSIONS README.EXT_SKEL README.MAILINGLIST_RULES \ README.PARAMETER_PARSING_API README.PHP4-TO-PHP5-THIN-CHANGES \ README.REDIST.BINS README.RELEASE_PROCESS \ README.SELF-CONTAINED-EXTENSIONS README.STREAMS \ README.SUBMITTING_PATCH README.SVN-RULES README.TESTING \ README.TESTING2 README.UNIX-BUILD-SYSTEM README.Zeus \ README.input_filter README.namespaces TODO TODO-5.1 \ TODO-PHP5 UPGRADING UPGRADING.INTERNALS" for _doc in $_docs; do install -Dm644 "$srcdir"/$pkgname-$pkgver/$_doc \ "$subpkgdir"/usr/share/doc/$pkgname/$_doc || return 1 done } common() { pkgdesc="PHP Common Files" replaces="$pkgname" cd "$srcdir"/$pkgname-$pkgver install -D -m644 php.ini-production "$subpkgdir"/etc/php/php.ini sed -i -e "s:^; extension_dir = \"./\":extension_dir = \"$_extdir\":" "$subpkgdir"/etc/php/php.ini sed -ri 's/;(date.timezone =)/\1 UTC/' "$subpkgdir"/etc/php/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"/etc/php/php.ini } cgi() { pkgdesc="PHP Common Gateway Interface (CGI)" replaces="php" depends="php-common" mkdir -p "$subpkgdir"/usr/bin mv "$pkgdir"/usr/bin/php-cgi "$subpkgdir"/usr/bin/ } cli() { pkgdesc="PHP Command Line Interface (CLI)" replaces="php-dev" depends="php-common" mkdir -p "$subpkgdir"/usr/bin mv "$pkgdir"/usr/bin/php "$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 } fpm() { pkgdesc="PHP FastCGI Process Manager (FPM)" depends="php-common" mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/etc/php mv "$pkgdir"/usr/bin/php-fpm "$subpkgdir"/usr/bin/ || return 1 mv "$pkgdir"/etc/init.d "$subpkgdir"/etc/ || return 1 mv "$pkgdir"/etc/php/php-fpm.conf "$subpkgdir"/etc/php/ } apache2() { pkgdesc="PHP Module for Apache2" depends="php-common apache2" mkdir -p "$subpkgdir"/usr/lib "$subpkgdir"/etc mv "$pkgdir"/usr/lib/apache2 "$subpkgdir"/usr/lib/ &&\ mv "$pkgdir"/etc/apache2 "$subpkgdir"/etc } embed() { pkgdesc="PHP Embed Library" depends="php-common" mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libphp5.so "$subpkgdir"/usr/lib/ } pear() { pkgdesc="PHP Extension and Application Repository (PEAR)" depends="php-cli php-xml" mkdir -p "$subpkgdir"/usr/share "$subpkgdir"/etc/php \ "$subpkgdir"/usr/bin mv "$pkgdir"/usr/bin/pecl \ "$pkgdir"/usr/bin/pear \ "$pkgdir"/usr/bin/peardev \ "$subpkgdir"/usr/bin/ || return 1 mv "$pkgdir"/etc/php/pear.conf \ "$subpkgdir"/etc/php/ || return 1 mv "$pkgdir"/usr/share/pear \ "$subpkgdir"/usr/share/ || return 1 } _mv_ext() { local ext=$1 pkgdesc="${ext} extension for PHP" # extension dependencies if [ -n "${2-}" ]; then depends="${2-}" fi depends="${pkgname} ${depends}" mkdir -p "$subpkgdir"/$_extdir mv "$pkgdir"/$_extdir/${ext}.so "$subpkgdir"/$_extdir/ || return 1 mkdir -p "$subpkgdir"/etc/php/conf.d echo "extension=${ext}.so" > "$subpkgdir"/etc/php/conf.d/${ext}.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 mysql; } mysqli() { _mv_ext mysqli mysql; } odbc() { _mv_ext odbc unixodbc; } openssl() { _mv_ext openssl; } pdo() { _mv_ext pdo; } pdo_mysql() { _mv_ext pdo_mysql "php-pdo mysql"; } pdo_odbc() { _mv_ext pdo_odbc "php-pdo unixodbc"; } pdo_pgsql() { _mv_ext pdo_pgsql "php-pdo postgresql"; } pdo_sqlite() { _mv_ext pdo_sqlite "php-pdo sqlite"; } pgsql() { _mv_ext pgsql postgresql; } 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; } sqlite() { _mv_ext sqlite php-pdo_sqlite; } sqlite3() { _mv_ext sqlite3 sqlite; } sysvmsg() { _mv_ext sysvmsg; } sysvsem() { _mv_ext sysvsem; } sysvshm() { _mv_ext sysvshm; } xml() { _mv_ext xml; } xmlreader() { _mv_ext xmlreader php-dom; } xmlrpc() { _mv_ext xmlrpc php-xml; } xsl() { _mv_ext xsl php-dom; } zip() { _mv_ext zip; } zlib() { _mv_ext zlib; } mssql() { _mv_ext mssql; } pdo_dblib() { _mv_ext pdo_dblib "php-pdo freetds"; } md5sums="816259e5ca7d0a7e943e56a3bb32b17f php-5.3.10.tar.bz2 c099b3d7eac95018ababd41ded7f3066 suhosin-patch-5.3.9-0.9.10.patch.gz 5111e3be06d391f8772587c675240fab php-install-pear-xml.patch 8d3806bbb19e390f9b32ccf21611d937 pcre_info.patch 9ab162ff3428511a68aa9801c746e0d5 php-fpm.initd 67719f428f44ec004da18705cbabe2ee php5-module.conf"