diff options
author | Sebastian Luther <SebastianLuther@gmx.de> | 2010-08-16 21:41:02 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-08-16 17:40:27 -0700 |
commit | c9f7930883d62fc26af72bff0c4623db0bbc8221 (patch) | |
tree | 5a7715ef593ee43085714150f1b5e784a01a551f | |
parent | 2fd3ea367e0b7f7978a3fc85e5cb57e7191ee431 (diff) | |
download | portage-c9f7930883d62fc26af72bff0c4623db0bbc8221.tar.gz portage-c9f7930883d62fc26af72bff0c4623db0bbc8221.tar.bz2 portage-c9f7930883d62fc26af72bff0c4623db0bbc8221.zip |
Pass token_class parameter if possible to use_reduce
-rwxr-xr-x | bin/repoman | 152 | ||||
-rw-r--r-- | pym/portage/dep/dep_check.py | 43 |
2 files changed, 93 insertions, 102 deletions
diff --git a/bin/repoman b/bin/repoman index 740b92e78..cb9baf1be 100755 --- a/bin/repoman +++ b/bin/repoman @@ -74,7 +74,7 @@ from portage.util import cmp_sort_key, writemsg_level from portage.package.ebuild.digestgen import digestgen from portage.eapi import eapi_has_src_uri_arrows, eapi_has_slot_deps, \ eapi_has_use_deps, eapi_has_strong_blocks, eapi_has_iuse_defaults, \ - eapi_has_required_use + eapi_has_required_use, eapi_has_use_dep_defaults if sys.hexversion >= 0x3000000: basestring = str @@ -1466,14 +1466,18 @@ for x in scanlist: "%s: '%s' found in thirdpartymirrors" % \ (relative_path, mirror)) - provide = portage.dep.use_reduce(pkg.metadata['PROVIDE'], matchall=1, flat=True) + try: + provide = portage.dep.use_reduce(pkg.metadata['PROVIDE'], matchall=1, flat=True) + except portage.exception.InvalidDependString: + stats["PROVIDE.syntax"] = stats["PROVIDE.syntax"] + 1 + fails["PROVIDE.syntax"].append("%s: %s" % \ + (relative_path, myprovide)) + provide = [] provide_cps = [] # The Package class automatically evaluates USE conditionals. for myprovide in provide: - try: - myprovide = portage.dep.Atom(myprovide) - except portage.exception.InvalidAtom: + if not isinstance(myprovide, portage.dep.Atom): stats["PROVIDE.syntax"] = stats["PROVIDE.syntax"] + 1 fails["PROVIDE.syntax"].append("%s: %s" % \ (relative_path, myprovide)) @@ -1607,86 +1611,77 @@ for x in scanlist: for mytype in ("DEPEND", "RDEPEND", "PDEPEND", "LICENSE", "PROPERTIES", "PROVIDE"): mydepstr = myaux[mytype] - - if mydepstr.find(" ?") != -1: - badsyntax.append("'?' preceded by space") + + token_class = None + if mytype in ("DEPEND", "RDEPEND", "PDEPEND"): + token_class=portage.dep.Atom try: - portage.dep.use_reduce(mydepstr, matchall=1) + atoms = portage.dep.use_reduce(mydepstr, matchall=1, flat=True, token_class=token_class) except portage.exception.InvalidDependString as e: + atoms = None badsyntax.append(str(e)) - for token in operator_tokens: - if mydepstr.startswith(token+" "): - myteststr = mydepstr[len(token):] - else: - myteststr = mydepstr - myteststr = myteststr.replace("(+)", "") - myteststr = myteststr.replace("(-)", "") - if myteststr.endswith(" "+token): - myteststr = myteststr[:-len(token)] - while myteststr.find(" "+token+" ") != -1: - myteststr = " ".join(myteststr.split(" "+token+" ", 1)) - if myteststr.find(token) != -1: - badsyntax.append("'%s' not separated by space" % (token)) + if atoms and mytype in ("DEPEND", "RDEPEND", "PDEPEND"): + if mytype in ("RDEPEND", "PDEPEND") and \ + "test?" in mydepstr.split(): + stats[mytype + '.suspect'] += 1 + fails[mytype + '.suspect'].append(relative_path + \ + ": 'test?' USE conditional in %s" % mytype) - if mytype in ("DEPEND", "RDEPEND", "PDEPEND"): - for token in mydepstr.split(): - if token in operator_tokens or \ - token[-1:] == "?": - if token == "test?" and \ - mytype in ("RDEPEND", "PDEPEND"): - stats[mytype + '.suspect'] += 1 - fails[mytype + '.suspect'].append(relative_path + \ - ": 'test?' USE conditional in %s" % mytype) + for atom in atoms: + if atom == "||": continue - try: - atom = portage.dep.Atom(token) - except portage.exception.InvalidAtom: - badsyntax.append("'%s' not a valid atom" % token) - else: - is_blocker = atom.blocker - - if mytype == "DEPEND" and \ - not is_blocker and \ - not inherited_java_eclass and \ - atom.cp == "virtual/jdk": - stats['java.eclassesnotused'] += 1 - fails['java.eclassesnotused'].append(relative_path) - elif mytype in ("PDEPEND", "RDEPEND"): - if not is_blocker and \ - atom.cp in suspect_rdepend: - stats[mytype + '.suspect'] += 1 - fails[mytype + '.suspect'].append( - relative_path + ": '%s'" % atom) - if not eapi_has_slot_deps(eapi): - if portage.dep.dep_getslot(atom): - stats['EAPI.incompatible'] += 1 - fails['EAPI.incompatible'].append( - (relative_path + ": %s slot dependency" + \ - " not supported with EAPI='%s':" + \ - " '%s'") % (mytype, eapi, atom)) - if atom.use and not eapi_has_use_deps(eapi): - stats['EAPI.incompatible'] += 1 - fails['EAPI.incompatible'].append( - (relative_path + ": %s use dependency" + \ - " not supported with EAPI='%s':" + \ - " '%s'") % (mytype, eapi, atom)) - if atom.blocker and atom.blocker.overlap.forbid \ - and not eapi_has_strong_blocks(eapi): + + is_blocker = atom.blocker + + if mytype == "DEPEND" and \ + not is_blocker and \ + not inherited_java_eclass and \ + atom.cp == "virtual/jdk": + stats['java.eclassesnotused'] += 1 + fails['java.eclassesnotused'].append(relative_path) + elif mytype in ("PDEPEND", "RDEPEND"): + if not is_blocker and \ + atom.cp in suspect_rdepend: + stats[mytype + '.suspect'] += 1 + fails[mytype + '.suspect'].append( + relative_path + ": '%s'" % atom) + if not eapi_has_slot_deps(eapi): + if portage.dep.dep_getslot(atom): stats['EAPI.incompatible'] += 1 fails['EAPI.incompatible'].append( - (relative_path + ": %s new blocker syntax" + \ + (relative_path + ": %s slot dependency" + \ " not supported with EAPI='%s':" + \ " '%s'") % (mytype, eapi, atom)) - - if atom.operator == "~" and \ - portage.versions.catpkgsplit(atom.cpv)[3] != "r0": - stats[mytype + '.badtilde'] += 1 - fails[mytype + '.badtilde'].append( - (relative_path + ": %s uses the ~ operator" - " with a non-zero revision:" + \ - " '%s'") % (mytype, atom)) + if atom.use and not eapi_has_use_deps(eapi): + stats['EAPI.incompatible'] += 1 + fails['EAPI.incompatible'].append( + (relative_path + ": %s use dependency" + \ + " not supported with EAPI='%s':" + \ + " '%s'") % (mytype, eapi, atom)) + if atom.use and (atom.use.missing_enabled or atom.use.missing_disabled) and \ + not eapi_has_use_dep_defaults(eapi): + stats['EAPI.incompatible'] += 1 + fails['EAPI.incompatible'].append( + (relative_path + ": %s use dependency" + \ + " not supported with EAPI='%s':" + \ + " '%s'") % (mytype, eapi, atom)) + if atom.blocker and atom.blocker.overlap.forbid \ + and not eapi_has_strong_blocks(eapi): + stats['EAPI.incompatible'] += 1 + fails['EAPI.incompatible'].append( + (relative_path + ": %s new blocker syntax" + \ + " not supported with EAPI='%s':" + \ + " '%s'") % (mytype, eapi, atom)) + + if atom.operator == "~" and \ + portage.versions.catpkgsplit(atom.cpv)[3] != "r0": + stats[mytype + '.badtilde'] += 1 + fails[mytype + '.badtilde'].append( + (relative_path + ": %s uses the ~ operator" + " with a non-zero revision:" + \ + " '%s'") % (mytype, atom)) type_list.extend([mytype] * (len(badsyntax) - len(type_list))) @@ -1730,18 +1725,17 @@ for x in scanlist: # license checks if not badlicsyntax: - myuse = myaux["LICENSE"] # Parse the LICENSE variable, remove USE conditions and # flatten it. - myuse=portage.dep.use_reduce(myuse, matchall=1, flat=True) + licenses = portage.dep.use_reduce(myaux["LICENSE"], matchall=1, flat=True) # Check each entry to ensure that it exists in PORTDIR's # license directory. - for mypos in range(0,len(myuse)): + for lic in licenses: # Need to check for "||" manually as no portage # function will remove it without removing values. - if myuse[mypos] not in liclist and myuse[mypos] != "||": + if lic not in liclist and lic != "||": stats["LICENSE.invalid"]=stats["LICENSE.invalid"]+1 - fails["LICENSE.invalid"].append(x+"/"+y+".ebuild: %s" % myuse[mypos]) + fails["LICENSE.invalid"].append(x+"/"+y+".ebuild: %s" % lic) #keyword checks myuse = myaux["KEYWORDS"].split() diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py index 74e14882b..4e0d319db 100644 --- a/pym/portage/dep/dep_check.py +++ b/pym/portage/dep/dep_check.py @@ -60,32 +60,29 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/", continue if not isinstance(x, Atom): - try: - x = Atom(x) - except InvalidAtom: - raise ParseError( - _("invalid atom: '%s'") % x) - else: - if x.blocker and x.blocker.overlap.forbid and \ - not eapi_has_strong_blocks(eapi): - raise ParseError( - _("invalid atom: '%s'") % (x,)) - if x.use and not eapi_has_use_deps(eapi): - raise ParseError( - _("invalid atom: '%s'") % (x,)) - if x.slot and not eapi_has_slot_deps(eapi): - raise ParseError( - _("invalid atom: '%s'") % (x,)) - if x.use and (x.use.missing_enabled or x.use.missing_disabled) \ - and not eapi_has_use_dep_defaults(eapi): - raise ParseError( - _("invalid atom: '%s'") % (x,)) + raise ParseError( + _("invalid token: '%s'") % x) + + if x.blocker and x.blocker.overlap.forbid and \ + not eapi_has_strong_blocks(eapi): + raise ParseError( + _("strong blocks are not allowed in EAPI %s: '%s'") % (eapi, x)) + if x.use and not eapi_has_use_deps(eapi): + raise ParseError( + _("use deps are not allowed in EAPI %s: '%s'") % (eapi, x)) + if x.slot and not eapi_has_slot_deps(eapi): + raise ParseError( + _("slot deps are not allowed in EAPI %s: '%s'") % (eapi, x)) + if x.use and (x.use.missing_enabled or x.use.missing_disabled) \ + and not eapi_has_use_dep_defaults(eapi): + raise ParseError( + _("use dep defaults are not allowed in EAPI %s: '%s'") % (eapi, x)) if repoman: x = x._eval_qa_conditionals(use_mask, use_force) if not repoman and \ - myuse is not None and isinstance(x, Atom) and x.use: + myuse is not None and x.use: if x.use.conditional: x = x.evaluate_conditionals(myuse) @@ -542,8 +539,8 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None, useforce.update(mysettings.useforce) useforce.difference_update(mymasks) try: - mysplit = use_reduce(depstring, uselist=myusesplit, - masklist=mymasks, matchall=(use=="all"), excludeall=useforce, opconvert=True) + mysplit = use_reduce(depstring, uselist=myusesplit, masklist=mymasks, \ + matchall=(use=="all"), excludeall=useforce, opconvert=True, token_class=Atom) except InvalidDependString as e: return [0, str(e)] |