TYPO free


fighting for TYPO free code

MacPorts . . . Give me back my PHP 5.2

4 Aug 2009

A while ago I updated my Ports list and upgraded all outdated ports. This gave me a shiny new PHP 5.3. PHP 5.3 is nice but it has deprecated a lot of functions and changed some other functions. This is all well and good, but now it spews a torrent of 'Notices', 'Deprecated' and 'Warning' messages when running TYPO3 4.1 and TYPO3 4.2 sites.

I can still get PHP 5.3 if I install the php5-devel package. If I really want to run that I'll compile that against apache1 and run that on another port to test TYPO3 4.3, FLOW3 and other software that requires PHP 5.3.

But I want the default PHP switched back to 5.2.10 as it was before.

Overriding the default Portfiles

You can override the default MacPorts Portfiles by creating a local Ports repository. Follow the guide and set one up.

Create your own PHP port file

Portfiles live in '/opt/local/var/macports/sources/rsync.macports.org/release/ports'. Your own portfiles directory should have a similar directory structure. In our case we want to override the php Portfile, so we create a directory in our ports directory the same way as the official one is stored:

mkdir -p /Users/yourname/ports/lang/php5/

Now take a look at '/opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/php5 /Portfile'. My first idea was to copy this and modify it so that it would get the 5.2.10 sources instead of the 5.3 sources. This does work if you tweak the portfile here and there and make sure you get the hashes right.

After tweaking, go to /Users/yourname/ports/ and issue the command 'portindex' to update the Port index with your new Portfile. If you now build php5, your own portfile will be used instead of the official one.

When MacPorts fetches the source code for PHP it puts it in: /opt/local/var/macports/distfiles/php5/. The commands to generate new hashes for a sourcefile are:

openssl dgst -sha1   php-5.2.10.tar.bz2
openssl dgst -md5 php-5.2.10.tar.bz2
openssl dgst -rmd160 php-5.2.10.tar.bz2

This got me pretty far and this should be enough information to get you going when modifying or tweaking other Portfiles. But I realized that it was easier to get the old PortFile for PHP from svn.

Tracking down a previous version of a Portfile

MacPorts uses SVN to store the Portfiles and other MacPorts software. We can check out the whole 'dports' directory or just the 'php5' directory:

cd /Users/yourname/ports/lang/php5/ 
rm -rf *
svn co svn.macports.org/repository/macports/trunk/dports/lang/php5/ .

Change into ~/tmp/macports and call up the revision history of Portfile:

svn log Portfile

This will give you the following list of revisions the file has gone through:

r54581 | [email protected] | 2009-07-29 22:05:12 +0200 (Wed, 29 Jul 2009) | 2 lines

php4, php5: add AU mirror

r54310 | [email protected] | 2009-07-24 20:54:23 +0200 (Fri, 24 Jul 2009) | 2 lines

remove darwin 6

r53797 | [email protected] | 2009-07-14 08:05:37 +0200 (Tue, 14 Jul 2009) | 2 lines

php5, php5-devel: remove some variants (gmp, imap, pspell, tidy, readline) and default features (xslt, zlib, mcrypt, curl, gd) now offered in separate ports; see #19091

r53631 | [email protected] | 2009-07-10 20:33:03 +0200 (Fri, 10 Jul 2009) | 2 lines

php5, php5-devel: fix build failure on Mac OS X 10.6; see #19997

r53566 | [email protected] | 2009-07-08 13:17:14 +0200 (Wed, 08 Jul 2009) | 2 lines

php5, php5-devel: remove now-unnecessary reinplaces from mssql variant; see #20232

r53563 | [email protected] | 2009-07-08 12:05:04 +0200 (Wed, 08 Jul 2009) | 10 lines

php5: update to 5.3.0 (see #20119) and bring over related changes from php5-devel:

* sample php.ini file names have changed
* new mysqlnd variant for the MySQL native driver
* MIME magic is gone; see #18307
* imap variant: cclient is a build dependency only; see #20216
* minor changes to how fastcgi is enabled
* remove ext/date patch that has been integrated upstream
* refresh other patches

r53555 | [email protected] | 2009-07-08 05:32:08 +0200 (Wed, 08 Jul 2009) | 2 lines

php5: change path:-style apache dependencies to port:-style as was already done for php4 in r27786 and php5-devel when it was created in r27925

Reverting to a previous revision

There you have it. Revision r53563 changed the version of PHP to 5.3. If we want the older version of PHP, we need to checkout revision r53555. So we check out that revision:

svn update -r 53555 

This will update your php5 direcory to revision 53555. If you inspect the Portfile you will see that it is indeed the file for PHP 5.2.10, fully intact. Now all we need to do is remove the PHP version 5.3, update the portindex and install our PHP 5.2.

add comment
Commenting is closed for this item