Added ability to specify compatibility in hotfix

This commit is contained in:
2016-12-02 15:23:03 +01:00
parent b5d3754b2f
commit 34f53c0e75
5 changed files with 115 additions and 1 deletions

View File

@ -10,7 +10,10 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use NoccyLabs\Hotfix\Hotfix\Loader;
use NoccyLabs\Hotfix\System\Facts;
class ApplyCommand extends Command
{
@ -64,6 +67,28 @@ class ApplyCommand extends Command
} else {
$output->writeln("<fg=red;options=bold>Warning: Hotfix is not signed or signature not valid!</fg=red;options=bold>");
}
$requires = $hotfix->getRequirements();
if (count($requires)>0) {
$engine = new ExpressionLanguage();
$facts = Facts::getSystemFacts()->getFacts();
while (true) {
$expr = array_shift($requires);
$ret = $engine->evaluate($expr, $facts);
if ($ret) {
//$output->writeln("<fg=green;options=bold>Hotfix is compatible with the current distribution</>");
break;
}
if (count($requires)==0) {
$output->writeln("<error>Error: This hotfix it not compatible with the current distribution</>");
return false;
}
}
//} else {
//$output->writeln("<fg=green;options=bold>Hotfix indicates universal compatibility.</>");
}
$output->writeln("");
$output->writeln(" Hotfix: <fg=yellow;options=bold>".$hotfix->getName()."</fg=yellow;options=bold>");
$output->writeln(" Author: <comment>".$hotfix->getAuthor()."</comment>");