protected function install(UpdateInfo $info, UpdateFile $file)
{
if (!$file->hashMatches($info->getChecksum())) {
throw new CouldNotUpdate(\__('Checksum mismatched'));
}
// Let's open the update package:
$path = $file->getPath();
$updater = new \Phar($path, \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_FILENAME);
$updater->setAlias($this->pharAlias);
$metadata = $updater->getMetadata();
// We need to do this while we're replacing files.
$this->bringSiteDown();
if (isset($metadata['files'])) {
foreach ($metadata['files'] as $fileName) {
$this->replaceFile($fileName);
}
}
if (isset($metadata['autoRun'])) {
foreach ($metadata['autoRun'] as $autoRun) {
$this->autoRunScript($autoRun);
}
}
// If we included composer.lock, we need to install the dependencies.
if (\in_array('composer.lock', $metadata['files'])) {
$composers = ['/usr/bin/composer', '/usr/bin/composer.phar', \dirname(ROOT) . '/composer', \dirname(ROOT) . '/composer.phar'];
$composerUpdated = false;
foreach ($composers as $composer) {
if (\file_exists($composer)) {
$dir = \getcwd();
\chdir(\dirname(ROOT));
\shell_exec("{$composer} install");
\chdir($dir);
$composerUpdated = true;
break;
}
}
if (!$composerUpdated) {
self::$continuumLogger->store(LogLevel::INFO, 'Could not update dependencies. Please run Composer manually.', $this->getLogContext($info, $file));
}
}
// Free up the updater alias
$garbageAlias = Base64UrlSafe::encode(\random_bytes(63)) . '.phar';
$updater->setAlias($garbageAlias);
unset($updater);
// Now bring it back up.
$this->bringSiteBackUp();
self::$continuumLogger->store(LogLevel::INFO, 'CMS Airship core update installed', $this->getLogContext($info, $file));
}