Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     if (null === self::$hasSystemUnzip) {
         $finder = new ExecutableFinder();
         self::$hasSystemUnzip = (bool) $finder->find('unzip');
     }
     if (!class_exists('ZipArchive') && !self::$hasSystemUnzip) {
         throw new \RuntimeException('The zip extension and unzip command are both missing, skipping');
     }
     return parent::download($package, $path);
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     if (null === self::$hasSystemUnzip) {
         $finder = new ExecutableFinder();
         self::$hasSystemUnzip = (bool) $finder->find('unzip');
     }
     if (!class_exists('ZipArchive') && !self::$hasSystemUnzip) {
         // php.ini path is added to the error message to help users find the correct file
         $iniMessage = IniHelper::getMessage();
         $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
         throw new \RuntimeException($error);
     }
     return parent::download($package, $path);
 }
 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('');
 }
Пример #4
0
 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     if (null === self::$hasSystemUnzip) {
         $finder = new ExecutableFinder();
         self::$hasSystemUnzip = (bool) $finder->find('unzip');
     }
     if (!class_exists('ZipArchive') && !self::$hasSystemUnzip) {
         // php.ini path is added to the error message to help users find the correct file
         $iniPath = php_ini_loaded_file();
         if ($iniPath) {
             $iniMessage = 'The php.ini used by your command-line PHP is: ' . $iniPath;
         } else {
             $iniMessage = 'A php.ini file does not exist. You will have to create one.';
         }
         $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
         throw new \RuntimeException($error);
     }
     return parent::download($package, $path);
 }
Пример #5
0
 public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, ProcessExecutor $process = null)
 {
     $this->process = $process ?: new ProcessExecutor($io);
     parent::__construct($io, $config, $eventDispatcher, $cache);
 }
Пример #6
0
 public function __construct(IOInterface $io, ProcessExecutor $process = null)
 {
     $this->process = $process ?: new ProcessExecutor();
     parent::__construct($io);
 }
 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     // set package so we can use it in the extract method
     $this->package = $package;
     parent::download($package, $path);
 }