Make use_reduce raise an InvalidDependString exception for use? conditionals that...
authorZac Medico <zmedico@gentoo.org>
Sat, 16 Dec 2006 23:25:03 +0000 (23:25 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 16 Dec 2006 23:25:03 +0000 (23:25 -0000)
svn path=/main/trunk/; revision=5305

pym/portage.py
pym/portage_dep.py

index 0f1ba998f98f219b47e0c6222161544e2fec376c..7688b5aba7bbea3e6d4c6075cba5ed4958101112 100644 (file)
@@ -3884,26 +3884,27 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
        #convert parenthesis to sublists
        mysplit = portage_dep.paren_reduce(depstring)
 
-       if mysettings:
-               mymasks = set()
-               useforce = set([mysettings["ARCH"]])
-               if use == "all":
-                       # These masks are only for repoman.  In other cases, relevant masks
-                       # should have already been applied via config.regenerate().  Also,
-                       # binary or installed packages may have been built with flags that
-                       # are now masked, and it would be inconsistent to mask them now.
-                       # Additionally, myuse may consist of flags from a parent package
-                       # that is being merged to a $ROOT that is different from the one
-                       # that mysettings represents.
-                       mymasks.update(mysettings.usemask)
-                       mymasks.update(mysettings.archlist())
-                       mymasks.discard(mysettings["ARCH"])
-                       useforce.update(mysettings.useforce)
-                       useforce.difference_update(mymasks)
+       mymasks = set()
+       useforce = set()
+       useforce.add(mysettings["ARCH"])
+       if use == "all":
+               # This masking/forcing is only for repoman.  In other cases, relevant
+               # masking/forcing should have already been applied via
+               # config.regenerate().  Also, binary or installed packages may have
+               # been built with flags that are now masked, and it would be
+               # inconsistent to mask them now.  Additionally, myuse may consist of
+               # flags from a parent package that is being merged to a $ROOT that is
+               # different from the one that mysettings represents.
+               mymasks.update(mysettings.usemask)
+               mymasks.update(mysettings.archlist())
+               mymasks.discard(mysettings["ARCH"])
+               useforce.update(mysettings.useforce)
+               useforce.difference_update(mymasks)
+       try:
                mysplit = portage_dep.use_reduce(mysplit, uselist=myusesplit,
                        masklist=mymasks, matchall=(use=="all"), excludeall=useforce)
-       else:
-               mysplit = portage_dep.use_reduce(mysplit,uselist=myusesplit,matchall=(use=="all"))
+       except portage_exception.InvalidDependString, e:
+               return [0, str(e)]
 
        # Do the || conversions
        mysplit=portage_dep.dep_opconvert(mysplit)
index 7a4d76aae03f4103b9c529a7da25720318601966..a482ab2f4457bac3608e5d9ac9efde427d511351 100644 (file)
@@ -167,8 +167,9 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
                                for head in newdeparray[:-1]:
                                        head = head[:-1]
                                        if head[0] == "!":
-                                               head = head[1:]
-                                               if not matchall and head in uselist or head in excludeall:
+                                               head_key = head[1:]
+                                               if not matchall and head_key in uselist or \
+                                                       head_key in excludeall:
                                                        ismatch = False
                                                        break
                                        elif head not in masklist:
@@ -186,7 +187,8 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
                                                if additions:
                                                        rlist.append(additions)
                                        else:
-                                               rlist += [target]
+                                               raise portage_exception.InvalidDependString(
+                                                       "Conditional without parenthesis: '%s?'" % head)
 
                        else:
                                rlist += [head]