/** * @override \ComponentManager\PackageSource\PackageSource */ public function obtainPackage($tempDirectory, ResolvedComponentVersion $resolvedComponentVersion, Filesystem $filesystem, LoggerInterface $logger) { $version = $resolvedComponentVersion->getVersion(); $sources = $version->getSources(); foreach ($sources as $source) { if ($source instanceof DirectoryComponentSource) { return $source->getDirectory(); } else { $logger->debug('Cannot accept component source; skipping', ['componentSource' => $source]); } } throw new InstallationFailureException('No directory component sources found', InstallationFailureException::CODE_SOURCE_UNAVAILABLE); }
/** * @override \ComponentManager\PackageSource\PackageSource */ public function obtainPackage($tempDirectory, ResolvedComponentVersion $resolvedComponentVersion, Filesystem $filesystem, LoggerInterface $logger) { $componentVersion = $resolvedComponentVersion->getVersion(); $sources = $componentVersion->getSources(); foreach ($sources as $source) { if ($source instanceof GitComponentSource) { $repositoryPath = $this->platform->joinPaths([$tempDirectory, 'repo']); $indexPath = $this->platform->joinPaths([$tempDirectory, 'index']); $repositoryUri = $source->getRepositoryUri(); $finalRef = $resolvedComponentVersion->getFinalVersion(); $ref = $source->getRef(); if ($finalRef !== null) { $logger->info('Installing pinned version', ['ref' => $ref, 'finalRef' => $finalRef]); $installRef = $finalRef; } else { $installRef = $ref; } // These paths must be removed in the event of a failure/retry $paths = [$repositoryPath, $indexPath]; $filesystem->mkdir($paths); $logger->debug('Trying git repository source', ['repositoryPath' => $repositoryPath, 'repositoryUri' => $repositoryUri, 'ref' => $installRef, 'indexPath' => $indexPath]); try { $repository = new GitVersionControl($this->platform->getExecutablePath('git'), $repositoryPath); $repository->init(); $repository->addRemote(new GitRemote('origin', $repositoryUri)); $repository->fetch('origin'); $repository->checkout($installRef); $repository->checkoutIndex($indexPath . $this->platform->getDirectorySeparator()); $resolvedComponentVersion->setFinalVersion($repository->parseRevision($installRef)); return $indexPath; } catch (VersionControlException $e) { $logger->debug('Version control failed; skipping', ['code' => $e->getCode(), 'message' => $e->getMessage()]); $filesystem->remove($paths); } } else { $logger->debug('Cannot accept component source; skipping', ['componentSource' => $source]); } } }
/** * @override \ComponentManager\PackageSource\PackageSource */ public function obtainPackage($tempDirectory, ResolvedComponentVersion $resolvedComponentVersion, Filesystem $filesystem, LoggerInterface $logger) { $component = $resolvedComponentVersion->getComponent(); $version = $resolvedComponentVersion->getVersion(); $sources = $version->getSources(); $finalVersion = $resolvedComponentVersion->getFinalVersion(); if ($finalVersion !== null) { $source = new ZipComponentSource($finalVersion->archiveUri, $finalVersion->md5Checksum); $logger->info('Installing pinned version', ['archiveUri' => $finalVersion->archiveUri, 'md5Checksum' => $finalVersion->md5Checksum]); return $this->trySource($tempDirectory, $logger, $component, $version, $source); } else { foreach ($sources as $source) { if ($source instanceof ZipComponentSource) { $moduleRootDirectory = $this->trySource($tempDirectory, $logger, $component, $version, $source); $resolvedComponentVersion->setFinalVersion((object) ['archiveUri' => $source->getArchiveUri(), 'md5Checksum' => $source->getMd5Checksum()]); return $moduleRootDirectory; } else { $logger->debug('Cannot accept component source; skipping', ['componentSource' => $source]); } } } throw new InstallationFailureException('No zip component sources found', InstallationFailureException::CODE_SOURCE_UNAVAILABLE); }