Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     if (!$package->getDistUrl()) {
         throw new \InvalidArgumentException('The given package is missing url information');
     }
     $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
     $urls = $package->getDistUrls();
     while ($url = array_shift($urls)) {
         try {
             return $this->doDownload($package, $path, $url);
         } catch (\Exception $e) {
             if ($this->io->isDebug()) {
                 $this->io->writeError('');
                 $this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getCode() . ': ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('');
                 $this->io->writeError('    Failed, trying the next URL (' . $e->getCode() . ': ' . $e->getMessage() . ')');
             }
             if (!count($urls)) {
                 throw $e;
             }
         }
     }
     $this->io->writeError('');
 }
 public function download(PackageInterface $package, $path)
 {
     $temporaryDir = $this->config->get('vendor-dir') . '/composer/' . substr(md5(uniqid('', true)), 0, 8);
     $this->filesystem->ensureDirectoryExists($temporaryDir);
     // START: from FileDownloader::download()
     if (!$package->getDistUrl()) {
         throw new \InvalidArgumentException('The given package is missing url information');
     }
     $this->io->writeError("  - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
     $urls = $package->getDistUrls();
     while ($url = array_shift($urls)) {
         try {
             $fileName = $this->doDownload($package, $temporaryDir, $url);
         } catch (\Exception $e) {
             if ($this->io->isDebug()) {
                 $this->io->writeError('');
                 $this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getCode() . ': ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('');
                 $this->io->writeError('    Failed, trying the next URL (' . $e->getCode() . ': ' . $e->getMessage() . ')');
             }
             if (!count($urls)) {
                 throw $e;
             }
         }
     }
     // END: from FileDownloader::download()
     if ($this->io->isVerbose()) {
         $this->io->writeError('    Extracting archive');
     }
     try {
         $this->extract($fileName, $path);
     } catch (\Exception $e) {
         // remove cache if the file was corrupted
         parent::clearCache($package, $path);
         throw $e;
     }
     $this->filesystem->unlink($fileName);
     if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir') . '/composer/')) {
         $this->filesystem->removeDirectory($this->config->get('vendor-dir') . '/composer/');
     }
     if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir'))) {
         $this->filesystem->removeDirectory($this->config->get('vendor-dir'));
     }
     $this->io->writeError('');
 }
Exemplo n.º 3
0
 protected function configurePackageTransportOptions(PackageInterface $package)
 {
     foreach ($package->getDistUrls() as $url) {
         if (strpos($url, $this->baseUrl) === 0) {
             $package->setTransportOptions($this->options);
             return;
         }
     }
 }
Exemplo n.º 4
0
 private static function getUrlFromPackage(Package\PackageInterface $package)
 {
     $url = $package->getDistUrl();
     if (!$url) {
         return false;
     }
     if ($package->getDistMirrors()) {
         $url = current($package->getDistUrls());
     }
     if (!parse_url($url, PHP_URL_HOST)) {
         return false;
     }
     return $url;
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function getDistUrls()
 {
     return $this->package->getDistUrls();
 }
Exemplo n.º 6
0
 public function getDistUrls()
 {
     return $this->aliasOf->getDistUrls();
 }