From 834ed8dbb2b4ef8492dc56868c8ec5d00332a799 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 6 Dec 2010 12:58:28 -0700 Subject: [PATCH] install_dev now accepts command line arguments --- framework/bin/install_dev | 67 ++++++++++++++++++++++++++++++++++--- framework/bin/install_dev.conf.dist | 4 +-- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/framework/bin/install_dev b/framework/bin/install_dev index 7fef01211..f2f78af22 100755 --- a/framework/bin/install_dev +++ b/framework/bin/install_dev @@ -5,17 +5,76 @@ * while allowing changes made to the repository source to also be reflected * in the local installation. * - * Requires the file 'install_dev.conf' to live in the same directory as - * this script. + * If run with no arguments, reads in config values from the file + * ./install_dev.conf. * - * @author Michael Slusarz + * @author Michael Slusarz + * @category Horde */ -require_once dirname(__FILE__) . '/install_dev.conf'; +require_once 'Console/Getopt.php'; +$c = new Console_Getopt(); +$argv = $c->readPHPArgv(); +array_shift($argv); + +/* Defaults */ +$apps = array(); +$debug = $git = false; +$horde_git = $static_group = $web_dir = ''; +$static_mode = 0775; + +if (count($argv)) { + $options = $c->getopt2($argv, '', array('apps=', 'config=', 'debug', 'git', 'group=', 'hordegit=', 'mode=', 'webdir=')); + if ($options instanceof PEAR_Error) { + exit("Invalid arguments.\n"); + } + + foreach ($options[0] as $val) { + switch ($val[0]) { + case '--apps': + $apps = explode(',', $val[1]); + break; + + case '--config': + require_once $val[1]; + break; + + case '--debug': + $debug = (bool)$val[1]; + break; + + case '--git': + $git = (bool)$val[1]; + break; + + case '--group': + $static_group = $val[1]; + break; + + case '--hordegit': + $horde_git = $val[1]; + break; + + case '--mode': + $mode = $val[1]; + break; + + case '--webdir': + $web_dir = $val[1]; + break; + } + } +} else { + require_once dirname(__FILE__) . '/install_dev.conf'; +} $horde_git = rtrim(ltrim($horde_git), '/ '); $web_dir = rtrim(ltrim($web_dir), '/ '); +if ($git && ($git === true)) { + $git = 'git fetch && ( git rebase -v origin || ( git stash && ( git rebase -v origin || echo "WARNING: Run \'git stash pop\' manually!" ) && git stash pop ) )'; +} + print "EMPTYING old web directory " . $web_dir . "\n"; try { $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($web_dir), RecursiveIteratorIterator::CHILD_FIRST); diff --git a/framework/bin/install_dev.conf.dist b/framework/bin/install_dev.conf.dist index c9cb20284..bc5ef0420 100644 --- a/framework/bin/install_dev.conf.dist +++ b/framework/bin/install_dev.conf.dist @@ -4,8 +4,8 @@ $debug = false; // Do git update before building web directory? If this is non-false, runs -// this command in each repository -// $git = 'git fetch && ( git rebase -v origin || ( git stash && ( git rebase -v origin || echo "WARNING: Run \'git stash pop\' manually!" ) && git stash pop ) )'; +// this command in each repository. If non-false and true, runs this command: +// 'git fetch && ( git rebase -v origin || ( git stash && ( git rebase -v origin || echo "WARNING: Run \'git stash pop\' manually!" ) && git stash pop ) )'; $git = false; // The list of apps to create symlinks for -- 2.11.0