diff --git a/setup/cli/modules/class.module.php b/setup/cli/modules/class.module.php index bfe32969b9e891d87e27f99a96aacfe1c64e8bfd..142a00283a23c1896a0ad64d2b83de499fc55b66 100644 --- a/setup/cli/modules/class.module.php +++ b/setup/cli/modules/class.module.php @@ -162,7 +162,7 @@ class Module { $this->parseOptions(); if (isset($this->_options[$name])) return $this->_options[$name]; - elseif ($this->options[$name]->default) + elseif (isset($this->options[$name]) && $this->options[$name]->default) return $this->options[$name]->default; else return $default; diff --git a/setup/cli/modules/deploy.php b/setup/cli/modules/deploy.php index 585f5314a02f8851f8814bd1bdcae561b48b29ca..4d48689927d1cd6fec2d087421229e3520fa23b9 100644 --- a/setup/cli/modules/deploy.php +++ b/setup/cli/modules/deploy.php @@ -11,6 +11,15 @@ class Deployment extends Unpacker { script to deploy changes made by you or upstream development to your installation target"; + function __construct() { + $this->options['dry-run'] = array('-t','--dry-run', + 'action'=>'store_true', + 'help'=>'Don\'t actually deploy new code. Just show the files + that would be copied'); + # super(*args); + call_user_func_array(array('parent', '__construct'), func_get_args()); + } + function find_root_folder() { # Hop up to the root folder of this repo $start = dirname(__file__); @@ -50,7 +59,8 @@ class Deployment extends Unpacker { # Unpack the include folder $this->unpackage("$root/include/{,.}*", $include, -1, array("*/include/ost-config.php")); - if (!$upgrade && $include != "{$this->destination}/include") + if (!$options['dry-run'] && !$upgrade + && $include != "{$this->destination}/include") $this->change_include_dir($include); } } diff --git a/setup/cli/modules/unpack.php b/setup/cli/modules/unpack.php index 318ac1d7d0ec4991a954c1173384d2237a744836..e338c283a55af9a628dad89a29b1ae6a86b9cc91 100644 --- a/setup/cli/modules/unpack.php +++ b/setup/cli/modules/unpack.php @@ -97,21 +97,23 @@ class Unpacker extends Module { * to disable exclusions */ function unpackage($folder, $destination, $recurse=0, $exclude=false) { - $verbose = $this->getOption('verbose'); + $dryrun = $this->getOption('dry-run', false); + $verbose = $this->getOption('verbose') || $dryrun; if (substr($destination, -1) !== '/') $destination .= '/'; foreach (glob($folder, GLOB_BRACE|GLOB_NOSORT) as $file) { if ($this->exclude($exclude, $file)) continue; if (is_file($file)) { - if (!is_dir($destination)) + if (!is_dir($destination) && !$dryrun) mkdir($destination, 0751, true); $target = $destination . basename($file); - if (is_file($target) && md5_file($target) == md5_file($file)) + if (is_file($target) && (md5_file($target) == md5_file($file))) continue; if ($verbose) $this->stdout->write($target."\n"); - copy($file, $target); + if (!$dryrun) + copy($file, $target); } } if ($recurse) {