Tidy, PHP and Mac

September 8, 2009

Oh, how you don’t play well together. In case anybody else has this problem, it is typified by:


/private/tmp/pear/download/tidy-1.2/tidy.c:463: warning: pointer targets in initialization differ in signedness
/private/tmp/pear/download/tidy-1.2/tidy.c: In function 'zif_tidy_parse_file':
/private/tmp/pear/download/tidy-1.2/tidy.c:490: warning: pointer targets in passing argument 2 of 'tidyBufAttach' differ in signedness
make: *** [tidy.lo] Error 1
ERROR: `make' failed

To fix it (thanks to dams at PHP):

“Get the libtidy from the CVS on their project. Compile and install it, then modify /usr/include/tidy/platform.h:

on line 530 comment [out] the line:

typedef unsigned long ulong;”

After this, tidy should install properly.

References:

http://bugs.php.net/bug.php?id=36164&edit=1

http://aspn.activestate.com/ASPN/Mail/Message/php-dev/3390328

Framework auto-updates

September 7, 2009

One of the more annoying things about web frameworks I’ve used is that if you started a project and you suddenly need a feature and need to update or slide back a version, it’s a pain in the posterior.

In ploof I’m trying to solve this problem with diffs and patches for the core files.

The ploof command, available on the command line, provides this functionality. Even though ploof doesn’t have any releases (proper), you can tell your ploof export to update to a particular revision:

./ploof update trunk

or

./ploof update 1.0

(note that as of this writing there is no 1.0 version, so trunk is all you get)

The essential strategy is to export another version in the resource subdirectory, run a diff against what you currently have installed, and patch it automatically.

Here’s the code:

function generate_patch($version= "trunk")
{
    if (opendir("resource/updates"))
        exec("rm -rf resource/updates");
    
    // export a copy of the code off the server:
    exec("mkdir resource/updates");
    if ($version != "trunk")
        $version= "branches/".$version;
    
    exec("svn export http://ploof.googlecode.com/svn/$version ./resource/updates/svn");
    
    // build patch files:
    exec("diff -rupN -x .svn ./core ./resource/updates/svn/core > ./resource/updates/core.patch");
    exec("diff -rupN -x .svn ./config/config.default.php ./resource/updates/svn/config/config.default.php > ./resource/updates/config.patch");
    exec("diff -rupN -x .svn ./ploof ./resource/updates/svn/ploof > ./resource/updates/ploof.patch");
}

function patch()
{
    // apply the patches:
    exec("patch -p1 < ./resource/updates/core.patch");
    exec("patch -p1 < ./resource/updates/config.patch");
    exec("patch -p1 < ./resource/updates/ploof.patch");
}
function update($version= "trunk")
{
    generate_patch($version);
    patch();
}

I separated the update() method into patch() and generate_patch() for testing purposes.

This isn’t perfect (it needs to address core CSS/HSS/JS merging, and needs to ignore other VCS’s), but it’s a start toward better framework integration into our normal development workflow.

Follow

Get every new post delivered to your Inbox.