diff --git a/setup/cli/modules/deploy.php b/setup/cli/modules/deploy.php index d307e51f2616e34ab378689b1993111b3b81eaa5..9ddde333f885193258f5d1b4eba1175d8ee1f0e8 100644 --- a/setup/cli/modules/deploy.php +++ b/setup/cli/modules/deploy.php @@ -99,10 +99,10 @@ class Deployment extends Unpacker { $upgrade = file_exists("{$this->destination}/main.inc.php"); # Get the current value of the INCLUDE_DIR before overwriting - # main.inc.php + # bootstrap.php $include = ($upgrade) ? $this->get_include_dir() : ($options['include'] ? $options['include'] - : "{$this->destination}/include"); + : rtrim($this->destination, '/')."/include"); $include = rtrim($include, '/').'/'; # Locate the upload folder @@ -119,9 +119,11 @@ class Deployment extends Unpacker { # Unpack the include folder $this->unpackage("$root/include/{,.}*", $include, -1, array("*/include/ost-config.php")); - if (!$options['dry-run'] - && $include != "{$this->destination}/include") - $this->change_include_dir($include); + if (!$options['dry-run']) { + if ($include != "{$this->destination}/include/") + $this->change_include_dir($include); + $this->touch_version(); + } if ($options['clean']) { // Clean everything but include folder first @@ -132,6 +134,30 @@ class Deployment extends Unpacker { "*/.htaccess")); } } + + function touch_version($version=false) { + if (!$version) + $version = exec('git describe'); + if (!$version) + return false; + + $bootstrap_php = $this->destination . '/bootstrap.php'; + $lines = explode("\n", file_get_contents($bootstrap_php)); + # Find the line that defines INCLUDE_DIR + $match = array(); + foreach ($lines as &$line) { + // TODO: Change THIS_VERSION inline to be current `git describe` + if (preg_match("/(\s*)define\s*\(\s*'THIS_VERSION'/", $line, $match)) { + # Replace the definition with the new locatin + $line = $match[1] . "define('THIS_VERSION', '" + . $version + . "'); // Set by installer"; + break; + } + } + if (!file_put_contents($bootstrap_php, implode("\n", $lines))) + die("Unable to write version information to bootstrap.php\n"); + } } Module::register('deploy', 'Deployment'); diff --git a/setup/cli/modules/unpack.php b/setup/cli/modules/unpack.php index af5cfd6247079facfcbf6215819475f0417be120..f200538ff5dcc5c911f8410e769b5aecfd6d01ef 100644 --- a/setup/cli/modules/unpack.php +++ b/setup/cli/modules/unpack.php @@ -72,7 +72,7 @@ class Unpacker extends Module { } } if (!file_put_contents($bootstrap_php, implode("\n", $lines))) - die("Unable to configure location of INCLUDE_DIR in main.inc.php\n"); + die("Unable to configure location of INCLUDE_DIR in bootstrap.php\n"); } function exclude($pattern, $match) { diff --git a/setup/cli/package.php b/setup/cli/package.php index e0b02cdea6725d3a8bd36387ba7e156c0765c32d..10fa537644dde35388e29a488aa19961dbdcf68e 100755 --- a/setup/cli/package.php +++ b/setup/cli/package.php @@ -143,9 +143,9 @@ chdir($stage_path); shell_exec("sed -ri -e \" s/( *)define\('THIS_VERSION'.*/\\1define('THIS_VERSION', '$version');/ \" upload/bootstrap.php"); -shell_exec("find . -name '*.inc.php' -print0 | xargs -0 sed -ri -e \" - s/( *)ini_set\( *'display_errors'[^)]+\);/\\1ini_set('display_errors', 0);/ - s/( *)ini_set\( *'display_startup_errors'[^)]+\);/\\1ini_set('display_startup_errors', 0);/ +shell_exec("find upload -name '*.php' -print0 | xargs -0 sed -i -e \" + s/\( *\)ini_set( *'display_errors'[^])]*);/\\1ini_set('display_errors', 0);/ + s/\( *\)ini_set( *'display_startup_errors'[^])]*);/\\1ini_set('display_startup_errors', 0);/ \""); shell_exec("tar cjf '$pwd/osTicket-$version.tar.bz2' *");