|
@@ -25,6 +25,8 @@ class RuleSetGenerator
|
|
|
protected $rules;
|
|
|
protected $jobs;
|
|
|
protected $installedMap;
|
|
|
+ protected $whitelistedMap;
|
|
|
+ protected $addedMap;
|
|
|
|
|
|
public function __construct(PolicyInterface $policy, Pool $pool)
|
|
|
{
|
|
@@ -141,6 +143,41 @@ class RuleSetGenerator
|
|
|
$this->rules->add($newRule, $type);
|
|
|
}
|
|
|
|
|
|
+ protected function whitelistFromPackage(PackageInterface $package)
|
|
|
+ {
|
|
|
+ $workQueue = new \SplQueue;
|
|
|
+ $workQueue->enqueue($package);
|
|
|
+
|
|
|
+ while (!$workQueue->isEmpty()) {
|
|
|
+ $package = $workQueue->dequeue();
|
|
|
+ if (isset($this->whitelistedMap[$package->getId()])) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->whitelistedMap[$package->getId()] = true;
|
|
|
+
|
|
|
+ foreach ($package->getRequires() as $link) {
|
|
|
+ $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint(), true);
|
|
|
+
|
|
|
+ foreach ($possibleRequires as $require) {
|
|
|
+ $workQueue->enqueue($require);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $obsoleteProviders = $this->pool->whatProvides($package->getName(), null, true);
|
|
|
+
|
|
|
+ foreach ($obsoleteProviders as $provider) {
|
|
|
+ if ($provider === $package) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (($package instanceof AliasPackage) && $package->getAliasOf() === $provider) {
|
|
|
+ $workQueue->enqueue($provider);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
protected function addRulesForPackage(PackageInterface $package)
|
|
|
{
|
|
|
$workQueue = new \SplQueue;
|
|
@@ -236,6 +273,30 @@ class RuleSetGenerator
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function whitelistFromUpdatePackages(PackageInterface $package)
|
|
|
+ {
|
|
|
+ $updates = $this->policy->findUpdatePackages($this->pool, $this->installedMap, $package, true);
|
|
|
+
|
|
|
+ foreach ($updates as $update) {
|
|
|
+ $this->whitelistFromPackage($update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function whitelistFromJobs()
|
|
|
+ {
|
|
|
+ foreach ($this->jobs as $job) {
|
|
|
+ switch ($job['cmd']) {
|
|
|
+ case 'install':
|
|
|
+ if ($job['packages']) {
|
|
|
+ foreach ($job['packages'] as $package) {
|
|
|
+ $this->whitelistFromPackage($package);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
protected function addRulesForJobs()
|
|
|
{
|
|
|
foreach ($this->jobs as $job) {
|
|
@@ -270,6 +331,16 @@ class RuleSetGenerator
|
|
|
$this->rules = new RuleSet;
|
|
|
$this->installedMap = $installedMap;
|
|
|
|
|
|
+ $this->whitelistedNames = array();
|
|
|
+ foreach ($this->installedMap as $package) {
|
|
|
+ $this->whitelistFromPackage($package);
|
|
|
+ $this->whitelistFromUpdatePackages($package);
|
|
|
+ }
|
|
|
+ $this->whitelistFromJobs();
|
|
|
+
|
|
|
+ $this->pool->setWhitelist($this->whitelistedMap);
|
|
|
+
|
|
|
+ $this->addedMap = array();
|
|
|
foreach ($this->installedMap as $package) {
|
|
|
$this->addRulesForPackage($package);
|
|
|
$this->addRulesForUpdatePackages($package);
|