Install fresh version of the database from db_structure and db_data files

@param  AbstractInstall $installScript
@param  OutputInterface $output        Command line output interface
342740
protected function install(AbstractInstall $installScript, OutputInterface $output)
    {
        $dataPath = DATADIR;

        $output->writeln('  Installing App...');

        // Install the database structure
        $this->runSql(
            $dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::STRUCTURE_FILE,
            '  Creating initial database schema',
            sprintf('  Database schema file %s not found', GenerateInstallCommand::STRUCTURE_FILE),
            $output
        );

        // Install the database data
        $this->runSql(
            $dataPath.DIRECTORY_SEPARATOR.GenerateInstallCommand::DATA_FILE,
            '  Inserting initial data',
            sprintf('  Database data file %s not found', GenerateInstallCommand::DATA_FILE),
            $output
        );

        $output->writeln('  Running install script');

        $installScript->execute($this->db);

        $output->write(['  Install completed!', ''], true);
    }
343790
public static function install()
    {
        update_option('search-statistics-db-version', 0);
        $charsetCollation = self::$wpdb->get_charset_collate();
        $tableName = self::$dbTable;

        if (!empty(get_site_option('search-statistics-db-version')) && self::$wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
            return;
        }

        $sql = "CREATE TABLE $tableName (
            id bigint(20) NOT NULL AUTO_INCREMENT,
            query varchar(255) DEFAULT NULL,
            results bigint(20) DEFAULT 0 NOT NULL,
            site_id bigint(20) DEFAULT NULL,
            logged_in tinyint(1) DEFAULT 0 NOT NULL,
            date_searched timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
            UNIQUE KEY id (id)
        ) $charsetCollation;";

        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);

        update_option('search-statistics-db-version', 2);
    }
459077
public static function create(IOInterface $io, Composer $composer, InputInterface $input): BaseInstaller
    {
        $config    = $composer->getConfig();
        $installer = new BaseInstaller(
            $io,
            $config,
            $composer->getPackage(),
            $composer->getDownloadManager(),
            $composer->getRepositoryManager(),
            $composer->getLocker(),
            $composer->getInstallationManager(),
            $composer->getEventDispatcher(),
            $composer->getAutoloadGenerator()
        );

        [$preferSource, $preferDist] = self::getPreferredInstallOptions($config, $input);

        $optimize      = self::getOption($input, 'optimize-autoloader')    || (bool) $config->get('optimize-autoloader');
        $authoritative = self::getOption($input, 'classmap-authoritative') || (bool) $config->get('classmap-authoritative');
        $apcu          = self::getOption($input, 'apcu-autoloader')        || (bool) $config->get('apcu-autoloader');

        $installer
            ->disablePlugins()
            ->setPreferSource($preferSource)
            ->setPreferDist($preferDist)
            ->setDryRun(self::getOption($input, 'dry-run'))
            ->setVerbose(self::getOption($input, 'verbose'))
            ->setDevMode(! self::getOption($input, 'no-dev'))
            ->setSuggestedPackagesReporter(new SuggestedPackagesReporter(new NullIO()))
            ->setDumpAutoloader(! self::getOption($input, 'no-autoloader'))
            ->setRunScripts(! self::getOption($input, 'no-scripts'))
            ->setOptimizeAutoloader($optimize)
            ->setClassMapAuthoritative($authoritative)
            ->setApcuAutoloader($apcu)
            ->setIgnorePlatformRequirements(self::getOption($input, 'ignore-platform-reqs'))
            ->setUpdate(true);

        return $installer;
    }
220320
public function updatePackages(InstallerInterface $installer)
    {
        $decode = $this->config->getBowerFileContent();
        if (!empty($decode['dependencies'])) {
            foreach ($decode['dependencies'] as $packageName => $requiredVersion) {
                $this->updatePackage(new Package($packageName, $requiredVersion), $installer);
            }
        }
    }
636462
protected function registerInstallCommand(): void
    {
        $this->app->singleton('orchestra.commands.tenanti.install', function (Application $app) {
            return new InstallCommand($app->make('orchestra.tenanti'));
        });
    }
1131916
function install( $package, $installType, $parameters,
                      $name, $os, $filename, $subdirectory,
                      $content, &$installParameters,
                      &$installData )
    {
        $serializedNameListNode = $content->getElementsByTagName( 'serialized-name-list' )->item( 0 );
        $serializedNameList = $serializedNameListNode ? $serializedNameListNode->textContent : false;
        $classNameList = new eZContentClassNameList( $serializedNameList );
        if ( $classNameList->isEmpty() )
        {
            $classNameList->initFromString( $content->getElementsByTagName( 'name' )->item( 0 )->textContent ); // for backward compatibility( <= 3.8 )
        }
        $classNameList->validate( );

        $serializedDescriptionListNode = $content->getElementsByTagName( 'serialized-description-list' )->item( 0 );
        $serializedDescriptionList = $serializedDescriptionListNode ? $serializedDescriptionListNode->textContent : false;
        $classDescriptionList = new eZSerializedObjectNameList( $serializedDescriptionList );

        $classIdentifier = $content->getElementsByTagName( 'identifier' )->item( 0 )->textContent;
        $classRemoteID = $content->getElementsByTagName( 'remote-id' )->item( 0 )->textContent;
        $classObjectNamePattern = $content->getElementsByTagName( 'object-name-pattern' )->item( 0 )->textContent;
        $classURLAliasPattern = is_object( $content->getElementsByTagName( 'url-alias-pattern' )->item( 0 ) ) ?
            $content->getElementsByTagName( 'url-alias-pattern' )->item( 0 )->textContent :
            null;
        $classIsContainer = $content->getAttribute( 'is-container' );
        if ( $classIsContainer !== false )
            $classIsContainer = $classIsContainer == 'true' ? 1 : 0;

        $classRemoteNode = $content->getElementsByTagName( 'remote' )->item( 0 );
        $classID = $classRemoteNode->getElementsByTagName( 'id' )->item( 0 )->textContent;
        $classGroupsNode = $classRemoteNode->getElementsByTagName( 'groups' )->item( 0 );
        $classCreated = $classRemoteNode->getElementsByTagName( 'created' )->item( 0 )->textContent;
        $classModified = $classRemoteNode->getElementsByTagName( 'modified' )->item( 0 )->textContent;
        $classCreatorNode = $classRemoteNode->getElementsByTagName( 'creator' )->item( 0 );
        $classModifierNode = $classRemoteNode->getElementsByTagName( 'modifier' )->item( 0 );

        $classAttributesNode = $content->getElementsByTagName( 'attributes' )->item( 0 );

        $dateTime = time();
        $classCreated = $dateTime;
        $classModified = $dateTime;

        $userID = false;
        if ( isset( $installParameters['user_id'] ) )
            $userID = $installParameters['user_id'];

        $class = eZContentClass::fetchByRemoteID( $classRemoteID );

        if ( $class )
        {
            $className = $class->name();
            $description = ezpI18n::tr( 'kernel/package', "Class '%classname' already exists.", false,
                                   array( '%classname' => $className ) );

            $choosenAction = $this->errorChoosenAction( self::ERROR_EXISTS,
                                                        $installParameters, $description, $this->HandlerType );
            switch( $choosenAction )
            {
            case eZPackage::NON_INTERACTIVE:
            case self::ACTION_REPLACE:
                if ( eZContentClassOperations::remove( $class->attribute( 'id' ) ) == false )
                {
                    eZDebug::writeWarning( "Unable to remove class '$className'." );
                    return true;
                }
                eZDebug::writeNotice( "Class '$className' will be replaced.", 'eZContentClassPackageHandler' );
                break;

            case self::ACTION_SKIP:
                return true;

            case self::ACTION_NEW:
                $class->setAttribute( 'remote_id', eZRemoteIdUtility::generate( 'class' ) );
                $class->store();
                $classNameList->appendGroupName( " (imported)" );
                break;

            default:
                $installParameters['error'] = array( 'error_code' => self::ERROR_EXISTS,
                                                     'element_id' => $classRemoteID,
                                                     'description' => $description,
                                                     'actions' => array() );
                if ( $class->isRemovable() )
                {
                    $errorMsg = ezpI18n::tr( 'kernel/package', "Replace existing class" );
                    $objectsCount = eZContentObject::fetchSameClassListCount( $class->attribute( 'id' ) );
                    if ( $objectsCount )
                        $errorMsg .= ' ' . ezpI18n::tr( 'kernel/package', "(Warning! $objectsCount content object(s) and their sub-items will be removed)" );
                    $installParameters['error']['actions'][self::ACTION_REPLACE] = $errorMsg;
                }
                $installParameters['error']['actions'][self::ACTION_SKIP] = ezpI18n::tr( 'kernel/package', 'Skip installing this class' );
                $installParameters['error']['actions'][self::ACTION_NEW] = ezpI18n::tr( 'kernel/package', 'Keep existing and create a new one' );
                return false;
            }
        }

        unset( $class );

        // Try to create a unique class identifier
        $currentClassIdentifier = $classIdentifier;
        $unique = false;

        while( !$unique )
        {
            $classList = eZContentClass::fetchByIdentifier( $currentClassIdentifier );
            if ( $classList )
            {
                // "increment" class identifier
                if ( preg_match( '/^(.*)_(\d+)$/', $currentClassIdentifier, $matches ) )
                    $currentClassIdentifier = $matches[1] . '_' . ( $matches[2] + 1 );
                else
                    $currentClassIdentifier = $currentClassIdentifier . '_1';
            }
            else
                $unique = true;

            unset( $classList );
        }

        $classIdentifier = $currentClassIdentifier;

        $values = array( 'version' => 0,
                         'serialized_name_list' => $classNameList->serializeNames(),
                         'serialized_description_list' => $classDescriptionList->serializeNames(),
                         'create_lang_if_not_exist' => true,
                         'identifier' => $classIdentifier,
                         'remote_id' => $classRemoteID,
                         'contentobject_name' => $classObjectNamePattern,
                         'url_alias_name' => $classURLAliasPattern,
                         'is_container' => $classIsContainer,
                         'created' => $classCreated,
                         'modified' => $classModified );

        if ( $content->hasAttribute( 'sort-field' ) )
        {
            $values['sort_field'] = eZContentObjectTreeNode::sortFieldID( $content->getAttribute( 'sort-field' ) );
        }
        else
        {
            eZDebug::writeNotice( 'The sort field was not specified in the content class package. ' .
                                  'This property is exported and imported since eZ Publish 4.0.2', __METHOD__ );
        }

        if ( $content->hasAttribute( 'sort-order' ) )
        {
            $values['sort_order'] = $content->getAttribute( 'sort-order' );
        }
        else
        {
            eZDebug::writeNotice( 'The sort order was not specified in the content class package. ' .
                                  'This property is exported and imported since eZ Publish 4.0.2', __METHOD__ );
        }

        if ( $content->hasAttribute( 'always-available' ) )
        {
            $values['always_available'] = ( $content->getAttribute( 'always-available' ) === 'true' ? 1 : 0 );
        }
        else
        {
            eZDebug::writeNotice( 'The default object availability was not specified in the content class package. ' .
                                  'This property is exported and imported since eZ Publish 4.0.2', __METHOD__ );
        }

        // create class
        $class = eZContentClass::create( $userID,
                                         $values );
        $class->store();

        $classID = $class->attribute( 'id' );

        if ( !isset( $installData['classid_list'] ) )
            $installData['classid_list'] = array();
        if ( !isset( $installData['classid_map'] ) )
            $installData['classid_map'] = array();
        $installData['classid_list'][] = $class->attribute( 'id' );
        $installData['classid_map'][$classID] = $class->attribute( 'id' );

        // create class attributes
        $classAttributeList = $classAttributesNode->getElementsByTagName( 'attribute' );
        foreach ( $classAttributeList as $classAttributeNode )
        {
            $isNotSupported = strtolower( $classAttributeNode->getAttribute( 'unsupported' ) ) == 'true';
            if ( $isNotSupported )
                continue;

            $attributeDatatype = $classAttributeNode->getAttribute( 'datatype' );
            $attributeIsRequired = strtolower( $classAttributeNode->getAttribute( 'required' ) ) == 'true';
            $attributeIsSearchable = strtolower( $classAttributeNode->getAttribute( 'searchable' ) ) == 'true';
            $attributeIsInformationCollector = strtolower( $classAttributeNode->getAttribute( 'information-collector' ) ) == 'true';
            $attributeIsTranslatable = strtolower( $classAttributeNode->getAttribute( 'translatable' ) ) == 'true';
            $attributeSerializedNameListNode = $classAttributeNode->getElementsByTagName( 'serialized-name-list' )->item( 0 );
            $attributeSerializedNameListContent = $attributeSerializedNameListNode ? $attributeSerializedNameListNode->textContent : false;
            $attributeSerializedNameList = new eZSerializedObjectNameList( $attributeSerializedNameListContent );
            if ( $attributeSerializedNameList->isEmpty() )
                $attributeSerializedNameList->initFromString( $classAttributeNode->getElementsByTagName( 'name' )->item( 0 )->textContent ); // for backward compatibility( <= 3.8 )
            $attributeSerializedNameList->validate( );

            $attributeSerializedDescriptionListNode = $classAttributeNode->getElementsByTagName( 'serialized-description-list' )->item( 0 );
            $attributeSerializedDescriptionListContent = $attributeSerializedDescriptionListNode ? $attributeSerializedDescriptionListNode->textContent : false;
            $attributeSerializedDescriptionList = new eZSerializedObjectNameList( $attributeSerializedDescriptionListContent );

            $attributeCategoryNode = $classAttributeNode->getElementsByTagName( 'category' )->item( 0 );
            $attributeCategory = $attributeCategoryNode ? $attributeCategoryNode->textContent : '';

            $attributeSerializedDataTextNode = $classAttributeNode->getElementsByTagName( 'serialized-description-text' )->item( 0 );
            $attributeSerializedDataTextContent = $attributeSerializedDataTextNode ? $attributeSerializedDataTextNode->textContent : false;
            $attributeSerializedDataText = new eZSerializedObjectNameList( $attributeSerializedDataTextContent );

            $attributeIdentifier = $classAttributeNode->getElementsByTagName( 'identifier' )->item( 0 )->textContent;
            $attributePlacement = $classAttributeNode->getElementsByTagName( 'placement' )->item( 0 )->textContent;
            $attributeDatatypeParameterNode = $classAttributeNode->getElementsByTagName( 'datatype-parameters' )->item( 0 );

            $classAttribute = $class->fetchAttributeByIdentifier( $attributeIdentifier );
            if ( !$classAttribute )
            {
                $classAttribute = eZContentClassAttribute::create( $class->attribute( 'id' ),
                                                                   $attributeDatatype,
                                                                   array( 'version' => 0,
                                                                          'identifier' => $attributeIdentifier,
                                                                          'serialized_name_list' => $attributeSerializedNameList->serializeNames(),
                                                                          'serialized_description_list' => $attributeSerializedDescriptionList->serializeNames(),
                                                                          'category' => $attributeCategory,
                                                                          'serialized_data_text' => $attributeSerializedDataText->serializeNames(),
                                                                          'is_required' => $attributeIsRequired,
                                                                          'is_searchable' => $attributeIsSearchable,
                                                                          'is_information_collector' => $attributeIsInformationCollector,
                                                                          'can_translate' => $attributeIsTranslatable,
                                                                          'placement' => $attributePlacement ) );

                $dataType = $classAttribute->dataType();
                $classAttribute->store();
                $dataType->unserializeContentClassAttribute( $classAttribute, $classAttributeNode, $attributeDatatypeParameterNode );
                $classAttribute->sync();
            }
        }

        // add class to a class group
        $classGroupsList = $classGroupsNode->getElementsByTagName( 'group' );
        foreach ( $classGroupsList as $classGroupNode )
        {
            $classGroupName = $classGroupNode->getAttribute( 'name' );
            $classGroup = eZContentClassGroup::fetchByName( $classGroupName );
            if ( !$classGroup )
            {
                $classGroup = eZContentClassGroup::create();
                $classGroup->setAttribute( 'name', $classGroupName );
                $classGroup->store();
            }
            $classGroup->appendClass( $class );
        }
        return true;
    }
1008512
protected function installRecipe(OutputInterface $output, $recipe, $constraint, $installedVersion)
    {
        if ($installedVersion) {
            if ($constraint) {
                $output->writeln(
                    "Updating existing recipe from <info>{$installedVersion}</info> to <info>{$constraint}</info>"
                );
            } else {
                // Show a guessed constraint
                $constraint = $this->findBestConstraint($installedVersion);
                if ($constraint) {
                    $output->writeln(
                        "Updating existing recipe from <info>{$installedVersion}</info> to <info>{$constraint}</info> "
                        . "(auto-detected constraint)"
                    );
                } else {
                    $output->writeln(
                        "Updating existing recipe from <info>{$installedVersion}</info> to latest version"
                    );
                }
            }
        }

        // Ensure composer require includes this recipe
        $returnCode = $this->requireRecipe($output, $recipe, $constraint);
        if ($returnCode) {
            return $returnCode;
        }

        // inline all dependencies inline into composer.json
        $this->modifyComposer(function ($composerData) use ($output, $recipe, $installedVersion) {
            // Check previously installed, and currently installed modules
            $require = isset($composerData['require']) ? $composerData['require'] : [];
            $previouslyInstalled = isset($composerData['extra'][RecipePlugin::PROJECT_DEPENDENCIES_INSTALLED])
                ? $composerData['extra'][RecipePlugin::PROJECT_DEPENDENCIES_INSTALLED]
                : [];

            // Get composer data for both root and newly installed recipe
            $installedRecipe = $this
                ->getComposer()
                ->getRepositoryManager()
                ->getLocalRepository()
                ->findPackage($recipe, '*');
            if ($installedRecipe) {
                $output->writeln("Inlining all dependencies for recipe <info>{$recipe}</info>:");
                foreach ($installedRecipe->getRequires() as $requireName => $requireConstraint) {
                    $requireVersion = $requireConstraint->getPrettyConstraint();

                    // If already installed, upgrade
                    if (isset($require[$requireName])) {
                        // Check if upgrade or not
                        $requireInstalledVersion = $require[$requireName];
                        if ($requireInstalledVersion === $requireVersion) {
                            // No need to upgrade
                            $output->writeln(
                                "  - Skipping <info>{$requireName}</info> "
                                . "(Already installed as <comment>{$requireVersion}</comment>)"
                            );
                        } else {
                            // Upgrade obsolete version
                            $output->writeln(
                                "  - Inlining <info>{$requireName}</info> "
                                . "(Updated to <comment>{$requireVersion}</comment> from "
                                . "<comment>{$requireInstalledVersion}</comment>)"
                            );
                            $require[$requireName] = $requireVersion;
                        }
                    } elseif (isset($previouslyInstalled[$requireName])) {
                        // Old module, manually removed
                        $output->writeln(
                            "  - Skipping <info>{$requireName}</info> (Manually removed from recipe)"
                        );
                    } else {
                        // New module
                        $output->writeln(
                            "  - Inlining <info>{$requireName}</info> (<comment>{$requireVersion}</comment>)"
                        );
                        $require[$requireName] = $requireVersion;
                    }

                    // note dependency as previously installed
                    $previouslyInstalled[$requireName] = $requireVersion;
                }
            }

            // Add new require / extra-installed
            $composerData['require'] = $require;
            if ($previouslyInstalled) {
                if (!isset($composerData['extra'])) {
                    $composerData['extra'] = [];
                }
                ksort($previouslyInstalled);
                $composerData['extra'][RecipePlugin::PROJECT_DEPENDENCIES_INSTALLED] = $previouslyInstalled;
            }

            // Move recipe from 'require' to 'provide'
            $installedVersion = $this->findInstalledVersion($recipe) ?: $installedVersion;
            unset($composerData['require'][$recipe]);
            if (!isset($composerData['provide'])) {
                $composerData['provide'] = [];
            }
            $composerData['provide'][$recipe] = $installedVersion;
            return $composerData;
        });

        // Update synchronise composer.lock
        return $this->updateProject($output);
    }
993617
private function handleDirectory(OutputInterface $output, $source)
	{
		$tmpDir  = $this->joomla->getCfg('tmp_path');
		$tmpPath = $tmpDir . '/' . uniqid('install_');
		$this->writeln($output, "Copying $source", OutputInterface::VERBOSITY_VERBOSE);

		mkdir($tmpPath);
		copy($source, $tmpPath);

		return $tmpPath;
	}
47247
function install(Connection $db, Logger $log) {
    // bail if we've already applied
    if ($this->isApplied($db)) {
      $log->info("Skipping " . $this->getName() . ": already applied");
      return;
    }

    // simply make sure all parent migrations are applied
    foreach ($this->getParents() as $migration) {
      $migration->install($db, $log);
    }

    // check we have a valid name
    if (strlen($this->getName()) == 0 || strlen($this->getName()) > 255) {
      throw new DbException("Invalid migration name '" . $this->getName() . "'");
    }

    // and then install our own
    try {
      $log->info("Applying " . $this->getName());
      if ($this->apply($db)) {
        $log->info("Applied migration " . $this->getName());
      } else {
        $log->error("Could not apply migration '" . $this->getName() . "': " . $db->lastError());
        throw new DbException("Could not apply migration " . $this->getName());
      }
    } catch (DbException $e) {
      $log->error("Could not apply migration '" . $this->getName() . "': " . $e->getMessage());
      throw new DbException("Could not apply migration " . $this->getName(), $e);
    }

    // save migration status
    $q = $db->prepare("INSERT INTO migrations SET name=?");
    $q->execute(array($this->getName()));
  }
641693
public function onInstallCommandCompletedOutputReport()
    {
        $report = new InstallReport($this->eventDataCollector, $this->dataCollectors);
        $report->generate($this->logger);
    }
172138
public function install(?string $database, $id = null): void
    {
        if (! \is_null($id)) {
            $this->executeFor($id, function ($entity) use ($database) {
                $this->runInstall($entity, $database);
            });

            return;
        }

        $this->executeForEach(function ($entity) use ($database) {
            $this->runInstall($entity, $database);
        });
    }
1254496
protected function _install($updateFile, $simulateInstall, $version)
    {
        $this->log->addNotice(sprintf('Trying to install update "%s"', $updateFile));

        // Check if install should be simulated
        if ($simulateInstall) {
            if ($this->_simulateInstall($updateFile)) {
                $this->log->addNotice(sprintf('Simulation of update "%s" process succeeded', $version));

                return true;
            }

            $this->log->addCritical(sprintf('Simulation of update  "%s" process failed!', $version));

            return self::ERROR_SIMULATE;
        }

        clearstatcache();

        // Install only if simulateInstall === false

        // Check if zip file could be opened
        $zip = zip_open($updateFile);
        if (!is_resource($zip)) {
            $this->log->addError(sprintf('Could not open zip file "%s", error: %d', $updateFile, $zip));

            return false;
        }

        // Read every file from archive
        while ($file = zip_read($zip)) {
            $filename = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, zip_entry_name($file));
            $foldername = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->installDir . dirname($filename));
            $absoluteFilename = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->installDir . $filename);
            $this->log->addDebug(sprintf('Updating file "%s"', $filename));

            if (!is_dir($foldername)) {
                if (!mkdir($foldername, $this->dirPermissions, true)) {
                    $this->log->addError(sprintf('Directory "%s" has to be writeable!', $foldername));

                    return false;
                }
            }

            // Skip if entry is a directory
            if (substr($filename, -1, 1) == DIRECTORY_SEPARATOR) {
                continue;
            }

            // Read file contents from archive
            $contents = zip_entry_read($file, zip_entry_filesize($file));

            if ($contents === false) {
                $this->log->addError(sprintf('Coud not read zip entry "%s"', $file));
                continue;
            }

            // Write to file
            if (file_exists($absoluteFilename)) {
                if (!is_writable($absoluteFilename)) {
                    $this->log->addError(sprintf('Could not overwrite "%s"!', $absoluteFilename));

                    zip_close($zip);

                    return false;
                }
            } else {
                // touch will fail if PHP is not the owner of the file, and file_put_contents is faster than touch.
                if (file_put_contents($absoluteFilename, '') === false) {
                    $this->log->addError(sprintf('The file "%s" could not be created!', $absoluteFilename));
                    zip_close($zip);

                    return false;
                }

                $this->log->addDebug(sprintf('File "%s" created', $absoluteFilename));
            }

            $updateHandle = fopen($absoluteFilename, 'w');

            if (!$updateHandle) {
                $this->log->addError(sprintf('Could not open file "%s"!', $absoluteFilename));
                zip_close($zip);

                return false;
            }


            if (false === fwrite($updateHandle, $contents)) {
                $this->log->addError(sprintf('Could not write to file "%s"!', $absoluteFilename));
                zip_close($zip);
                return false;
            }

            fclose($updateHandle);

            //If file is a update script, include
            if ($filename == $this->updateScriptName) {
                $this->log->addDebug(sprintf('Try to include update script "%s"', $absoluteFilename));
                require($absoluteFilename);

                $this->log->addInfo(sprintf('Update script "%s" included!', $absoluteFilename));
                if (!unlink($absoluteFilename)) {
                    $this->log->addWarning(sprintf('Could not delete update script "%s"!', $absoluteFilename));
                }
            }
        }

        zip_close($zip);

        $this->log->addNotice(sprintf('Update "%s" successfully installed', $version));

        return true;
    }
767657
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->stdOut->writeln("<info>Syncing Platform.sh environment database to local</info>");

        /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
        $process = $this->getHelper('process');

        // If this is a Platform.sh project, get latest dump.
        // @todo: add proper provider integration
        if (Config::get('id')) {
            $process->mustRun($this->stdOut, [
              'platform',
              'sql-dump',
            ]);
        }

        $cd = getcwd();
        chdir(Platform::webDir());
        $process->run($this->stdOut, 'drush sqlc < ' . $input->getArgument('file'));
        chdir($cd);
    }
297988
private function createNotifier(InputInterface $input, OutputInterface $output)
    {
        $clear = $this->createProgressBar($output);
        $download = $this->createProgressBar($output);
        $extract = $this->createProgressBar($output);

        return function ($type, $data) use ($input, $output, $clear, $download, $extract) {
            switch ($type) {
                case CKEditorInstaller::NOTIFY_CLEAR:
                    $result = $this->choice(
                        [
                            sprintf('CKEditor is already installed in "%s"...', $data),
                            '',
                            'What do you want to do?',
                        ],
                        $choices = [
                            CKEditorInstaller::CLEAR_DROP => 'Drop the directory & reinstall CKEditor',
                            CKEditorInstaller::CLEAR_KEEP => 'Keep the directory & reinstall CKEditor by overriding files',
                            CKEditorInstaller::CLEAR_SKIP => 'Skip installation',
                        ],
                        CKEditorInstaller::CLEAR_DROP,
                        $input,
                        $output
                    );

                    if (($key = array_search($result, $choices, true)) !== false) {
                        $result = $key;
                    }

                    if ($result === CKEditorInstaller::CLEAR_DROP) {
                        $this->comment(sprintf('Dropping CKEditor from "%s"', $data), $output);
                    }

                    return $result;

                case CKEditorInstaller::NOTIFY_CLEAR_ARCHIVE:
                    $this->comment(sprintf('Dropping CKEditor ZIP archive "%s"', $data), $output);
                    break;

                case CKEditorInstaller::NOTIFY_CLEAR_COMPLETE:
                    $this->finishProgressBar($clear, $output);
                    break;

                case CKEditorInstaller::NOTIFY_CLEAR_PROGRESS:
                    $clear->advance();
                    break;

                case CKEditorInstaller::NOTIFY_CLEAR_SIZE:
                    $this->startProgressBar($clear, $output, $data);
                    break;

                case CKEditorInstaller::NOTIFY_DOWNLOAD:
                    $this->comment(sprintf('Downloading CKEditor ZIP archive from "%s"', $data), $output);
                    break;

                case CKEditorInstaller::NOTIFY_DOWNLOAD_COMPLETE:
                    $this->finishProgressBar($download, $output);
                    break;

                case CKEditorInstaller::NOTIFY_DOWNLOAD_PROGRESS:
                    $this->advanceProgressBar($download, $data);
                    break;

                case CKEditorInstaller::NOTIFY_DOWNLOAD_SIZE:
                    $this->startProgressBar($download, $output, $data);
                    break;

                case CKEditorInstaller::NOTIFY_EXTRACT:
                    $this->comment(sprintf('Extracting CKEditor ZIP archive to "%s"', $data), $output);
                    break;

                case CKEditorInstaller::NOTIFY_EXTRACT_COMPLETE:
                    $this->finishProgressBar($extract, $output);
                    break;

                case CKEditorInstaller::NOTIFY_EXTRACT_PROGRESS:
                    $extract->advance();
                    break;

                case CKEditorInstaller::NOTIFY_EXTRACT_SIZE:
                    $this->startProgressBar($extract, $output, $data);
                    break;
            }
        };
    }
153514
public static function copyInstall($source_path, $install_path)
    {
        if (empty($source_path)) {
            throw new \RuntimeException("Directory $source_path is missing");
        }

        Folder::rcopy($source_path, $install_path);

        return true;
    }
428438
public function setInstallInfos(array $installInfos)
    {
        $this->installInfos = array();

        foreach ($installInfos as $installInfo) {
            $this->addInstallInfo($installInfo);
        }
    }
765550
public function execute(InputInterface $input, OutputInterface $output)
    {
        $dropTables = $input->getOption('drop-tables');

        if (! $this->hasTablesOrViews() || $dropTables) {
            if ($dropTables && $this->appEnv === 'production') {
                $output->writeln('Cannot drop tables when app environment is production.');
                return;
            }

            // Console message heading padded by a newline
            $output->write(['', '  -- APP INSTALL --', ''], true);

            $output->write(['  Dropping tables', ''], true);
            $this->dropViews();
            $this->dropTables();

            try {
                $installScript = $this->getInstallScript();
            } catch (RuntimeException $e) {
                $output->writeln($e->getMessage());
                return;
            }

            $this->install(
                $installScript,
                $output
            );
        }

        // Run all migrations
        $output->writeln('  Executing new migrations');
        $this->runMigrationsCommand->run(new ArrayInput(['migrations:run']), $output);

        $output->write(['  Done!', ''], true);
    }