summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2010-04-12 21:41:33 +0200
committerZac Medico <zmedico@gentoo.org>2010-08-10 18:27:37 -0700
commit3230e79815b43fc1c36f46a2b75a2567bfe9efa9 (patch)
tree4ffbe9b1b183be570b6ecdb791e03e60c57a99ba
parent4602c1d959ebaa8a8d0d60f8614e09d641a41709 (diff)
downloadportage-3230e79815b43fc1c36f46a2b75a2567bfe9efa9.tar.gz
portage-3230e79815b43fc1c36f46a2b75a2567bfe9efa9.tar.bz2
portage-3230e79815b43fc1c36f46a2b75a2567bfe9efa9.zip
Add REQUIRED_USE check as pre-merge check.
-rw-r--r--pym/_emerge/Scheduler.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index c6af547f8..d5c152f15 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -721,6 +721,63 @@ class Scheduler(PollScheduler):
return 1
return os.EX_OK
+ def _check_required_use(self):
+ # Make sure all constraints expressed in REQUIRED_USE are satisfied
+
+ failures = 0
+ shown_verifying_msg = False
+ for x in self._mergelist:
+ if not isinstance(x, Package):
+ continue
+
+ if x.operation == "uninstall":
+ continue
+
+ if x.metadata["EAPI"] in ("0", "1", "2", "3"):
+ continue
+
+ if not x.metadata["REQUIRED_USE"]:
+ continue
+
+ if not shown_verifying_msg:
+ shown_verifying_msg = True
+ self._status_msg("Verifying use flag constraints")
+
+ required_use = x.metadata["REQUIRED_USE"]
+ use = x.metadata["USE"].split()
+ iuse = x.metadata["IUSE"].split()
+
+ try:
+ sat, unsat = portage.dep.check_required_use(required_use, use, iuse)
+ except portage.exception.InvalidRequiredUseString as e:
+ failures += 1
+ portage.writemsg("!!! Invalid REQUIRED_USE specified by " + \
+ "'%s': %s\n" % (x.cpv, str(e)), noiselevel=-1)
+ del e
+ continue
+
+ if unsat:
+ failures += 1
+ if sat:
+ #not all constraints are violated, display the them all to not annoy
+ #the user with another violated constraint after he fixed the first one
+ portage.writemsg(
+ "!!! Use flag constraints for '%s' not met.\n" % x.cpv + \
+ "!!! violated constraint(s): '%s'\n" % unsat + \
+ "!!! all constraint(s): '%s'\n" % required_use, noiselevel=-1)
+ else:
+ portage.writemsg(
+ "!!! Use flag constraints for '%s' not met.\n" % x.cpv + \
+ "!!! constraint(s): '%s'\n" % required_use, noiselevel=-1)
+ if failures:
+ portage.writemsg("\n")
+ portage.writemsg("Explanation: || ( a b c ): at least one of 'a', 'b' or 'c' must be enabled\n")
+ portage.writemsg("Explanation: ^^ ( a b c ): exactly one of 'a', 'b' or 'c' must be enabled\n")
+ portage.writemsg("Explanation: a? ( b ): b needs to be enabled if a is enabled\n")
+ portage.writemsg("Explanation: '!'-prefix reverses the required state\n")
+ return 1
+ return os.EX_OK
+
def _add_prefetchers(self):
if not self._parallel_fetch:
@@ -990,6 +1047,10 @@ class Scheduler(PollScheduler):
if rval != os.EX_OK and not keep_going:
return rval
+ rval = self._check_required_use()
+ if rval != os.EX_OK:
+ return rval
+
rval = self._run_pkg_pretend()
if rval != os.EX_OK:
return rval