示例#1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $force = $input->getOption('force');
     $config_si = $input->getOption('config');
     $installer = new Installer($this->getService('sugarcrm.application'), $input->getOption('source'), $config_si);
     try {
         $installer->run($force);
         $output->writeln('Installation was sucessfully completed.');
     } catch (InstallerException $e) {
         $logger = $this->getService('logger');
         $logger->error('An error occured during the installation.');
         $logger->error($e->getMessage());
         return ExitCode::EXIT_INSTALL_ERROR;
     }
 }
示例#2
0
 /**
  * Extract the source archive into $this->getPath().
  * While extracting, we remove the top folder from the filename inside the archive.
  * For example, a file 'SugarPro-Full-7.2.1/soap.php' will get extracted to
  * <install_path>/soap.php .
  */
 public function extract()
 {
     $this->getLogger()->info("Extracting {$this->source} into " . $this->getPath() . '...');
     if (!is_dir($this->getPath()) || !$this->fs->isEmpty($this->getPath())) {
         throw new InstallerException("The target path {$this->getPath()} is not a directory or is not empty when extracting the archive.");
     }
     if (!is_file($this->source)) {
         throw new InstallerException("{$this->source} doesn't exists or is not a file.");
     }
     $zip = new \ZipArchive();
     if ($zip->open($this->source) !== true) {
         throw new InstallerException("Unable to open zip {$this->source}.");
     }
     $zip_paths = array();
     for ($i = 0; $i < $zip->numFiles; $i++) {
         $zip_paths[$i] = $zip->getNameIndex($i);
     }
     $target_paths = Installer::junkParent($zip_paths);
     foreach ($target_paths as $i => $name) {
         if (empty($name)) {
             continue;
         }
         $target_path = $this->getPath() . '/' . $name;
         // Check is name ends with '/' (directory name)
         if (strpos($name, '/', strlen($name) - 1) === false) {
             // We have a file name
             // We load each zipped file in memory.
             // It is much faster than getting the Stream handle.
             // For Sugar 7 archive we peak at 24MB so it shouldn't be an issue.
             $content = $zip->getFromIndex($i);
             if ($content === false) {
                 throw new InstallerException("Error while extracting {$name} from the archive.");
             }
             if (file_put_contents($target_path, $content) === false) {
                 throw new InstallerException("Error while writting to file {$target_path}.");
             }
         } else {
             // We have a dir name
             $this->fs->mkdir($target_path);
         }
     }
     if (!$zip->close()) {
         throw new InstallerException("Unable to close zip {$this->source}.");
     }
     $this->getLogger()->info('Extraction OK.');
 }
示例#3
0
 /**
  * @group sugar
  */
 public function testInstall()
 {
     $this->assertFileExists(getenv('SUGARCRM_PATH'), 'Please specify the SUGARCRM_PATH from the environment or phpunit.xml file.');
     $install_path = getenv('SUGARCRM_PATH') . '/inetprocess_installer';
     $fs = new Filesystem();
     if ($fs->exists($install_path)) {
         $fs->remove($install_path);
     }
     $fs->mkdir($install_path);
     $installer = new Installer($this->newApp($install_path), __DIR__ . '/installer/Fake_Sugar.zip', __DIR__ . '/installer/config_si.php');
     $installer->run();
     $this->assertTrue($installer->getApplication()->isValid(), 'The install did not extract the zip archive correctly');
     $this->assertTrue($installer->getApplication()->isInstalled(), 'The installer did not perform the sugar installation correctly.');
     $sugar_config = $installer->getApplication()->getSugarConfig();
     $this->assertEquals('UTF-8', $sugar_config['default_export_charset']);
     $fs->remove($install_path);
 }