From afd26ffa8819f1a61a3a41ee5a549f254363b153 Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Thu, 5 Jan 2006 08:10:29 +0000 Subject: bug 42299, detect and fail invalid atoms in *DEPEND svn path=/main/trunk/; revision=2532 --- bin/repoman | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'bin') diff --git a/bin/repoman b/bin/repoman index bc7c80924..19e0c430d 100755 --- a/bin/repoman +++ b/bin/repoman @@ -959,12 +959,12 @@ for x in scanlist: badlicsyntax = False badprovsyntax = False catpkg = catdir+"/"+y + type_list, badsyntax = [], [] for mytype in ("DEPEND", "RDEPEND", "PDEPEND", "LICENSE", "PROVIDE"): mydepstr = myaux[mytype] - badsyntax = None if (string.find(mydepstr, " ?") != -1): - badsyntax = "'?' preceded by space" + badsyntax.append("'?' preceded by space") try: # Missing closing parenthesis will result in a ValueError @@ -973,7 +973,7 @@ for x in scanlist: if "" in mydeplist or "(" in mydeplist: raise ValueError except ValueError: - badsyntax = "parenthesis mismatch" + badsyntax.append("parenthesis mismatch") for token in ("||", "(", ")"): if mydepstr.startswith(token+" "): @@ -985,22 +985,25 @@ for x in scanlist: while myteststr.find(" "+token+" ") != -1: myteststr = " ".join(myteststr.split(" "+token+" ", 1)) if myteststr.find(token) != -1: - print mydepstr - print myteststr - print token - badsyntax = "'%s' not separated by space" % (token) - break + badsyntax.append("'%s' not separated by space" % (token)) - if badsyntax: - stats[mytype+".syntax"] += 1 - fails[mytype+".syntax"].append(catpkg+".ebuild "+mytype+": "+badsyntax) - if mytype == "LICENSE": - badlicsyntax = True - elif mytype == "PROVIDE": - badprovsyntax = True - else: - baddepsyntax = True - continue + + if mytype in ("DEPEND", "RDEPEND", "PDEPEND"): + for token in filter(lambda x: not (x.endswith("?") or x.strip() in ("||", "&&")), mydepstr.split()): + if not "/" in token: + badsyntax.append("'%s' not a valid atom" % token) + + type_list.extend([mytype] * (len(badsyntax) - len(type_list))) + + for m,b in zip(type_list, badsyntax): + stats[m+".syntax"] += 1 + fails[m+".syntax"].append(catpkg+".ebuild "+m+": "+b) + + badlicsyntax = len(filter(lambda x:x=="LICENSE", type_list)) + badprovsyntax = len(filter(lambda x:x=="PROVIDE", type_list)) + baddepsyntax = len(type_list) != badlicsyntax + badprovsyntax + badlicsyntax = badlicsyntax > 0 + badprovsyntax = badprovsyntax > 0 for keyword,arch,groups in arches: portage.groups=groups -- cgit v1.2.3-1-g7c22