private function upgrade_system() { $tool_dir = dirname(__FILE__) . '/../../'; $tool_dir = realpath($tool_dir); // Get version data $source = $this->spark_sources[0]; if (!$source) { throw new Spark_exception('No sources listed - unsure how to upgrade'); } if (!$source->outdated()) { Spark_utils::warning('Spark manager is already up to date'); return; } // Build a spark and download it $data = null; $data->name = 'Spark Manager'; $data->archive_url = $source->version_data->spark_manager_download_url; $zip_spark = new Zip_spark($data); $zip_spark->retrieve(); // Download the new version // Remove the lib directory and the spark unlink($tool_dir . '/spark'); Spark_utils::remove_full_directory($tool_dir . '/lib'); // Link up the new version Spark_utils::full_move($zip_spark->temp_path . '/lib', $tool_dir . '/lib'); @rename($zip_spark->temp_path . '/spark', $tool_dir . '/spark'); @`chmod u+x {$tool_dir}/spark`; // Tell the user the story of what just happened Spark_utils::notice('Spark manager has been upgraded to ' . $source->version . '!'); }
function install_dependency($dependency_data) { // Get the spark object $spark = null; if ($dependency_data->repository_type == 'hg') { $spark = Mercurial_spark::get_spark($dependency_data); } else { if ($dependency_data->repository_type == 'git') { $spark = Git_spark::get_spark($dependency_data); } else { if ($dependency_data->repository_type == 'zip') { $spark = new Zip_spark($dependency_data); } else { throw new Exception('Unknown repository type: ' . $dependency_data->repository_type); } } } // Install the spark if ($spark->verify(false)) { // if not installed, install $spark->retrieve(); $spark->install(); Spark_utils::notice("Installed dependency: {$spark->name} to " . $spark->installed_path()); } else { Spark_utils::warning("Dependency {$spark->name} is already installed."); } }