From: Sebastian Luther Date: Mon, 19 Sep 2011 13:07:08 +0000 (+0200) Subject: Reject inconsistent backtrack parameters X-Git-Tag: v2.2.0_alpha60~57 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6cea2091526659521d35be6c8dc7733f69f1a760;p=portage.git Reject inconsistent backtrack parameters If backtracking masks a package that caused another package to be masked, we declare this backtracking node as invalid. The backtracker should be able to find another node that gives a valid solution if one exists. This fixes bug 375573. --- diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 19773c2d9..8b2bfd378 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -1121,11 +1121,6 @@ class depgraph(object): all_match = False break - if to_be_selected >= to_be_masked: - # We only care about the parent atoms - # when they trigger a downgrade. - parent_atoms = set() - fallback_data.append((to_be_masked, parent_atoms)) if all_match: diff --git a/pym/_emerge/resolver/backtracking.py b/pym/_emerge/resolver/backtracking.py index dcdaee0cb..e072275fe 100644 --- a/pym/_emerge/resolver/backtracking.py +++ b/pym/_emerge/resolver/backtracking.py @@ -84,6 +84,9 @@ class Backtracker(object): Adds a newly computed backtrack parameter. Makes sure that it doesn't already exist and that we don't backtrack deeper than we are allowed by --backtrack. """ + if not self._check_runtime_pkg_mask(node.parameter.runtime_pkg_mask): + return + if node.mask_steps <= self._max_depth and node not in self._nodes: if explore: self._unexplored_nodes.append(node) @@ -105,6 +108,28 @@ class Backtracker(object): def __len__(self): return len(self._unexplored_nodes) + def _check_runtime_pkg_mask(self, runtime_pkg_mask): + """ + If a package gets masked that caused other packages to be masked + before, we revert the mask for other packages (bug 375573). + """ + + for pkg in runtime_pkg_mask: + + if "missing dependency" in runtime_pkg_mask[pkg]: + continue + + entry_is_valid = False + + for ppkg, patom in runtime_pkg_mask[pkg].get("slot conflict", set()): + if ppkg not in runtime_pkg_mask: + entry_is_valid = True + break + + if not entry_is_valid: + return False + + return True def _feedback_slot_conflict(self, conflict_data): for pkg, parent_atoms in conflict_data: diff --git a/pym/portage/tests/resolver/test_backtracking.py b/pym/portage/tests/resolver/test_backtracking.py index fc493062c..600f68216 100644 --- a/pym/portage/tests/resolver/test_backtracking.py +++ b/pym/portage/tests/resolver/test_backtracking.py @@ -167,3 +167,46 @@ class BacktrackingTestCase(TestCase): self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup() + + + def testBacktrackNoWrongRebuilds(self): + """ + Ensure we remove backtrack masks if the reason for the mask gets masked itself. + """ + + ebuilds = { + "dev-libs/A-1": { }, + "dev-libs/A-2": { }, + "dev-libs/B-1": { "RDEPEND": "dev-libs/D"}, + "dev-libs/C-1": { }, + "dev-libs/C-2": { "RDEPEND": ">=dev-libs/A-2" }, + "dev-libs/D-1": { "RDEPEND": "