aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2019-11-26 10:05:47 -0800
committerZac Medico <zmedico@gentoo.org>2019-11-26 12:34:53 -0800
commit1b3131db0e22085dba7d0fb9fc6e5ec70c8c577d (patch)
treef7d433787a633d63c6f3787eee80e58825e1a47f
parentRename DCO_SIGNED_OFF_BY config variable to SIGNED_OFF_BY. (diff)
downloadportage-1b3131db0e22085dba7d0fb9fc6e5ec70c8c577d.tar.gz
portage-1b3131db0e22085dba7d0fb9fc6e5ec70c8c577d.tar.bz2
portage-1b3131db0e22085dba7d0fb9fc6e5ec70c8c577d.zip
emerge --buildpkgonly: respect buildtime hard blockers
Bug: https://bugs.gentoo.org/689226 Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rw-r--r--lib/_emerge/depgraph.py24
-rw-r--r--lib/portage/tests/resolver/test_blocker.py87
2 files changed, 102 insertions, 9 deletions
diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 68b5bdb2e..1127a6234 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -2791,7 +2791,6 @@ class depgraph(object):
def _add_dep(self, dep, allow_unsatisfied=False):
debug = "--debug" in self._frozen_config.myopts
- buildpkgonly = "--buildpkgonly" in self._frozen_config.myopts
nodeps = "--nodeps" in self._frozen_config.myopts
if dep.blocker:
@@ -2799,8 +2798,7 @@ class depgraph(object):
# blocker validation is only able to account for one package per slot.
is_slot_conflict_parent = any(dep.parent in conflict.pkgs[1:] for conflict in \
self._dynamic_config._package_tracker.slot_conflicts())
- if not buildpkgonly and \
- not nodeps and \
+ if not nodeps and \
not dep.collapsed_priority.ignored and \
not dep.collapsed_priority.optional and \
not is_slot_conflict_parent:
@@ -6805,8 +6803,7 @@ class depgraph(object):
for depclean and prune removal operations)
@type required_sets: dict
"""
- if "--buildpkgonly" in self._frozen_config.myopts or \
- "recurse" not in self._dynamic_config.myparams:
+ if "recurse" not in self._dynamic_config.myparams:
return 1
complete_if_new_use = self._dynamic_config.myparams.get(
@@ -7061,8 +7058,7 @@ class depgraph(object):
# has been called before it, by checking that it is not None.
self._dynamic_config._blocked_pkgs = digraph()
- if "--buildpkgonly" in self._frozen_config.myopts or \
- "--nodeps" in self._frozen_config.myopts:
+ if "--nodeps" in self._frozen_config.myopts:
return True
if True:
@@ -7338,6 +7334,10 @@ class depgraph(object):
# so apparently this one is unresolvable.
unresolved_blocks = True
+ if "--buildpkgonly" in self._frozen_config.myopts and not (
+ blocker.priority.buildtime and blocker.atom.blocker.overlap.forbid):
+ depends_on_order.clear()
+
# Make sure we don't unmerge any package that have been pulled
# into the graph.
if not unresolved_blocks and depends_on_order:
@@ -8292,9 +8292,17 @@ class depgraph(object):
retlist.extend(unsolvable_blockers)
retlist = tuple(retlist)
+ buildtime_blockers = []
+ if unsolvable_blockers and "--buildpkgonly" in self._frozen_config.myopts:
+ for blocker in unsolvable_blockers:
+ if blocker.priority.buildtime and blocker.atom.blocker.overlap.forbid:
+ buildtime_blockers.append(blocker)
+
if unsolvable_blockers and \
+ not buildtime_blockers and \
not self._accept_blocker_conflicts():
- self._dynamic_config._unsatisfied_blockers_for_display = unsolvable_blockers
+ self._dynamic_config._unsatisfied_blockers_for_display = (tuple(buildtime_blockers)
+ if buildtime_blockers else unsolvable_blockers)
self._dynamic_config._serialized_tasks_cache = retlist
self._dynamic_config._scheduler_graph = scheduler_graph
# Blockers don't trigger the _skip_restart flag, since
diff --git a/lib/portage/tests/resolver/test_blocker.py b/lib/portage/tests/resolver/test_blocker.py
index 94a88b8b4..6534f99e6 100644
--- a/lib/portage/tests/resolver/test_blocker.py
+++ b/lib/portage/tests/resolver/test_blocker.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Gentoo Foundation
+# Copyright 2014-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
@@ -46,3 +46,88 @@ class SlotConflictWithBlockerTestCase(TestCase):
self.assertEqual(test_case.test_success, True, test_case.fail_msg)
finally:
playground.cleanup()
+
+ def testBlockerBuildpkgonly(self):
+ ebuilds = {
+ 'dev-libs/A-1': {
+ 'EAPI': '7',
+ 'DEPEND': '!!dev-libs/X'
+ },
+
+ 'dev-libs/B-1': {
+ 'EAPI': '7',
+ 'BDEPEND': '!!dev-libs/X'
+ },
+
+ 'dev-libs/C-1': {
+ 'EAPI': '7',
+ 'BDEPEND': '!dev-libs/X'
+ },
+
+ 'dev-libs/D-1': {
+ 'EAPI': '7',
+ 'DEPEND': '!dev-libs/X'
+ },
+
+ 'dev-libs/E-1': {
+ 'EAPI': '7',
+ 'RDEPEND': '!dev-libs/X !!dev-libs/X'
+ },
+
+ 'dev-libs/F-1': {
+ 'EAPI': '7',
+ 'PDEPEND': '!dev-libs/X !!dev-libs/X'
+ },
+ }
+
+ installed = {
+ 'dev-libs/X-1': {},
+ }
+
+ test_cases = (
+ ResolverPlaygroundTestCase(
+ ['dev-libs/A'],
+ success = False,
+ options = {'--buildpkgonly': True},
+ mergelist = ['dev-libs/A-1', '!!dev-libs/X']),
+
+ ResolverPlaygroundTestCase(
+ ['dev-libs/B'],
+ success = False,
+ options = {'--buildpkgonly': True},
+ mergelist = ['dev-libs/B-1', '!!dev-libs/X']),
+
+ ResolverPlaygroundTestCase(
+ ['dev-libs/C'],
+ success = True,
+ options = {'--buildpkgonly': True},
+ mergelist = ['dev-libs/C-1']),
+
+ ResolverPlaygroundTestCase(
+ ['dev-libs/D'],
+ success = True,
+ options = {'--buildpkgonly': True},
+ mergelist = ['dev-libs/D-1']),
+
+ ResolverPlaygroundTestCase(
+ ['dev-libs/E'],
+ success = True,
+ options = {'--buildpkgonly': True},
+ mergelist = ['dev-libs/E-1']),
+
+ ResolverPlaygroundTestCase(
+ ['dev-libs/F'],
+ success = True,
+ options = {'--buildpkgonly': True},
+ mergelist = ['dev-libs/F-1']),
+ )
+
+ playground = ResolverPlayground(ebuilds=ebuilds,
+ installed=installed, debug=False)
+ try:
+ for test_case in test_cases:
+ playground.run_TestCase(test_case)
+ self.assertEqual(test_case.test_success, True, test_case.fail_msg)
+ finally:
+ playground.debug = False
+ playground.cleanup()