Regarding
http://greg.chiaraquartet.net/archives/5-Post-install-Scripts-in-PEAR-1.4.0.html, I have taken the suggestions into account and reworked the way post-install scripts work in
PEAR.
First off, the xml representation has not changed a bit, but now post-install scripts must be run manually with the "pear run-scripts <packagename>" command. This has several nice advantages
- It's MUCH easier to debug
- The script can be run multiple times without penalty, if the first time fails
I also took Jan Schneider's suggestion about including the previously installed version and took it one step further. Now, the previously installed version, if any, is stored directly in the registry. This could allow all kinds of nice processing for the future, including the revert command. This also means that the previous version or null is passed into the "init()" function for use by the post-install script to determine how it should install/upgrade non-PEAR elements.
This will also address any security concerns, as scripts cannot be run manually, and can only be run after installation has completed. Users can even open up the install scripts in any text editor to see what they do, as all post-install scripts must be PHP code in order to work.
Here is the sequence users should expect, when installing a package that contains post-installation scripts
$ pear install postinstall
Install OK channel://pear.php.net/postinstall-1.0.0
postinstall contains installation scripts, use "pear run-scripts pear/postinstall" to run them
$ pear run-scripts postinstall
...
Note that pear/postinstall = pear.php.net/postinstall = postinstall if and only if the default_channel is pear.php.net (which is the installation default).
Hopefully this clears up any problems that others noted!