From 80e42fdf33ccdea0a6a15d067d884e049b6f1a39 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 5 Nov 2007 06:50:39 +0000 Subject: [PATCH] Port the EbuildNestedDie check from trunk since the python version is much faster than the old one that uses grep. svn path=/main/branches/2.1.2/; revision=8430 --- bin/repoman | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/bin/repoman b/bin/repoman index d1445d3d5..149dd1729 100755 --- a/bin/repoman +++ b/bin/repoman @@ -818,6 +818,24 @@ class EbuildQuote(object): break return errors +class EbuildNestedDie(object): + """Check ebuild for nested die statements (die statements in subshells""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\([^)]*\bdie\b') + + def __init__(self, contents): + self.contents = contents + + def Run(self): + errors = [] + for num, line in enumerate(self.contents): + match = self.nesteddie_re.match(line) + if match: + errors.append((num + 1, + 'Ebuild calls die in a subshell on line: %d')) + return errors + class EbuildUselessDodoc(object): """Check ebuild for useless files in dodoc arguments.""" repoman_check_name = 'ebuild.minorsyn' @@ -1403,10 +1421,6 @@ for x in scanlist: stats["usage.obsolete"] += 1 fails["usage.obsolete"].append("%s/%s.ebuild: not migrated to modular X" % (x, y)) - # this check needs work, it won't catch (\ndie) - if not os.system("egrep '^[^#]*\([^)]*\' "+checkdir+"/"+y+".ebuild >/dev/null 2>&1"): - stats["ebuild.nesteddie"]=stats["ebuild.nesteddie"]+1 - fails["ebuild.nesteddie"].append(x+"/"+y+".ebuild") # uselist checks - global myuse = [] default_use = [] @@ -1493,6 +1507,13 @@ for x in scanlist: stats[c.repoman_check_name] += 1 fails[c.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0]) del check + check = EbuildNestedDie(contents) + errors = check.Run() + for e in errors: + stats[check.repoman_check_name] += 1 + fails[check.repoman_check_name].append( + x + '/' + y + '.ebuild: %s' % e[1] % e[0]) + del check gentoo_copyright = re.compile(r'^# Copyright ((1999|200\d)-)?' + str(myear) + r' Gentoo Foundation') gentoo_license = re.compile(r'^# Distributed under the terms of the GNU General Public License v2$') -- 2.26.2