Installing old libxml2 ports with MacPorts
There is a problem with libxml2 from version 2.7.1 onward where it completely deletes any greater than (>) and less than symbols (<) sent to it. This is messing up my blog posting unless I do it within the WordPress interface since attempts to use xmlrpc.php use PHP, which is compiled against libxml2, and thus the posting gets mangled.
The solution suggested on the PHP boards is to compile PHP against expat. This would be kind of a pain for me since I am using the MacPorts install of PHP. So I looked into rolling back to an earlier version of libxml2 using MacPorts. The solution was originally outlined in this blog post by Stephen Chu on how to install earlier versions of ruby under DarwinPorts, I have updated it for MacPorts. The key is to create a local MacPorts repository with the version of the port you want copied over to it.
- First I identified the version of the libxml2 portfile I wanted by going to http://trac.macports.org/browser/trunk/dports/textproc/libxml2/Portfile and entering revisions into the “View revision” box until I found the appropriate version of the Portfile linking to libxml2 2.6.32 instead of 2.7.1. This turned out to be revision 40211 (actually 39551).
- I created a directory to contain my MacPorts repository at
/Users/Shared/dports/and after creating that directory, I edited the MacPorts configuration file/opt/local/etc/macports/sources.confto include the line:file:///Users/Shared/dportsand you should make this line appear before the “rsync” or svn” port listing in the config file, otherwise it defaults to using that version of the port during the install.
- I then installed the old libxml2 port into my local MacPorts respository using subversion:
and then I updated the MacPorts index:svn co --revision 40211 http://trac.macports.org/browser/trunk/dports/textproc/libxml2/ textproc/libxml2/
portindex /Users/Shared/dportsWith this done, I can see the two versions of
libxml2in my ports list, when I issue aport list libxml2the result is:
libxml2 @2.7.2 textproc/libxml2 libxml2 @2.6.32 textproc/libxml2showing the current
libxml2version in MacPorts and the older one in my repository. - Now I can install the older version of libxml2 by first forcing removal of the current version and then installing the old version:
sudo port -f uninstall libxml2 @2.7.2_1+darwin_9 sudo port install libxml2 @2.6.32[Warning: Unless you place the
file:///Users/Shared/dportsline before any rsync/svn lines of the config file noted in step 2, this port install command installs the current version instead of the old version] - I had to forcible uninstall and then reinstall libxslt but then my reinstall of php within MacPorts went fine. And I can now use WordPress again without any issues when using a remote blog editor.
I just figured in case anyone else wanted to use an older MacPort port they could use this to figure out how.

