diff options
author | Andy Wermke <andy@dev.next-step-software.com> | 2013-04-04 16:10:23 +0200 |
---|---|---|
committer | Andy Wermke <andy@dev.next-step-software.com> | 2013-04-04 16:10:23 +0200 |
commit | 92cd7f34b07e86062f2c024039e3309768b48ce6 (patch) | |
tree | 63b9f39280ebcab80742d9f2b4db6a139c1791e1 /bin | |
parent | 029d18f13bcf01aa2f1f08dbdfc6400c081bf7cb (diff) | |
parent | 443b92a7ee19e321b350750240e0fc54ec5be357 (diff) |
Merge branch 'master' of https://github.com/roundcube/roundcubemail
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/installto.sh | 2 | ||||
-rwxr-xr-x | bin/jsshrink.sh | 25 | ||||
-rwxr-xr-x | bin/jsunshrink.sh | 2 | ||||
-rwxr-xr-x | bin/makedoc.sh | 5 | ||||
-rwxr-xr-x | bin/moduserprefs.sh | 2 | ||||
-rwxr-xr-x | bin/update.sh | 42 | ||||
-rwxr-xr-x | bin/updatedb.sh | 201 |
7 files changed, 241 insertions, 38 deletions
diff --git a/bin/installto.sh b/bin/installto.sh index de96bf004..e6cf79d7d 100755 --- a/bin/installto.sh +++ b/bin/installto.sh @@ -35,7 +35,7 @@ if (!preg_match('/define\(.RCMAIL_VERSION.,\s*.([0-9.]+[a-z-]*)/', $iniset, $m)) $oldversion = $m[1]; -if (version_compare($oldversion, RCMAIL_VERSION, '>=')) +if (version_compare(version_parse($oldversion), version_parse(RCMAIL_VERSION), '>=')) die("Installation at target location is up-to-date!\n"); echo "Upgrading from $oldversion. Do you want to continue? (y/N)\n"; diff --git a/bin/jsshrink.sh b/bin/jsshrink.sh index 9cfd660bb..c79f90405 100755 --- a/bin/jsshrink.sh +++ b/bin/jsshrink.sh @@ -1,11 +1,12 @@ #!/bin/sh JS_DIR=`dirname "$0"`/../program/js JAR_DIR='/tmp' +LANG_IN='ECMASCRIPT3' CLOSURE_COMPILER_URL='http://closure-compiler.googlecode.com/files/compiler-latest.zip' do_shrink() { rm -f "$2" - java -jar $JAR_DIR/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js="$1" --js_output_file="$2" + java -jar $JAR_DIR/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js="$1" --js_output_file="$2" --language_in="$3" } if [ ! -d "$JS_DIR" ]; then @@ -37,12 +38,30 @@ if [ ! -r "$JAR_DIR/compiler.jar" ]; then rm -f "/tmp/$$.zip" fi -for fn in app common googiespell list; do +# compress single file from argument +if [ $# -gt 0 ]; then + JS_DIR=`dirname "$1"` + JS_FILE="$1" + + if [ $# -gt 1 ]; then + LANG_IN="$2" + fi + + if [ ! -r "${JS_FILE}.src" ]; then + mv "$JS_FILE" "${JS_FILE}.src" + fi + echo "Shrinking $JS_FILE" + do_shrink "${JS_FILE}.src" "$JS_FILE" "$LANG_IN" + exit +fi + +# default: compress application scripts +for fn in app common googiespell list treelist; do if [ -r "$JS_DIR/${fn}.js.src" ]; then echo "$JS_DIR/${fn}.js.src already exists, not overwriting" else mv "$JS_DIR/${fn}.js" "$JS_DIR/${fn}.js.src" fi echo "Shrinking $JS_DIR/${fn}.js" - do_shrink "$JS_DIR/${fn}.js.src" "$JS_DIR/${fn}.js" + do_shrink "$JS_DIR/${fn}.js.src" "$JS_DIR/${fn}.js" "$LANG_IN" done diff --git a/bin/jsunshrink.sh b/bin/jsunshrink.sh index 9d7755092..ef1bb47a1 100755 --- a/bin/jsunshrink.sh +++ b/bin/jsunshrink.sh @@ -6,7 +6,7 @@ if [ ! -d "$JS_DIR" ]; then exit 1 fi -for fn in app common googiespell list; do +for fn in app common googiespell list treelist; do if [ -r "$JS_DIR/${fn}.js.src" ]; then mv "$JS_DIR/${fn}.js.src" "$JS_DIR/${fn}.js" echo "Reverted $JS_DIR/${fn}.js" diff --git a/bin/makedoc.sh b/bin/makedoc.sh index 40c75bf47..2a34254cb 100755 --- a/bin/makedoc.sh +++ b/bin/makedoc.sh @@ -1,10 +1,11 @@ #!/bin/sh -TITLE="Roundcube Classes" +TITLE="Roundcube Webmail" PACKAGES="Core" INSTALL_PATH="`dirname $0`/.." PATH_PROJECT=$INSTALL_PATH/program/include +PATH_FRAMEWORK=$INSTALL_PATH/program/lib/Roundcube PATH_DOCS=$INSTALL_PATH/doc/phpdoc BIN_PHPDOC="`/usr/bin/which phpdoc`" @@ -20,6 +21,6 @@ TEMPLATE=earthli PRIVATE=off # make documentation -$BIN_PHPDOC -d $PATH_PROJECT -t $PATH_DOCS -ti "$TITLE" -dn $PACKAGES \ +$BIN_PHPDOC -d $PATH_PROJECT,$PATH_FRAMEWORK -t $PATH_DOCS -ti "$TITLE" -dn $PACKAGES \ -o $OUTPUTFORMAT:$CONVERTER:$TEMPLATE -pp $PRIVATE diff --git a/bin/moduserprefs.sh b/bin/moduserprefs.sh index a8fc3f655..b8ba98578 100755 --- a/bin/moduserprefs.sh +++ b/bin/moduserprefs.sh @@ -31,7 +31,7 @@ function print_usage() // get arguments -$args = rcube_utils:get_opt(array('u' => 'user', 'd' => 'delete')); +$args = rcube_utils::get_opt(array('u' => 'user', 'd' => 'delete')); if ($_SERVER['argv'][1] == 'help') { print_usage(); diff --git a/bin/update.sh b/bin/update.sh index 59aa596dd..05956b933 100755 --- a/bin/update.sh +++ b/bin/update.sh @@ -32,9 +32,11 @@ if (!$opts['version']) { echo "What version are you upgrading from? Type '?' if you don't know.\n"; if (($input = trim(fgets(STDIN))) && preg_match('/^[0-9.]+[a-z-]*$/', $input)) $opts['version'] = $input; + else + $opts['version'] = RCMAIL_VERSION; } -if ($opts['version'] && version_compare($opts['version'], RCMAIL_VERSION, '>')) +if ($opts['version'] && version_compare(version_parse($opts['version']), version_parse(RCMAIL_VERSION), '>=')) die("Nothing to be done here. Bye!\n"); @@ -124,7 +126,7 @@ if ($RCI->configured) { } } else { - echo "Please update your config files manually according to the above messages.\n\n"; + echo "Please update your config files manually according to the above messages.\n"; } } @@ -143,36 +145,18 @@ if ($RCI->configured) { // check database schema if ($RCI->config['db_dsnw']) { - $DB = rcube_db::factory($RCI->config['db_dsnw'], '', false); - $DB->db_connect('w'); - if ($db_error_msg = $DB->is_error()) { - echo "Error connecting to database: $db_error_msg\n"; - $success = false; - } - else if ($err = $RCI->db_schema_check($DB, false)) { - $updatefile = INSTALL_PATH . 'SQL/' . (isset($RCI->db_map[$DB->db_provider]) ? $RCI->db_map[$DB->db_provider] : $DB->db_provider) . '.update.sql'; - echo "WARNING: Database schema needs to be updated!\n"; - echo join("\n", $err) . "\n\n"; - $success = false; - - if ($opts['version']) { - echo "Do you want to run the update queries to get the schmea fixed? (y/N)\n"; - $input = trim(fgets(STDIN)); - if (strtolower($input) == 'y') { - $success = $RCI->update_db($DB, $opts['version']); - } - } - - if (!$success) - echo "Open $updatefile and execute all queries below the comment with the currently installed version number.\n"; - } + echo "Executing database schema update.\n"; + system(INSTALL_PATH . "bin/updatedb.sh --package=roundcube --version=" . $opts['version'] + . " --dir=" . INSTALL_PATH . DIRECTORY_SEPARATOR . "SQL", $res); + + $success = !$res; } - + // index contacts for fulltext searching - if (version_compare($opts['version'], '0.6', '<')) { + if (version_compare(version_parse($opts['version']), '0.6.0', '<')) { system(INSTALL_PATH . 'bin/indexcontacts.sh'); } - + if ($success) { echo "This instance of Roundcube is up-to-date.\n"; echo "Have fun!\n"; @@ -183,6 +167,4 @@ else { echo "Open http://url-to-roundcube/installer/ in your browser and follow the instuctions.\n"; } -echo "\n"; - ?> diff --git a/bin/updatedb.sh b/bin/updatedb.sh new file mode 100755 index 000000000..7fa8cceb9 --- /dev/null +++ b/bin/updatedb.sh @@ -0,0 +1,201 @@ +#!/usr/bin/env php +<?php +/* + +-----------------------------------------------------------------------+ + | bin/updatedb.sh | + | | + | This file is part of the Roundcube Webmail client | + | Copyright (C) 2010-2012, The Roundcube Dev Team | + | Copyright (C) 2010-2012, Kolab Systems AG | + | | + | Licensed under the GNU General Public License version 3 or | + | any later version with exceptions for skins & plugins. | + | See the README file for a full license statement. | + | | + | PURPOSE: | + | Update database schema | + +-----------------------------------------------------------------------+ + | Author: Aleksander Machniak <alec@alec.pl> | + +-----------------------------------------------------------------------+ +*/ + +define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); + +require_once INSTALL_PATH . 'program/include/clisetup.php'; + +// get arguments +$opts = rcube_utils::get_opt(array( + 'v' => 'version', + 'd' => 'dir', + 'p' => 'package', +)); + +if (empty($opts['dir'])) { + echo "ERROR: Database schema directory not specified (--dir).\n"; + exit(1); +} +if (empty($opts['package'])) { + echo "ERROR: Database schema package name not specified (--package).\n"; + exit(1); +} + +// Check if directory exists +if (!file_exists($opts['dir'])) { + echo "ERROR: Specified database schema directory doesn't exist.\n"; + exit(1); +} + +$RC = rcube::get_instance(); +$DB = rcube_db::factory($RC->config->get('db_dsnw')); + +// Connect to database +$DB->db_connect('w'); +if (!$DB->is_connected()) { + echo "Error connecting to database: " . $DB->is_error() . ".\n"; + exit(1); +} + +// Read DB schema version from database (if 'system' table exists) +if (in_array($DB->table_name('system'), (array)$DB->list_tables())) { + $DB->query("SELECT " . $DB->quote_identifier('value') + ." FROM " . $DB->quote_identifier($DB->table_name('system')) + ." WHERE " . $DB->quote_identifier('name') ." = ?", + $opts['package'] . '-version'); + + $row = $DB->fetch_array(); + $version = preg_replace('/[^0-9]/', '', $row[0]); +} + +// DB version not found, but release version is specified +if (!$version && $opts['version']) { + // Map old release version string to DB schema version + // Note: This is for backward compat. only, do not need to be updated + $map = array( + '0.1-stable' => 1, + '0.1.1' => 2008030300, + '0.2-alpha' => 2008040500, + '0.2-beta' => 2008060900, + '0.2-stable' => 2008092100, + '0.3-stable' => 2008092100, + '0.3.1' => 2009090400, + '0.4-beta' => 2009103100, + '0.4.2' => 2010042300, + '0.5-beta' => 2010100600, + '0.5' => 2010100600, + '0.5.1' => 2010100600, + '0.6-beta' => 2011011200, + '0.6' => 2011011200, + '0.7-beta' => 2011092800, + '0.7' => 2011111600, + '0.7.1' => 2011111600, + '0.7.2' => 2011111600, + '0.7.3' => 2011111600, + '0.7.4' => 2011111600, + '0.8-beta' => 2011121400, + '0.8-rc' => 2011121400, + '0.8.0' => 2011121400, + '0.8.1' => 2011121400, + '0.8.2' => 2011121400, + '0.8.3' => 2011121400, + '0.8.4' => 2011121400, + '0.8.5' => 2011121400, + '0.8.6' => 2011121400, + '0.9-beta' => 2012080700, + ); + + $version = $map[$opts['version']]; +} + +// Assume last version before the 'system' table was added +if (empty($version)) { + $version = 2012080700; +} + +$dir = $opts['dir'] . DIRECTORY_SEPARATOR . $DB->db_provider; +if (!file_exists($dir)) { + echo "DDL Upgrade files for " . $DB->db_provider . " driver not found.\n"; + exit(1); +} + +$dh = opendir($dir); +$result = array(); + +while ($file = readdir($dh)) { + if (preg_match('/^([0-9]+)\.sql$/', $file, $m) && $m[1] > $version) { + $result[] = $m[1]; + } +} +sort($result, SORT_NUMERIC); + +foreach ($result as $v) { + echo "Updating database schema ($v)... "; + $error = update_db_schema($opts['package'], $v, $dir . DIRECTORY_SEPARATOR . "$v.sql"); + + if ($error) { + echo "\nError in DDL upgrade $v: $error\n"; + exit(1); + } + echo "[OK]\n"; +} + +exit(0); + +function update_db_schema($package, $version, $file) +{ + global $DB; + + // read DDL file + if ($lines = file($file)) { + $sql = ''; + foreach ($lines as $line) { + if (preg_match('/^--/', $line) || trim($line) == '') + continue; + + $sql .= $line . "\n"; + if (preg_match('/(;|^GO)$/', trim($line))) { + @$DB->query(fix_table_names($sql)); + $sql = ''; + if ($error = $DB->is_error()) { + return $error; + } + } + } + } + + // escape if 'system' table does not exist + if ($version < 2013011000) { + return; + } + + $system_table = $DB->quote_identifier($DB->table_name('system')); + + $DB->query("UPDATE " . $system_table + ." SET " . $DB->quote_identifier('value') . " = ?" + ." WHERE " . $DB->quote_identifier('name') . " = ?", + $version, $package . '-version'); + + if (!$DB->is_error() && !$DB->affected_rows()) { + $DB->query("INSERT INTO " . $system_table + ." (" . $DB->quote_identifier('name') . ", " . $DB->quote_identifier('value') . ")" + ." VALUES (?, ?)", + $package . '-version', $version); + } + + return $DB->is_error(); +} + +function fix_table_names($sql) +{ + global $DB; + + foreach (array('users','identities','contacts','contactgroups','contactgroupmembers','session','cache','cache_index','cache_index','cache_messages','dictionary','searches','system') as $table) { + $real_table = $DB->table_name($table); + if ($real_table != $table) { + $sql = preg_replace("/([^a-z0-9_])$table([^a-z0-9_])/i", "\\1$real_table\\2", $sql); + } + } + + return $sql; +} + +?> |