Beispiel #1
0
 /**
  * Synchronize packages installed earlier (by pear installer) with local cache
  *
  * @param string $command
  * @param array $options
  * @param array $params
  * @return array|true
  */
 public function doSyncPear($command, $options, $params)
 {
     $this->cleanupParams($params);
     try {
         $packager = $this->getPackager();
         $cache = null;
         $config = null;
         $ftpObj = null;
         $ftp = empty($options['ftp']) ? false : $options['ftp'];
         if ($ftp) {
             list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
         } else {
             $config = $this->config();
             $cache = $this->getSconfig();
         }
         $pkglist = array();
         if (!$this->_checkPearData($config)) {
             return $pkglist;
         }
         $pearStorage = $config->magento_root . '/' . $config->downloader_path . '/' . self::PACKAGE_PEAR_DIR;
         $channels = array('.channel.connect.magentocommerce.com_community', '.channel.connect.magentocommerce.com_core');
         foreach ($channels as $channel) {
             $channelDirectory = $pearStorage . '/' . $channel;
             if (!file_exists($channelDirectory) || !is_dir($channelDirectory)) {
                 continue;
             }
             $dp = opendir($channelDirectory);
             if (!$dp) {
                 continue;
             }
             while ($ent = readdir($dp)) {
                 if ($ent[0] == '.' || substr($ent, -4) != '.reg') {
                     continue;
                 }
                 $pkglist[] = array('file' => $ent, 'channel' => $channel);
             }
             closedir($dp);
         }
         $package = new \Magento\Framework\Connect\Package();
         foreach ($pkglist as $pkg) {
             $pkgFilename = $pearStorage . '/' . $pkg['channel'] . '/' . $pkg['file'];
             if (!file_exists($pkgFilename)) {
                 continue;
             }
             $data = file_get_contents($pkgFilename);
             $data = unserialize($data);
             $package->importDataV1x($data);
             $name = $package->getName();
             $channel = $package->getChannel();
             $version = $package->getVersion();
             if (!$cache->isChannel($channel) && $channel == $config->root_channel) {
                 $cache->addChannel($channel, $config->root_channel_uri);
             }
             if (!$cache->hasPackage($channel, $name, $version, $version)) {
                 $cache->addPackage($package);
                 if ($ftp) {
                     $localXml = tempnam(sys_get_temp_dir(), 'package');
                     @file_put_contents($localXml, $package->getPackageXml());
                     if (is_file($localXml)) {
                         $ftpDir = $ftpObj->getcwd();
                         $remoteXmlPath = $ftpDir . '/' . \Magento\Framework\Connect\Package::PACKAGE_XML_DIR;
                         $remoteXml = $package->getReleaseFilename() . '.xml';
                         $ftpObj->mkdirRecursive($remoteXmlPath);
                         $ftpObj->upload($remoteXml, $localXml, 0777, 0666);
                         $ftpObj->chdir($ftpDir);
                     }
                 } else {
                     $destDir = rtrim($config->magento_root, "\\/") . '/' . \Magento\Framework\Connect\Package::PACKAGE_XML_DIR;
                     $destFile = $package->getReleaseFilename() . '.xml';
                     $dest = $destDir . '/' . $destFile;
                     @mkdir($destDir, 0777, true);
                     @file_put_contents($dest, $package->getPackageXml());
                     @chmod($dest, 0666);
                 }
                 $this->ui()->output("Successfully added: {$channel}/{$name}-{$version}");
             }
         }
         $config->sync_pear = true;
         if ($ftp) {
             $packager->writeToRemoteCache($cache, $ftpObj);
             @unlink($config->getFilename());
         }
     } catch (\Exception $e) {
         $this->doError($command, $e->getMessage());
     }
     return true;
 }
Beispiel #2
0
 /**
  * Install action callback
  *
  * @throws \Exception
  * @param string $command
  * @param array $options
  * @param array $params
  * @param array $objects
  * @return array|null
  */
 public function doInstall($command, $options, $params, $objects = array())
 {
     $this->cleanupParams($params);
     $installFileMode = $command === 'install-file';
     /** @var $ftpObj \Magento\Framework\Connect\Ftp */
     $ftpObj = null;
     $ftp = empty($options['ftp']) ? false : $options['ftp'];
     /** @var $packager \Magento\Framework\Connect\Packager */
     $packager = $this->getPackager();
     /** @var $cache \Magento\Framework\Connect\Singleconfig */
     /** @var $config \Magento\Framework\Connect\Config */
     if ($ftp) {
         list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
     } else {
         $cache = $this->getSconfig();
         $config = $this->config();
     }
     try {
         $forceMode = isset($options['force']);
         $upgradeAllMode = $command == 'upgrade-all';
         $upgradeMode = $command == 'upgrade' || $command == 'upgrade-all';
         $noFilesInstall = isset($options['nofiles']);
         $withDepsMode = !isset($options['nodeps']);
         $ignoreModifiedMode = true || !isset($options['ignorelocalmodification']);
         $clearInstallMode = $command == 'install' && !$forceMode;
         $installAll = isset($options['install_all']);
         $channelAuth = isset($options['auth']) ? $options['auth'] : array();
         $rest = $this->rest();
         if (empty($config->magento_root)) {
             $config->magento_root = dirname(dirname($_SERVER['SCRIPT_FILENAME']));
         }
         chdir($config->magento_root);
         $dirCache = '/' . $config->downloader_path . '/' . \Magento\Framework\Connect\Config::DEFAULT_CACHE_PATH;
         $dirTmp = '/' . \Magento\Framework\Connect\Package\Reader::PATH_TO_TEMPORARY_DIRECTORY;
         $dirMedia = '/media';
         $isWritable = true;
         if ($ftp) {
             $cwd = $ftpObj->getcwd();
             $ftpObj->mkdirRecursive($cwd . $dirCache, 0777);
             $ftpObj->chdir($cwd);
             $ftpObj->mkdirRecursive($cwd . $dirTmp, 0777);
             $ftpObj->chdir($cwd);
             $ftpObj->mkdirRecursive($cwd . $dirMedia, 0777);
             $ftpObj->chdir($cwd);
             $err = "Please check for sufficient ftp write file permissions.";
         } else {
             @mkdir($config->magento_root . $dirCache, 0777, true);
             @mkdir($config->magento_root . $dirTmp, 0777, true);
             @mkdir($config->magento_root . $dirMedia, 0777, true);
             $isWritable = is_writable($config->magento_root) && is_writable($config->magento_root . '/' . $config->downloader_path) && is_writable($config->magento_root . $dirCache) && is_writable($config->magento_root . $dirTmp) && is_writable($config->magento_root . $dirMedia);
             $err = "Please check for sufficient write file permissions.";
         }
         $isWritable = $isWritable && is_writable($config->magento_root . $dirMedia) && is_writable($config->magento_root . $dirCache) && is_writable($config->magento_root . $dirTmp);
         if (!$isWritable) {
             $this->doError($command, $err);
             throw new \Exception('Your Magento folder does not have sufficient write permissions, which downloader requires.');
         }
         if (!empty($channelAuth)) {
             $rest->getLoader()->setCredentials($channelAuth['username'], $channelAuth['password']);
         }
         if ($installFileMode) {
             if (count($params) < 1) {
                 throw new \Exception("Argument should be: filename");
             }
             $filename = $params[0];
             if (!@file_exists($filename)) {
                 throw new \Exception("File '{$filename}' not found");
             }
             if (!@is_readable($filename)) {
                 throw new \Exception("File '{$filename}' is not readable");
             }
             $package = new \Magento\Framework\Connect\Package($filename);
             $package->setConfig($config);
             $package->validate();
             $errors = $package->getErrors();
             if (count($errors)) {
                 throw new \Exception("Package file is invalid\n" . implode("\n", $errors));
             }
             $pChan = $package->getChannel();
             $pName = $package->getName();
             $pVer = $package->getVersion();
             if (!($cache->isChannelName($pChan) || $cache->isChannelAlias($pChan))) {
                 throw new \Exception("The '{$pChan}' channel is not installed. Please use the MAGE shell " . "script to install the '{$pChan}' channel.");
             }
             $conflicts = $cache->hasConflicts($pChan, $pName, $pVer);
             if (false !== $conflicts) {
                 $conflicts = implode(", ", $conflicts);
                 if ($forceMode) {
                     $this->doError($command, "Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
                 } else {
                     throw new \Exception("Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
                 }
             }
             $conflicts = $package->checkPhpDependencies();
             if (true !== $conflicts) {
                 $conflicts = implode(",", $conflicts);
                 $err = "Package {$pChan}/{$pName} {$pVer} depends on PHP extensions: " . $conflicts;
                 if ($forceMode) {
                     $this->doError($command, $err);
                 } else {
                     throw new \Exception($err);
                 }
             }
             $conflicts = $package->checkPhpVersion();
             if (true !== $conflicts) {
                 $err = "Package {$pChan}/{$pName} {$pVer}: " . $conflicts;
                 if ($forceMode) {
                     $this->doError($command, $err);
                 } else {
                     throw new \Exception($err);
                 }
             }
             if (!$noFilesInstall) {
                 if ($ftp) {
                     $packager->processInstallPackageFtp($package, $filename, $config, $ftpObj);
                 } else {
                     $packager->processInstallPackage($package, $filename, $config);
                 }
             }
             $cache->addPackage($package);
             $installedDeps = array();
             $installedDepsAssoc = array();
             $installedDepsAssoc[] = array('channel' => $pChan, 'name' => $pName, 'version' => $pVer);
             $installedDeps[] = array($pChan, $pName, $pVer);
             $title = isset($options['title']) ? $options['title'] : "Package installed: ";
             $out = array($command => array('data' => $installedDeps, 'assoc' => $installedDepsAssoc, 'title' => $title));
             if ($ftp) {
                 $packager->writeToRemoteCache($cache, $ftpObj);
                 @unlink($config->getFilename());
             }
             $this->ui()->output($out);
             return $out[$command]['data'];
         }
         if (!$upgradeAllMode) {
             if (count($params) < 2) {
                 throw new \Exception("Argument should be: channelName packageName");
             }
             $channel = $params[0];
             $package = $params[1];
             $argVersionMax = isset($params[2]) ? $params[2] : false;
             $argVersionMin = isset($params[3]) ? $params[3] : false;
             $cache->checkChannel($channel, $config, $rest);
             $channelName = $cache->chanName($channel);
             $this->ui()->output("Checking dependencies of packages");
             $packagesToInstall = $packager->getDependenciesList($channelName, $package, $cache, $config, $argVersionMax, $argVersionMin, $withDepsMode, false, $rest);
             /*
              * process 'failed' results
              */
             if (count($packagesToInstall['failed'])) {
                 $showError = !count($packagesToInstall['result']);
                 foreach ($packagesToInstall['failed'] as $failed) {
                     $msg = "Package {$failed['channel']}/{$failed['name']} failed: " . $failed['reason'];
                     if ($showError) {
                         $this->doError($command, $msg);
                     } else {
                         $this->ui()->output($msg);
                     }
                 }
             }
             $packagesToInstall = $packagesToInstall['result'];
         } else {
             if (empty($params[0])) {
                 $channels = $cache->getChannelNames();
             } else {
                 $channel = $params[0];
                 if (!$cache->isChannel($channel)) {
                     throw new \Exception("'{$channel}' is not existant channel name / valid uri");
                 }
                 $channels = $cache->chanName($channel);
             }
             $packagesToInstall = array();
             $neededToUpgrade = $packager->getUpgradesList($channels, $cache, $config, $rest);
             foreach ($neededToUpgrade as $chan => $packages) {
                 foreach ($packages as $name => $data) {
                     $versionTo = $data['to'];
                     $tmp = $packager->getDependenciesList($chan, $name, $cache, $config, $versionTo, $versionTo, $withDepsMode, false, $rest);
                     if (count($tmp['result'])) {
                         $packagesToInstall = array_merge($packagesToInstall, $tmp['result']);
                     }
                 }
             }
         }
         /**
          * Make installation
          */
         $installedDeps = array();
         $installedDepsAssoc = array();
         foreach ($packagesToInstall as $package) {
             try {
                 $pName = $package['name'];
                 $pChan = $package['channel'];
                 $pVer = $package['downloaded_version'];
                 $pInstallState = $package['install_state'];
                 $rest->setChannel($cache->chanUrl($pChan));
                 /**
                  * Skip existing packages
                  */
                 if ($upgradeMode && $cache->hasPackage($pChan, $pName, $pVer, $pVer) || 'already_installed' == $pInstallState && !$forceMode) {
                     $this->ui()->output("Already installed: {$pChan}/{$pName} {$pVer}, skipping");
                     continue;
                 }
                 if ('incompartible' == $pInstallState) {
                     $this->ui()->output("Package incompartible with installed Magento: {$pChan}/{$pName} {$pVer}, skipping");
                     continue;
                 }
                 $conflicts = $cache->hasConflicts($pChan, $pName, $pVer);
                 if (false !== $conflicts) {
                     $conflicts = implode(", ", $conflicts);
                     if ($forceMode) {
                         $this->doError($command, "Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
                     } else {
                         throw new \Exception("Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
                     }
                 }
                 /**
                  * Modifications
                  */
                 if (($upgradeMode || $pInstallState == 'upgrade') && !$ignoreModifiedMode) {
                     if ($ftp) {
                         $modifications = $packager->getRemoteModifiedFiles($pChan, $pName, $cache, $config, $ftp);
                     } else {
                         $modifications = $packager->getLocalModifiedFiles($pChan, $pName, $cache, $config);
                     }
                     if (count($modifications) > 0) {
                         $this->ui()->output('Changed locally: ');
                         foreach ($modifications as $row) {
                             if (!$ftp) {
                                 $this->ui()->output($config->magento_root . '/' . $row);
                             } else {
                                 $this->ui()->output($row);
                             }
                         }
                     }
                 }
                 if ($ftp) {
                     $cwd = $ftpObj->getcwd();
                     $dir = $cwd . '/' . $config->downloader_path . '/' . \Magento\Framework\Connect\Config::DEFAULT_CACHE_PATH . '/' . trim($pChan, "\\/");
                     $ftpObj->mkdirRecursive($dir, 0777);
                     $ftpObj->chdir($cwd);
                 } else {
                     $dir = $config->getChannelCacheDir($pChan);
                     @mkdir($dir, 0777, true);
                 }
                 $dir = $config->getChannelCacheDir($pChan);
                 $packageFileName = $pName . "-" . $pVer . ".tgz";
                 $file = $dir . '/' . $packageFileName;
                 if (!@file_exists($file)) {
                     $this->ui()->output("Starting to download {$packageFileName} ...");
                     $rest->downloadPackageFileOfRelease($pName, $pVer, $file);
                     $this->ui()->output(sprintf("...done: %s bytes", number_format(filesize($file))));
                 }
                 /**
                  * Remove old version package before install new
                  */
                 if ($cache->hasPackage($pChan, $pName)) {
                     if ($ftp) {
                         $packager->processUninstallPackageFtp($pChan, $pName, $cache, $ftpObj);
                     } else {
                         $packager->processUninstallPackage($pChan, $pName, $cache, $config);
                     }
                     $cache->deletePackage($pChan, $pName);
                 }
                 $package = new \Magento\Framework\Connect\Package($file);
                 if ($clearInstallMode && $pInstallState != 'upgrade' && !$installAll) {
                     $this->validator()->validateContents($package->getContents(), $config);
                     $errors = $this->validator()->getErrors();
                     if (count($errors)) {
                         throw new \Exception("Package '{$pName}' is invalid\n" . implode("\n", $errors));
                     }
                 }
                 $conflicts = $package->checkPhpDependencies();
                 if (true !== $conflicts) {
                     $conflicts = implode(",", $conflicts);
                     $err = "Package {$pChan}/{$pName} {$pVer} depends on PHP extensions: " . $conflicts;
                     if ($forceMode) {
                         $this->doError($command, $err);
                     } else {
                         throw new \Exception($err);
                     }
                 }
                 $conflicts = $package->checkPhpVersion();
                 if (true !== $conflicts) {
                     $err = "Package {$pChan}/{$pName} {$pVer}: " . $conflicts;
                     if ($forceMode) {
                         $this->doError($command, $err);
                     } else {
                         throw new \Exception($err);
                     }
                 }
                 if (!$noFilesInstall) {
                     $this->ui()->output("Installing package {$pChan}/{$pName} {$pVer}");
                     if ($ftp) {
                         $packager->processInstallPackageFtp($package, $file, $config, $ftpObj);
                     } else {
                         $packager->processInstallPackage($package, $file, $config);
                     }
                     $this->ui()->output("Package {$pChan}/{$pName} {$pVer} installed successfully");
                 }
                 $cache->addPackage($package);
                 $installedDepsAssoc[] = array('channel' => $pChan, 'name' => $pName, 'version' => $pVer);
                 $installedDeps[] = array($pChan, $pName, $pVer);
             } catch (\Exception $e) {
                 $this->doError($command, $e->getMessage());
             }
         }
         $title = isset($options['title']) ? $options['title'] : "Package installed: ";
         $out = array($command => array('data' => $installedDeps, 'assoc' => $installedDepsAssoc, 'title' => $title));
         if ($ftp) {
             $packager->writeToRemoteCache($cache, $ftpObj);
             @unlink($config->getFilename());
         }
         $this->ui()->output($out);
         return $out[$command]['data'];
     } catch (\Exception $e) {
         if ($ftp) {
             $packager->writeToRemoteCache($cache, $ftpObj);
             @unlink($config->getFilename());
         }
         return $this->doError($command, $e->getMessage());
     }
 }
Beispiel #3
0
 /**
  * Install action callback
  *
  * @param string $command
  * @param array $options
  * @param string[] $params
  * @param array $objects
  * @return array
  */
 public function doInstall($command, $options, $params, $objects = array())
 {
     $this->cleanupParams($params);
     $installFileMode = $command === 'install-file';
     try {
         $packager = $this->getPackager();
         $forceMode = isset($options['force']);
         $upgradeAllMode = $command == 'upgrade-all';
         $upgradeMode = $command == 'upgrade' || $command == 'upgrade-all';
         $noFilesInstall = isset($options['nofiles']);
         $withDepsMode = !isset($options['nodeps']);
         $ignoreModifiedMode = true || !isset($options['ignorelocalmodification']);
         $rest = $this->rest();
         $ftp = empty($options['ftp']) ? false : $options['ftp'];
         if ($ftp) {
             list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
         } else {
             $config = $this->config();
             $cache = $this->getSconfig();
         }
         if ($installFileMode) {
             if (count($params) < 1) {
                 throw new \Exception("Argument should be: filename");
             }
             $filename = $params[0];
             if (!@file_exists($filename)) {
                 throw new \Exception("File '{$filename}' not found");
             }
             if (!@is_readable($filename)) {
                 throw new \Exception("File '{$filename}' is not readable");
             }
             $package = new \Magento\Framework\Connect\Package($filename);
             $package->validate();
             $errors = $package->getErrors();
             if (count($errors)) {
                 throw new \Exception("Package file is invalid\n" . implode("\n", $errors));
             }
             $pChan = $package->getChannel();
             $pName = $package->getName();
             $pVer = $package->getVersion();
             if (!$cache->isChannel($pChan)) {
                 throw new \Exception("'{$pChan}' is not installed channel");
             }
             $conflicts = $cache->hasConflicts($pChan, $pName, $pVer);
             if (false !== $conflicts) {
                 $conflicts = implode(", ", $conflicts);
                 if ($forceMode) {
                     $this->doError($command, "Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
                 } else {
                     throw new \Exception("Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
                 }
             }
             $conflicts = $package->checkPhpDependencies();
             if (true !== $conflicts) {
                 $confilcts = implode(",", $conflicts);
                 $err = "Package {$pChan}/{$pName} {$pVer} depends on PHP extensions: " . $conflicts;
                 if ($forceMode) {
                     $this->doError($command, $err);
                 } else {
                     throw new \Exception($err);
                 }
             }
             $conflicts = $package->checkPhpVersion();
             if (true !== $conflicts) {
                 $err = "Package {$pChan}/{$pName} {$pVer}: " . $conflicts;
                 if ($forceMode) {
                     $this->doError($command, $err);
                 } else {
                     throw new \Exception($err);
                 }
             }
             if (!$noFilesInstall) {
                 if ($ftp) {
                     $packager->processInstallPackageFtp($package, $filename, $config, $ftpObj);
                 } else {
                     $packager->processInstallPackage($package, $filename, $config);
                 }
             }
             $cache->addPackage($package);
             $installedDeps = array();
             $installedDepsAssoc = array();
             $installedDepsAssoc[] = array('channel' => $pChan, 'name' => $pName, 'version' => $pVer);
             $installedDeps[] = array($pChan, $pName, $pVer);
             $title = isset($options['title']) ? $options['title'] : "Package installed: ";
             $out = array($command => array('data' => $installedDeps, 'assoc' => $installedDepsAssoc, 'title' => $title));
             if ($ftp) {
                 $packager->writeToRemoteCache($cache, $ftpObj);
                 @unlink($config->getFilename());
             }
             $this->ui()->output($out);
             return $out[$command]['data'];
         }
         if (!$upgradeAllMode) {
             if (count($params) < 2) {
                 throw new \Exception("Argument should be: channelName packageName");
             }
             $channel = $params[0];
             $package = $params[1];
             $argVersionMax = isset($params[2]) ? $params[2] : false;
             $argVersionMin = false;
             if ($cache->isChannelName($channel)) {
                 $uri = $cache->chanUrl($channel);
             } elseif ($this->validator()->validateUrl($channel)) {
                 $uri = $channel;
             } elseif ($channel) {
                 $uri = $config->protocol . '://' . $channel;
             } else {
                 throw new \Exception("'{$channel}' is not existant channel name / valid uri");
             }
             if ($uri && !$cache->isChannel($uri)) {
                 $rest->setChannel($uri);
                 $data = $rest->getChannelInfo();
                 $data->uri = $uri;
                 $cache->addChannel($data->name, $uri);
                 $this->ui()->output("Successfully added channel: " . $uri);
             }
             $channelName = $cache->chanName($channel);
             //var_dump($channelName);
             $packagesToInstall = $packager->getDependenciesList($channelName, $package, $cache, $config, $argVersionMax, $argVersionMin, $withDepsMode);
             $packagesToInstall = $packagesToInstall['result'];
             //var_dump($packagesToInstall);
         } else {
             if (empty($params[0])) {
                 $channels = $cache->getChannelNames();
             } else {
                 $channel = $params[0];
                 if (!$cache->isChannel($channel)) {
                     throw new \Exception("'{$channel}' is not existant channel name / valid uri");
                 }
                 $channels = $cache->chanName($channel);
             }
             $packagesToInstall = array();
             $neededToUpgrade = $packager->getUpgradesList($channels, $cache, $config);
             foreach ($neededToUpgrade as $chan => $packages) {
                 foreach ($packages as $name => $data) {
                     $versionTo = $data['to'];
                     $tmp = $packager->getDependenciesList($chan, $name, $cache, $config, $versionTo, $versionTo, $withDepsMode);
                     if (count($tmp['result'])) {
                         $packagesToInstall = array_merge($packagesToInstall, $tmp['result']);
                     }
                 }
             }
         }
         /**
          * Make installation
          */
         $installedDeps = array();
         $installedDepsAssoc = array();
         $keys = array();
         foreach ($packagesToInstall as $package) {
             try {
                 $pName = $package['name'];
                 $pChan = $package['channel'];
                 $pVer = $package['downloaded_version'];
                 $rest->setChannel($cache->chanUrl($pChan));
                 /**
                  * Upgrade mode
                  */
                 if ($upgradeMode && $cache->hasPackage($pChan, $pName, $pVer, $pVer)) {
                     $this->ui()->output("Already installed: {$pChan}/{$pName} {$pVer}, skipping");
                     continue;
                 }
                 $conflicts = $cache->hasConflicts($pChan, $pName, $pVer);
                 if (false !== $conflicts) {
                     $conflicts = implode(", ", $conflicts);
                     if ($forceMode) {
                         $this->doError($command, "Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
                     } else {
                         throw new \Exception("Package {$pChan}/{$pName} {$pVer} conflicts with: " . $conflicts);
                     }
                 }
                 /**
                  * Modifications
                  */
                 if ($upgradeMode && !$ignoreModifiedMode) {
                     if ($ftp) {
                         $modifications = $packager->getRemoteModifiedFiles($pChan, $pName, $cache, $config, $ftp);
                     } else {
                         $modifications = $packager->getLocalModifiedFiles($pChan, $pName, $cache, $config);
                     }
                     if (count($modifications) > 0) {
                         $this->ui()->output('Changed locally: ');
                         foreach ($modifications as $row) {
                             if (!$ftp) {
                                 $this->ui()->output($config->magento_root . '/' . $row);
                             } else {
                                 $this->ui()->output($row);
                             }
                         }
                         /*$this->ui()->confirm('Do you want rewrite all files?');
                           continue;*/
                     }
                 }
                 $dir = $config->getChannelCacheDir($pChan);
                 @mkdir($dir, 0777, true);
                 $file = $dir . '/' . $pName . "-" . $pVer . ".tgz";
                 if (!@file_exists($file)) {
                     $rest->downloadPackageFileOfRelease($pName, $pVer, $file);
                 }
                 $package = new \Magento\Framework\Connect\Package($file);
                 $conflicts = $package->checkPhpDependencies();
                 if (true !== $conflicts) {
                     $confilcts = implode(",", $conflicts);
                     $err = "Package {$pChan}/{$pName} {$pVer} depends on PHP extensions: " . $conflicts;
                     if ($forceMode) {
                         $this->doError($command, $err);
                     } else {
                         throw new \Exception($err);
                     }
                 }
                 $conflicts = $package->checkPhpVersion();
                 if (true !== $conflicts) {
                     $err = "Package {$pChan}/{$pName} {$pVer}: " . $conflicts;
                     if ($forceMode) {
                         $this->doError($command, $err);
                     } else {
                         throw new \Exception($err);
                     }
                 }
                 if (!$noFilesInstall) {
                     if ($ftp) {
                         $packager->processInstallPackageFtp($package, $file, $config, $ftpObj);
                     } else {
                         $packager->processInstallPackage($package, $file, $config);
                     }
                 }
                 $cache->addPackage($package);
                 $installedDepsAssoc[] = array('channel' => $pChan, 'name' => $pName, 'version' => $pVer);
                 $installedDeps[] = array($pChan, $pName, $pVer);
             } catch (\Exception $e) {
                 $this->doError($command, $e->getMessage());
             }
         }
         $title = isset($options['title']) ? $options['title'] : "Package installed: ";
         $out = array($command => array('data' => $installedDeps, 'assoc' => $installedDepsAssoc, 'title' => $title));
         if ($ftp) {
             $packager->writeToRemoteCache($cache, $ftpObj);
             @unlink($config->getFilename());
         }
         $this->ui()->output($out);
         return $out[$command]['data'];
     } catch (\Exception $e) {
         if ($ftp) {
             $packager->writeToRemoteCache($cache, $ftpObj);
             @unlink($config->getFilename());
         }
         return $this->doError($command, $e->getMessage());
     }
 }