1
0
Fork 0

Remove dontFix feature for local packages and explicit fix command

This made sense for the libzypp, so your kernel doesn't get deleted
just cause it thinks something is broken, but it doesn't really make
sense for composer.
pull/568/head
Nils Adermann 2012-04-12 15:40:34 +02:00
parent 38cc4e9e5f
commit 64a451eaf9
1 changed files with 4 additions and 43 deletions

View File

@ -29,7 +29,6 @@ class Solver
protected $ruleToJob = array(); protected $ruleToJob = array();
protected $addedMap = array(); protected $addedMap = array();
protected $fixMap = array();
protected $updateMap = array(); protected $updateMap = array();
protected $noObsoletes = array(); protected $noObsoletes = array();
protected $watches = array(); protected $watches = array();
@ -214,12 +213,7 @@ class Solver
$this->addedMap[$package->getId()] = true; $this->addedMap[$package->getId()] = true;
$dontFix = 0; if (!$this->policy->installable($this, $this->pool, $this->installedMap, $package)) {
if (isset($this->installedMap[$package->getId()]) && !isset($this->fixMap[$package->getId()])) {
$dontFix = 1;
}
if (!$dontFix && !$this->policy->installable($this, $this->pool, $this->installedMap, $package)) {
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createRemoveRule($package, Rule::RULE_NOT_INSTALLABLE, (string) $package)); $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRemoveRule($package, Rule::RULE_NOT_INSTALLABLE, (string) $package));
continue; continue;
} }
@ -227,25 +221,6 @@ class Solver
foreach ($package->getRequires() as $link) { foreach ($package->getRequires() as $link) {
$possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint()); $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
// the strategy here is to not insist on dependencies
// that are already broken. so if we find one provider
// that was already installed, we know that the
// dependency was not broken before so we enforce it
if ($dontFix) {
$foundInstalled = false;
foreach ($possibleRequires as $require) {
if (isset($this->installedMap[$require->getId()])) {
$foundInstalled = true;
break;
}
}
// no installed provider found: previously broken dependency => don't add rule
if (!$foundInstalled) {
continue;
}
}
$this->addRule(RuleSet::TYPE_PACKAGE, $rule = $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, (string) $link)); $this->addRule(RuleSet::TYPE_PACKAGE, $rule = $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, (string) $link));
foreach ($possibleRequires as $require) { foreach ($possibleRequires as $require) {
@ -257,10 +232,6 @@ class Solver
$possibleConflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint()); $possibleConflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
foreach ($possibleConflicts as $conflict) { foreach ($possibleConflicts as $conflict) {
if ($dontFix && isset($this->installedMap[$conflict->getId()])) {
continue;
}
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createConflictRule($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, (string) $link)); $this->addRule(RuleSet::TYPE_PACKAGE, $this->createConflictRule($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, (string) $link));
} }
} }
@ -282,20 +253,15 @@ class Solver
continue; continue;
} }
if ($isInstalled && $dontFix && isset($this->installedMap[$provider->getId()])) {
continue; // don't repair installed/installed problems
}
$reason = ($isInstalled) ? Rule::RULE_INSTALLED_PACKAGE_OBSOLETES : Rule::RULE_PACKAGE_OBSOLETES; $reason = ($isInstalled) ? Rule::RULE_INSTALLED_PACKAGE_OBSOLETES : Rule::RULE_PACKAGE_OBSOLETES;
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createConflictRule($package, $provider, $reason, (string) $link)); $this->addRule(RuleSet::TYPE_PACKAGE, $this->createConflictRule($package, $provider, $reason, (string) $link));
} }
} }
// check implicit obsoletes // check implicit obsoletes
// for installed packages we only need to check installed/installed problems (and // for installed packages we only need to check installed/installed problems,
// only when dontFix is not set), as the others are picked up when looking at the // as the others are picked up when looking at the uninstalled package.
// uninstalled package. if (!$isInstalled) {
if (!$isInstalled || !$dontFix) {
$obsoleteProviders = $this->pool->whatProvides($package->getName(), null); $obsoleteProviders = $this->pool->whatProvides($package->getName(), null);
foreach ($obsoleteProviders as $provider) { foreach ($obsoleteProviders as $provider) {
@ -912,11 +878,6 @@ class Solver
foreach ($this->jobs as $job) { foreach ($this->jobs as $job) {
foreach ($job['packages'] as $package) { foreach ($job['packages'] as $package) {
switch ($job['cmd']) { switch ($job['cmd']) {
case 'fix':
if (isset($this->installedMap[$package->getId()])) {
$this->fixMap[$package->getId()] = true;
}
break;
case 'update': case 'update':
if (isset($this->installedMap[$package->getId()])) { if (isset($this->installedMap[$package->getId()])) {
$this->updateMap[$package->getId()] = true; $this->updateMap[$package->getId()] = true;