<?PHP
/**
* ((OTRS - Manager)), BUILD-SYSTEM
*
* This script load all necessary classes and starts the program.
* @author Mario Staas <hide@address.com>
* @copyright Copyright © 2006-2008, Mario Staas
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
error_reporting(E_ALL);
// analyse argv
array_shift($argv);
$argv_string = implode(' ', $argv);
$argv_array = explode('-', $argv_string);
/* Runtime settings */
$loglevel = 15;
$build_descriptor = '';
/*
* Analyze argv
*/
foreach ($argv_array as $option)
{
$parts = explode(' ', $option);
switch ($parts[0])
{
case 'l':
$loglevel = trim($parts[1]);
break;
case 'd':
$build_descriptor = trim($parts[1]);
break;
}
}
/*
* Setup runtime environment
*/
define ('TOKAWARE_LOGLEVEL', $loglevel);
// Basic configuration
define ('OTRSM_PFAD', dirname(__FILE__));
define ('OTRSM_PATH', dirname(__FILE__));
define ('OTRSM_CLASSES', OTRSM_PFAD .'/classes');
define ('OTRSM_ETC', OTRSM_PFAD .'/etc');
define ('OTRSM_PATH_PHP', OTRSM_PFAD .'/php');
define ('OTRSM_PREFIX', 'OTRS-Manager');
define ('OTRSM_BUILD_PATH', OTRSM_PFAD .'/../build');
if ($build_descriptor == '')
{
define ('OTRSM_BUILD_DESCRIPTOR', OTRSM_ETC .'/build_descriptor.xml');
}
else
{
define ('OTRSM_BUILD_DESCRIPTOR', OTRSM_PATH .'/' .$build_descriptor);
}
define ('OTRSM_PATH_MSGFMT', OTRSM_PFAD .'/bin');
define ('OTRSM_PATH_NSIS', OTRSM_PFAD .'/bin/nsis');
define ('OTRSM_LICENSE_FILE', OTRSM_PFAD .'/license.txt');
$appdata = getenv ("APPDATA");
if (!$appdata)
{
$appdata = getenv("USERPROFILE") .'/Application Data';
}
define ('OTRSM_APPDATA', "$appdata/Tokaware");
/* include classes */
include(OTRSM_ETC .'/otrs-manager.inc.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_framework.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_path.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_observer_publisher.class.php');
include(OTRSM_CLASSES .'/tokaware/interface/tokaware_observer_subscriber.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_observer_message.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_debug_writer.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_debugger_msg.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_debugger_client.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_gtk_button_factory.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_persistence.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_persistence_config.class.php');
include(OTRSM_CLASSES .'/tokaware/interface/tokaware_persistence_config_interface.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_msgfmt.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_gettext.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_template.class.php');
include(OTRSM_CLASSES .'/tokaware/toakware_env.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_extension.class.php');
include(OTRSM_CLASSES .'/tokaware/tokaware_text.class.php');
include(OTRSM_CLASSES .'/tokaware/file_watcher/tokaware_directory.class.php');
include(OTRSM_CLASSES .'/tokaware/file_watcher/tokaware_file.class.php');
include(OTRSM_CLASSES .'/tokaware/file_watcher/tokaware_file_watcher.class.php');
include(OTRSM_CLASSES .'/tokaware/file_watcher/tokaware_filter.class.php');
include(OTRSM_CLASSES .'/build/otrsm_builder.class.php');
include(OTRSM_CLASSES .'/build/otrsm_builder_metadata.class.php');
include(OTRSM_CLASSES .'/build/otrsm_plugin_builder.class.php');
include(OTRSM_CLASSES .'/build/otrsm_main_builder.class.php');
include(OTRSM_CLASSES .'/build/otrsm_test_environment_builder.class.php');
include(OTRSM_CLASSES .'/build/otrsm_nsis_builder.class.php');
include(OTRSM_CLASSES .'/build/otrsm_builder_factroy.class.php');
include(OTRSM_CLASSES .'/build/controller/otrsm_build.class.php');
include(OTRSM_CLASSES .'/build/view/otrsm_window_build.class.php');
include(OTRSM_CLASSES .'/build/controller/otrsm_custom_options.class.php');
include(OTRSM_CLASSES .'/build/view/otrsm_view_custom_options.class.php');
include(OTRSM_CLASSES .'/build/otrsm_file_watcher_factory.class.php');
include(OTRSM_CLASSES .'/build/otrsm_executor.class.php');
include(OTRSM_CLASSES .'/build/otrsm_prog_exec_factroy.class.php');
include(OTRSM_CLASSES .'/build/otrsm_nsis_executor.class.php');
include(OTRSM_CLASSES .'/build/otrsm_test_version_executor.class.php');
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
{
define ('OTRSM_LIB_SUFFIX', '.dll');
}
else
{
define ('OTRSM_LIB_SUFFIX', '.so');
}
/* check if debugger is online */
try
{
$td_msg = new tokaware_debugger_msg('', 0, 'DEBUG_TAIL_CLEAR');
tokaware_debugger_client::write($td_msg);
define ('TOKAWARE_DEBUGMODE', true);
}
catch (Exception $e)
{
define ('TOKAWARE_DEBUGMODE', false);
}
/*
* Analyze php environment
*/
$php_ini_path = '';
ob_start();
phpinfo(INFO_GENERAL);
$php_info = ob_get_contents();
ob_end_clean();
foreach (split("\n",$php_info) as $line)
{
if (! eregi('php.ini', $line))
{
continue;
}
$php_ini_path = explode('=>', $line);
$php_ini_path = trim($php_ini_path[1]);
if (!@file_exists($php_ini_path))
{
$php_ini_path = '';
}
}
if ($php_ini_path == '')
{
echo "ERROR : Can not find php.ini!\n";
echo "INFO : Please reinstall ((OTRS - Manager)) developer edition. \n";
exit();
}
ob_start();
phpinfo(INFO_MODULES);
$php_info = ob_get_contents();
ob_end_clean();
$gtk_version = '';
foreach (split("\n",$php_info) as $line)
{
if (! eregi('GTK\+ v', $line))
{
continue;
}
$gtk_version = explode('=>', $line);
$gtk_version = trim($gtk_version[1]);
}
if ($gtk_version == '')
{
tokaware_debug_writer::error('Can not find GTK+!');
tokaware_debug_writer::debug('Please reinstall GTK+');
exit();
}
define ('GTK_VERSION', $gtk_version);
otrs_define();
$env = tokaware_env::get_instance();
tokaware_debug_writer::notice('Starting ' .OTRSM_DISPLAY_NAME .' build system');
tokaware_debug_writer::notice('Version: ' .OTRSM_VERSION);
tokaware_debug_writer::notice('Cycle: ' .OTRSM_CYCLE);
tokaware_debug_writer::notice('Log-Level: ' .TOKAWARE_LOGLEVEL);
tokaware_debug_writer::debug('PHP: ' .$env->php_version);
tokaware_debug_writer::debug('PHP-Path: ' .OTRSM_PATH_PHP);
tokaware_debug_writer::debug('PHP_GTK: ' .$env->php_gtk_version);
tokaware_debug_writer::debug('GTK+: ' .$env->gtk_version);
/*
* Load php extensions (if not loaded)
*/
$tw_extension = new tokaware_extension();
$tw_extension->set_path_to_php(OTRSM_PATH_PHP);
$extensions = array
(
'bz2',
'php-gtk',
'zip',
'gd',
'wddx',
'win32std'
);
if (!$tw_extension->load_extensions($extensions))
{
var_dump($tw_extension->get_loaded_extensions());
exit;
}
/*
* Parse GTK+ settings
*/
GTK::rc_parse (OTRSM_PATH_PHP ."/etc/gtk-2.0/gtkrc");
$otrsm_build = new otrsm_build();
// run gtk main iteration
Gtk::main();
?>