Exemple #1
0
 /**
  * Обработка одного шага.
  *
  * @throw RollbackException
  * @param array $step
  */
 function processStep($step)
 {
     if (!count($step)) {
         return;
     }
     switch ($cmd = array_shift($step)) {
         case 'delete':
             $this->delete($step);
             break;
         case 'move':
             break;
         case 'undeploy':
             Deployer::undeploy(Dir::get($step[0], true));
             break;
         default:
             throw new RollbackException('Unknown command ' . $cmd);
     }
     return true;
 }
Exemple #2
0
 /**
  * Удаление пакета
  */
 static function uninstall($package)
 {
     $nvr = PackageManager::parseNRV($package);
     // проверка обратных зависимостей
     $res = Deps::isNoNeeded($nvr, $unstatisfied);
     if (count($res) == 0) {
         return IO::out('Packages to uninstall not found', IO::MESSAGE_FAIL);
     }
     if ($res === false) {
         io::out('Unable uninstall package ~WHITE~' . $nvr['name'] . '~~~ because', IO::MESSAGE_FAIL);
         foreach ($unstatisfied as $p => $d) {
             io::out('Package ' . $p . ' require  ' . implode(', ', array_keys($d)));
         }
         return false;
     }
     io::out('Packages to be removed: ', false);
     foreach ($res as $p) {
         io::out($p->name . '(' . $p->version . ') ', false);
     }
     io::out();
     if (IO::NO == io::dialog('Continue?', IO::YES | IO::NO, IO::NO)) {
         return 1;
     }
     foreach ($res as $p) {
         io::out('~WHITE~Undeploying ' . $p->name . '(' . $p->version . '):~~~');
         $r = Deployer::undeploy(Deployer::getPackageRollbackDir($p));
         if ($r || IO::OK != IO::dialog('Some part of rollback failed. Remove anyway?', IO::YES | IO::NO, IO::YES)) {
             Deployer::getPackageRollbackDir($p)->delete();
             $p->file->delete();
             PackageManager::get()->packagesSequence->removePackage($p->name, $p->version);
         }
     }
 }