| 1 | #! /usr/local/bin/php |
|---|
| 2 | <?php |
|---|
| 3 | /** |
|---|
| 4 | * Make a standalone ready to go PHPonTrax application |
|---|
| 5 | * |
|---|
| 6 | * (PHP 5) |
|---|
| 7 | * |
|---|
| 8 | * Simply run <b>php make-standalone.php</b>. |
|---|
| 9 | * Once ran this script will generate a folder "trax-standalone" and a tar file of that folder. |
|---|
| 10 | * That folder is the standalone version that you can used to build an app just as if you ran |
|---|
| 11 | * the "trax ." command and generated a fresh app. |
|---|
| 12 | * |
|---|
| 13 | * This script is mainly for me to make the standalone version easily, but included |
|---|
| 14 | * it for anyone that wants to play with it. |
|---|
| 15 | * |
|---|
| 16 | * Required to use this is Unix-type system (I think), wget, tar, svn, PHPonTrax already installed. |
|---|
| 17 | * |
|---|
| 18 | * @package PHPonTrax |
|---|
| 19 | * @version $Id$ |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | echo "cleaning up old builds of trax-standalone\n"; |
|---|
| 23 | exec("rm -Rf trax-standalone*"); |
|---|
| 24 | echo "creating folder trax-standalone\n"; |
|---|
| 25 | mkdir("trax-standalone"); |
|---|
| 26 | |
|---|
| 27 | if(!is_dir("trax-standalone")) { |
|---|
| 28 | echo "no trax-standalone dir\n"; |
|---|
| 29 | exit; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | chdir("trax-standalone"); |
|---|
| 33 | |
|---|
| 34 | echo "creating trax skeleton files\n"; |
|---|
| 35 | exec("trax ".dirname(__FILE__)."/trax-standalone"); |
|---|
| 36 | |
|---|
| 37 | echo "fetching README\n"; |
|---|
| 38 | exec("wget http://www.phpontrax.com/downloads/README-standalone.txt"); |
|---|
| 39 | rename("README-standalone.txt", "README"); |
|---|
| 40 | |
|---|
| 41 | chdir("vendor"); |
|---|
| 42 | echo "fetching PEAR files\n"; |
|---|
| 43 | exec("wget http://www.phpontrax.com/downloads/PEAR.tar.gz"); |
|---|
| 44 | echo "untarring PEAR files\n"; |
|---|
| 45 | exec("tar zxvf PEAR.tar.gz"); |
|---|
| 46 | echo "removing PEAR tar file.\n"; |
|---|
| 47 | unlink("PEAR.tar.gz"); |
|---|
| 48 | echo "checking out edge Trax from svn\n"; |
|---|
| 49 | exec("svn co svn://svn.phpontrax.com/trax/trunk/trax/vendor/trax trax"); |
|---|
| 50 | |
|---|
| 51 | chdir("../"); |
|---|
| 52 | echo "updating config files\n"; |
|---|
| 53 | $htaccess = file_get_contents("./public/.htaccess"); |
|---|
| 54 | file_put_contents("./public/.htaccess", str_replace(dirname(__FILE__)."/trax-standalone/config", "/home/username/trax/config", $htaccess)); |
|---|
| 55 | $environment = file_get_contents("./config/environment.php"); |
|---|
| 56 | $environment = str_replace("# define(\"PHP_LIB_ROOT\", \"/usr/local/lib/php\");", "define(\"PHP_LIB_ROOT\", dirname(dirname(__FILE__)).\"/vendor/PEAR\");", $environment); |
|---|
| 57 | $environment = str_replace("# define(\"TRAX_ROOT\", dirname(dirname(__FILE__)));", "define(\"TRAX_ROOT\", dirname(dirname(__FILE__)));", $environment); |
|---|
| 58 | file_put_contents("./config/environment.php", $environment); |
|---|
| 59 | include("./vendor/trax/trax.php"); |
|---|
| 60 | $version = Trax::version(); |
|---|
| 61 | chdir("../"); |
|---|
| 62 | exec("tar zcvf trax-standalone-".$version.".tar.gz trax-standalone"); |
|---|
| 63 | |
|---|
| 64 | echo "done creating standalone Trax\n"; |
|---|
| 65 | |
|---|
| 66 | ?> |
|---|