Creating PEAR-installable nightly builds :: a programmer's best friend |
Sunday, August 20. 2006Creating PEAR-installable nightly builds
If you incorporate a "release early, release often" policy for your projects, it helps you to detect bugs in an early development stage of your application. In many cases making a release takes some time and you do not release new versions as often as you intended. We had these problems with our projects over at www.php-tools.net. That's why we created snaps.php-tools.net, a site where you can download nightly builds of our projects as ZIP, TAR.GZ or TAR.BZ2 archive. This saves the users, who want to test the latest development versions the hassle checking out the latest version from our subversion repository. The problem of this technique was, that most users use the PEAR installer to deploy our packages and if they downloaded a ZIP file, it's not possible to use the PEAR installer on this file. That's why we came up with a solution to create nightly builds that are installable with the PEAR installer. Read on, if you are interested in how this can be achieved...
To create a PEAR installable package, all you need is a package.xml file, that contains all information about the project and the related files. So to create a nightly build, you will need a current package.xml that describes the package. Creating this by hand can be very cumbersome, as it has to contain all dependencies as well as all files that you want to include in the resulting package. But help has arrived, as Greg Beaver provides a PEAR package that aids you in the creation of package.xml files: PEAR_PackageFileManager. This package provides a PHP-API to read, modify and write the package.xml file needed to create an installable package. To automate this process, you need to follow these steps:
$ svn export http://www.php-tools.net/svn/patTemplate/trunk patTemplateNow that you have exported the latest code-base the next steps is to create a unique version number. We decided that we wanted to use the latest officially released version (e.g. 3.1.0) and add a version suffix. This suffix could either be the latest SVN revision, or the date that the last change has been made.As the revision in Subversion is incremented for the complete repository, once a commit has been made and all our projects share a common repository, we decided to use the date of the last change in the project folder as the version suffix. Once you have checked out the contents, this can be easily accomplished using the SPL's RecursiveDirectoryIterator: function getLastModifiedDate($folder) {This information now has to be used in a script, that will generate the package.xml file. For snaps.php-tools.net, we decided to split these tasks. The SVN export and the generation of the version suffix is handled by a simple script createSnaps.php which also build the plain ZIP or TAR archives.After exporting the latest SVN version, this script searches for a file called autopackage2.php. If the file is available, it will execute the file and pass the version suffix as the sole parameter. $createPackageFile = "php autopackage2.php " . date( 'YmdHi', $mtime );The autopackage2.php file then will use PEAR_PackageFileManager to create the current package.xml file. I will not go into detail here, you may take a look at an example in the patTemplate subversion repository. The most important part is, how the version number is created:// Base version Furthemore it uses a filelistegenerator provided by PEAR_PAckageFileManager to include all files that have been exported from SVN. This autopackage2.php script will generate a package.xml file and save it on disk. To create a PEAR installable package from this newly generated package.xml file, all that's left to do is execute the following command:$ pear package -nThe -n switch is used to echo the full path to the generated .tgz package file after it has been generated. We use it to move this file to the document root, so it can be downloaded. And voilá you created a PEAR-installable nightly build.For snaps.php-tools.net we also implemented some more features:
$ svn co http://www.php-tools.net/svn/patSnaps/trunkBeware that some of the code is several years old and while it works with PHP 5.1 it surely could be optimized. Examples for the autopackage2.php file are available in the subversion repositories for patTemplate, patForms and patBBCode.
Posted by schst
in PHP, PAT
at
11:23
| Trackbacks (12)
View as PDF: This entry | This month | Full blog Comments
Display comments as
(Linear | Threaded)
No comments
The author does not allow comments to this entry
|
Notice: in /var/www/schst/blog.php-tools.net/htdoc/bundled-libs/PEAR.php on line 848 |
hkirhltryu medbdnnbqxk fxlswwlxc wnjelthk
Tracked: Oct 18, 09:26
valium drug test roche valium valium addiction cheap valium valium overdose fkibdgipwa
Tracked: Oct 18, 10:34
valium information online pharmacy valium dj valium drug valium prescription valium kktxkxlc
Tracked: Oct 18, 15:15
valium on line valium sale valium valium without prescription drug valium fvevzfnihe
Tracked: Oct 18, 16:42
valium online valium xanax valium valium picture valium online mheotkug
Tracked: Oct 18, 18:21
valium overdose valium diazepam online pharmacy valium valium effects buy valium online ewkvgfny
Tracked: Oct 18, 20:15
valium picture prescription valium side effects of valium and diazepam valium addiction valium logvlohhbc
Tracked: Oct 18, 21:54
valium sale how long does valium stay in your system valium withdrawal valium side effects online pharmacy valium iuhhntcvg
Tracked: Oct 19, 01:21
valium side effects valium online prescription valium valium addiction order valium jluupldkfju
Tracked: Oct 19, 03:00
valium withdrawal generic valium valium online order valium online cheap valium veawxcgfc
Tracked: Oct 19, 04:20
valium without prescription dj valium how long does valium stay in your system valium pill valium on line dazihyiwtq
Tracked: Oct 19, 05:54
xanax valium buy valium online valium online purchase valium valium pill lsdgthjogk
Tracked: Oct 19, 07:24