From 2ead123b69209a430ff3e6483b9f9f42194fd4ae Mon Sep 17 00:00:00 2001
From: Michael Hanson <hansonorders@verizon.net>
Date: Tue, 23 Nov 2010 01:05:55 +0000
Subject: php: upgrade to 5.3.3 (php now split into php php-cgi and php-pear)

---
 abs/core/php/PKGBUILD       | 170 ++++++++++++++++++++++----------------------
 abs/core/php/__changelog    |   2 +
 abs/core/php/db4-test.patch |  11 +++
 abs/core/php/php.ini        |   2 +-
 abs/core/php/php.install    |   2 +-
 5 files changed, 100 insertions(+), 87 deletions(-)
 create mode 100644 abs/core/php/db4-test.patch

diff --git a/abs/core/php/PKGBUILD b/abs/core/php/PKGBUILD
index 9e297f0..fc3b8b3 100644
--- a/abs/core/php/PKGBUILD
+++ b/abs/core/php/PKGBUILD
@@ -1,7 +1,8 @@
-pkgname=php
-pkgver=5.2.6
-pkgrel=31
-_suhosinver=0.9.6.2
+pkgbase=php
+pkgname=('php' 'php-cgi' 'php-pear')
+pkgver=5.3.3
+pkgrel=1
+_suhosinver=${pkgver}-0.9.10
 pkgdesc='A high-level scripting language'
 arch=('i686' 'x86_64')
 license=('PHP')
@@ -14,42 +15,17 @@ depends=('glibc' 'readline' 'ncurses' 'libxml2' 'pcre')
 #       	'libmcrypt' 'tidyhtml' 'aspell' 'libtool' 'freetype2' 'libjpeg' \
 #             'curl' 'libxslt' 'pam' 'openssl' 'bzip2' 'gdbm' 'db>=4.7')
 
-makedepends=('mysql' 'libpng' 'libjpeg' 'sqlite3' \
-       	'libmcrypt' 'libtool' 'freetype2' 'libjpeg' \
-             'curl' 'libxslt' 'pam' 'openssl' 'bzip2' 'gdbm' 'db>=4.7')
-
-optdepends=('bzip2: bz2' \
-            'curl: curl' \
-            'gdbm: dba' \
-            'libpng: gd' \
-            'libjpeg: gd' \
-            'freetype2: gd' \
-            'pam: imap' \
-            'libldap: ldap' \
-            'mcrypt: mcrypt' \
-            'libtool: mcrypt' \
-            'libmysqlclient: mysql/mysqli' \
-            'unixodbc: odbc/pdo_odbc' \
-            'openssl: openssl' \
-            'postgresql-libs: pgsql/pdo_pgsql' \
-            'aspell: pspell' \
-            'net-snmp: snmp' \
-            'sqlite3: sqlite' \
-            'tidyhtml: tidy' \
-            'libxslt: xsl' \
-            )
+makedepends=('mysql' 'libpng' 'libjpeg' 'sqlite3' 'libmcrypt' 'libtool' \
+             'freetype2' 'libjpeg' 'curl' 'libxslt' 'pam' 'openssl' 'bzip2' \
+             'gdbm' 'db>=4.8.26')
 options=('emptydirs')
-source=("http://museum.php.net/php5/${pkgname}-${pkgver}.tar.bz2" \
-        "http://download.suhosin.org/suhosin-patch-${pkgver}-${_suhosinver}.patch.gz" \
-        'php.ini' 'apache.conf' 'db-configure.patch')
-md5sums=('7380ffecebd95c6edb317ef861229ebd'
-         'f2ec986341a314c271259dbe4d940858'
-         'fda535c2b333297972aad48ee9285b45'
-         '96ca078be6729b665be8a865535a97bf'
-         '74e5ce5a02488ec91b1c59f539e42936')
+source=("http://www.php.net/distributions/${pkgname}-${pkgver}.tar.bz2" \
+        "http://download.suhosin.org/suhosin-patch-${_suhosinver}.patch.gz" \
+        'php.ini' 'apache.conf')
 
 build() {
-	phpconfig="--prefix=/usr \
+	phpconfig="--srcdir=${srcdir}/${pkgbase}-${pkgver} \
+        --prefix=/usr \
 	--sysconfdir=/etc/php \
 	--with-layout=GNU \
 	--with-config-file-path=/etc/php \
@@ -59,6 +35,8 @@ build() {
 	--disable-rpath \
 	--disable-static \
 	--enable-shared \
+        --mandir=/usr/share/man \
+        --without-pear \
 	"
 
 	phpextensions="--with-openssl=shared \
@@ -72,7 +50,6 @@ build() {
 	--without-db3 \
 	--with-db4=shared \
 	--with-gdbm=shared \
-	--enable-dbase=shared \
 	--enable-exif=shared \
 	--enable-ftp=shared \
 	--with-gd=shared \
@@ -89,7 +66,6 @@ build() {
 	--with-mysql-sock=/tmp/mysql.sock \
 	--with-mysql=shared \
 	--with-mysqli=shared \
-	--with-ncurses=shared \
 	--without-unixODBC \
 	--enable-pdo=shared \
 	--with-pdo-mysql=shared \
@@ -111,7 +87,6 @@ build() {
 	--enable-posix=shared \
 	--enable-sockets=shared \
 	--enable-xml \
-	--with-ttf=shared \
 	--enable-session=shared \
 	--with-regex=php \
 	--with-pcre-regex=/usr \
@@ -122,67 +97,92 @@ build() {
 	--with-xmlrpc=shared \
 	--without-pspell \
 	--with-freetype-dir=shared,/usr \
-	--with-mime-magic=shared \
 	"
+        EXTENSION_DIR=/usr/lib/php/modules
+        export EXTENSION_DIR
+        PEAR_INSTALLDIR=/usr/share/pear
+        export PEAR_INSTALLDIR
 
-	cd ${srcdir}/${pkgname}-${pkgver}
-
-	# avoid linking against old db version
-	patch -p0 -i ${srcdir}/db-configure.patch || return 1
+	cd ${srcdir}/${pkgbase}-${pkgver}
 
 	# apply suhosin patch
-	patch -p1 -i ${srcdir}/suhosin-patch-${pkgver}-${_suhosinver}.patch || return 1
+	patch -p1 -i ${srcdir}/suhosin-patch-${_suhosinver}.patch || return 1
 
-	# cli
+	# php
+        mkdir ${srcdir}/build-php
+        cd ${srcdir}/build-php
+        ln -s ../${pkgbase}-${pkgver}/configure
 	./configure ${phpconfig} \
 		--disable-cgi \
 		--with-readline \
 		--enable-pcntl \
-		--with-pear=/usr/share/pear \
 		${phpextensions} || return 1
 	make || return 1
-	# make test
-	make INSTALL_ROOT=${pkgdir} install || return 1
-
-	# fix pear path
-	sed "s|$PWD||g" -i ${pkgdir}/usr/{bin/pear,share/pear/pearcmd.php}
-	# cleanup
-	rm -f ${pkgdir}`${pkgdir}/usr/bin/php-config --extension-dir`/*.a
-	rm -rf ${pkgdir}/{.registry,.channels,.depdb*,.lock,.filemap}
-	rmdir ${pkgdir}/usr/include/php/include
-	# install php.ini
-	install -D -m644 ${srcdir}/php.ini ${pkgdir}/etc/php/php.ini
-	install -d -m755 ${pkgdir}/etc/php/conf.d/
 
 	# cgi and fcgi
+        cp -a ${srcdir}/build-php ${srcdir}/build-cgi
+        cd ${srcdir}/build-cgi
 	./configure ${phpconfig} \
-		--enable-fastcgi \
-		--enable-cgi \
-		--enable-discard-path \
-		--enable-force-cgi-redirect \
-		--disable-cli \
+                --disable-cli \
+                --enable-cgi \
 		${phpextensions} || return 1
 	make || return 1
-	install -D -m755 sapi/cgi/php-cgi ${pkgdir}/usr/bin/php-cgi || return 1
-
-	# mod_php
-#	./configure ${phpconfig} \
-#		--with-apxs2 \
-#		--disable-cli \
-#		${phpextensions} || return 1
-#	make || return 1
-#	install -D -m644 libs/libphp5.so ${pkgdir}/usr/lib/httpd/modules/libphp5.so || return 1
-#	install -D -m644 ${srcdir}/apache.conf ${pkgdir}/etc/httpd/conf/extra/php5_module.conf || return 1
+
+        # pear
+        cp -a ${srcdir}/build-php ${srcdir}/build-pear
+        cd ${srcdir}/build-pear
+        ./configure ${phpconfig} \
+                --disable-cgi \
+                --with-readline \
+                --enable-pcntl \
+                --with-pear \
+                ${phpextensions}
+        make || return 1
+}
+
+package_php() {
+        pkgdesc='An HTML-embedded scripting language'
+        depends=('pcre' 'libxml2' 'bzip2' 'openssl')
+        replaces=('php')
+        provides=('php')
+        backup=('etc/php/php.ini')
+
+	cd ${srcdir}/build-php
+	make INSTALL_ROOT=${pkgdir} install || return 1
+        install -d -m755 ${pkgdir}/usr/share/pear
+        # fix broken link
+        ln -sf phar.phar $pkgdir/usr/bin/phar
+        # install php.ini
+        install -D -m644 ${srcdir}/php.ini ${pkgdir}/etc/php/php.ini
+        install -d -m755 ${pkgdir}/etc/php/conf.d/
+
+        # remove static modules
+        rm -f ${pkgdir}/usr/lib/php/modules/*.a
+        # remove modules provided by sub packages
+        rm -f ${pkgdir}/usr/lib/php/modules/{curl,enchant,gd,gmp,intl,ldap,mcrypt,mssql,odbc,pdo_odbc,pgsql,pdo_pgsql,pspell,snmp,sqlite3,pdo_sqlite,tidy,xsl}.so
 }
 
+package_php-cgi() {
+        pkgdesc='CGI and FCGI SAPI for PHP'
+        depends=('php' 'pcre' 'libxml2')
+
+        install -D -m755 ${srcdir}/build-cgi/sapi/cgi/php-cgi ${pkgdir}/usr/bin/php-cgi
+}
+
+package_php-pear() {
+        pkgdesc='PHP Extension and Application Repository'
+        depends=('php' 'bash')
+        backup=('etc/php/pear.conf')
+
+        cd ${srcdir}/build-pear
+        make install-pear INSTALL_ROOT=${pkgdir} || return 1
+        local i
+        while read i; do
+                [ ! -e "$i" ] || rm -rf "$i"
+        done < <(find ${pkgdir} -name '.*')
+}
 
-md5sums=('7380ffecebd95c6edb317ef861229ebd'
-         'f2ec986341a314c271259dbe4d940858'
-         '0ba86d39163d577c195d57c9129149cd'
-         '96ca078be6729b665be8a865535a97bf'
-         '74e5ce5a02488ec91b1c59f539e42936')
-md5sums=('7380ffecebd95c6edb317ef861229ebd'
-         'f2ec986341a314c271259dbe4d940858'
-         '13795526fe1a5da17c0aa46d5ea1a5d8'
-         '96ca078be6729b665be8a865535a97bf'
-         '74e5ce5a02488ec91b1c59f539e42936')
+md5sums=('21ceeeb232813c10283a5ca1b4c87b48'
+         'b66b27c43b1332400ef8982944c3b95b'
+         '8ced1a21457e3d513425617667eb8588'
+         '96ca078be6729b665be8a865535a97bf')
diff --git a/abs/core/php/__changelog b/abs/core/php/__changelog
index 375545c..c8f04da 100644
--- a/abs/core/php/__changelog
+++ b/abs/core/php/__changelog
@@ -6,3 +6,5 @@ send errors to stderr
 change .install file, timezone is modified on install
 php.ini -jm
 	remove open_basedir
+
+split package into "php" "php-cgi" and "php-pear" -mh
diff --git a/abs/core/php/db4-test.patch b/abs/core/php/db4-test.patch
new file mode 100644
index 0000000..2c0cb14
--- /dev/null
+++ b/abs/core/php/db4-test.patch
@@ -0,0 +1,11 @@
+--- configure	2010-07-21 12:53:06.000000000 +0200
++++ configure	2010-10-22 09:21:54.077666560 +0200
+@@ -30742,7 +30742,7 @@
+ #include "confdefs.h"
+ 
+ #include "$THIS_INCLUDE"
+-#if DB_VERSION_MINOR != 1 || (DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
++#if DB_VERSION_MAJOR == 5 || DB_VERSION_MINOR != 1 || (DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
+       yes
+ #endif
+     
diff --git a/abs/core/php/php.ini b/abs/core/php/php.ini
index 0d3a568..5ef9d1d 100644
--- a/abs/core/php/php.ini
+++ b/abs/core/php/php.ini
@@ -529,7 +529,7 @@ doc_root =
 user_dir =
 
 ; Directory in which the loadable extensions (modules) reside.
-extension_dir = "/usr/lib/php/20060613/"
+extension_dir = "/usr/lib/php/modules/"
 
 ; Whether or not to enable the dl() function.  The dl() function does NOT work
 ; properly in multithreaded servers, such as IIS or Zeus, and is automatically
diff --git a/abs/core/php/php.install b/abs/core/php/php.install
index 1981a63..fb543f3 100644
--- a/abs/core/php/php.install
+++ b/abs/core/php/php.install
@@ -44,7 +44,7 @@ post_upgrade() {
 		fi
 	fi
     echo 'Updating extension dir...'
-    sed -i -e 's/#extension_dir = "/usr/lib/php/extensions/php/"/#extension_dir = "/usr/lib/php/20060613/"#g' /etc/php/php.ini
+    sed -i -e 's/#extension_dir = "/usr/lib/php/20060613/"/#extension_dir = "/usr/lib/php/modules/"#g' /etc/php/php.ini
     echo '
     ==> Location of php.ini has changed
 
-- 
cgit v0.12