If the parent is not installed, check if it needs to be rebuilt against an installed instance, since otherwise it could trigger downgrade of an installed instance.
Bug: https://bugs.gentoo.org/652938 --- pym/_emerge/depgraph.py | 10 ++++- .../tests/resolver/test_slot_operator_rebuild.py | 43 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 160ea5e94..67f912f5e 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -2571,17 +2571,23 @@ class depgraph(object): isinstance(dep.parent, Package) and dep.parent.built): continue + # If the parent is not installed, check if it needs to be + # rebuilt against an installed instance, since otherwise + # it could trigger downgrade of an installed instance as + # in bug #652938. + want_update_probe = dep.want_update or not dep.parent.installed + # Check for slot update first, since we don't want to # trigger reinstall of the child package when a newer # slot will be used instead. - if rebuild_if_new_slot and dep.want_update: + if rebuild_if_new_slot and want_update_probe: new_dep = self._slot_operator_update_probe(dep, new_child_slot=True) if new_dep is not None: self._slot_operator_update_backtrack(dep, new_child_slot=new_dep.child) - if dep.want_update: + if want_update_probe: if self._slot_operator_update_probe(dep): self._slot_operator_update_backtrack(dep) diff --git a/pym/portage/tests/resolver/test_slot_operator_rebuild.py b/pym/portage/tests/resolver/test_slot_operator_rebuild.py index 42512aad8..46bad7de4 100644 --- a/pym/portage/tests/resolver/test_slot_operator_rebuild.py +++ b/pym/portage/tests/resolver/test_slot_operator_rebuild.py @@ -31,6 +31,32 @@ class SlotOperatorRebuildTestCase(TestCase): "RDEPEND": "|| ( app-misc/X app-misc/A:= )" }, + "app-misc/D-1" : { + "EAPI": "6", + "RDEPEND": "app-misc/E", + }, + + "app-misc/E-1" : { + "EAPI": "6", + "RDEPEND": "app-misc/F:=", + }, + + "app-misc/F-1" : { + "EAPI": "6", + "SLOT": "0/1" + }, + + "app-misc/F-2" : { + "EAPI": "6", + "SLOT": "0/2" + }, + } + + binpkgs = { + "app-misc/E-1" : { + "EAPI": "6", + "RDEPEND": "app-misc/F:0/1=", + }, } installed = { @@ -50,6 +76,10 @@ class SlotOperatorRebuildTestCase(TestCase): "RDEPEND": "|| ( app-misc/X app-misc/A:0/1= )" }, + "app-misc/F-2" : { + "EAPI": "6", + "SLOT": "0/2" + }, } world = ["app-misc/B", "app-misc/C"] @@ -68,9 +98,20 @@ class SlotOperatorRebuildTestCase(TestCase): mergelist = ['app-misc/A-2', ('app-misc/B-0', 'app-misc/C-0')] ), + # Test bug #652938, where a binary package built against an + # older subslot triggered downgrade of an installed package. + # In this case we want to reject the app-misc/E-1 binary + # package, and rebuild it against the installed instance of + # app-misc/F. + ResolverPlaygroundTestCase( + ["app-misc/D"], + options = {'--usepkg': True}, + success = True, + mergelist = ['app-misc/E-1', 'app-misc/D-1'] + ), ) - playground = ResolverPlayground(ebuilds=ebuilds, + playground = ResolverPlayground(ebuilds=ebuilds, binpkgs=binpkgs, installed=installed, world=world, debug=False) try: for test_case in test_cases: -- 2.13.6