--- repoman 2003-08-26 12:27:48.000000000 +0100 +++ repoman.syn 2003-08-26 14:16:55.000000000 +0100 @@ -16,6 +16,7 @@ from output import * from commands import getstatusoutput from time import * +from fileinput import input if "cvs" not in portage.features: print @@ -65,7 +66,9 @@ "ebuild.syntax","ebuild.output", "ebuild.nesteddie","LICENSE.invalid", "IUSE.invalid","KEYWORDS.invalid", -"ebuild.nostable","ebuild.allmasked" +"ebuild.nostable","ebuild.allmasked", +"ebuild.majorsyn", "ebuild.minorsyn", +"ebuild.badheader", "metadata.missing" ] qawarnings=[ "changelog.missing", @@ -79,7 +82,10 @@ "digest.unmatch", "DEPEND.badmasked", "RDEPEND.badmasked", -"IUSE.invalid" +"IUSE.invalid", +"ebuild.minorsyn", +"ebuild.badheader", +"metadata.missing" ] missingvars=["KEYWORDS","LICENSE","DESCRIPTION","SLOT"] allvars=portage.auxdbkeys @@ -115,7 +121,11 @@ "LICENSE.invalid":"This ebuild is listing a license that doesnt exist in portages license/ dir.", "KEYWORDS.invalid":"This ebuild contains KEYWORDS that are not listed in profiles/keywords.desc", "ebuild.nostable":"There are no ebuilds that are marked as stable for your ARCH", - "ebuild.allmasked":"All ebuilds are masked for this package" + "ebuild.allmasked":"All ebuilds are masked for this package", + "ebuild.majorsyn":"This ebuild has a major syntax error that may cause the ebuild to fail partially or fully", + "ebuild.minorsyn":"This ebuild has a minor syntax error that contravenes gentoo coding style", + "ebuild.badheader":"This ebuild has a malformed header", + "metadata.missing":"Missing metadata.xml files" } def err(txt): @@ -446,7 +456,11 @@ if not cladded: stats["changelog.notadded"]+=1 fails["changelog.notadded"].append(x+"/ChangeLog") - + #metadata.xml file check + if "metadata.xml" not in checkdirlist: + stats["metadata.missing"]+=1 + fails["metadata.missing"].append(x+"/metadata.xml") + for y in ebuildlist: if y not in eadded: #ebuild not added to cvs @@ -544,6 +558,66 @@ if (mykey!="-*") and (myskey not in kwlist): stats["KEYWORDS.invalid"]=stats["KEYWORDS.invalid"]+1 fails["KEYWORDS.invalid"].append(x+"/"+y+".ebuild: %s" % mykey) + #syntax checks + gentoo_copyright = re.compile(r'^# Copyright 1999-' + strftime("%Y", gmtime()) + r' Gentoo Technologies, Inc\.') + gentoo_license = re.compile(r'^# Distributed under the terms of the GNU General Public License v2$') + ignore_line = re.compile(r'(^$)|(^(\t)*#)') + leading_spaces = re.compile(r'^[\S\t]') + trailing_whitespace = re.compile(r'.*([\S]$)') + continuation_symbol = re.compile(r'(.*[ ]+[\\][ ].*)') + line_continuation_quoted = re.compile(r'(\"|\')(([\w ,:;#\[\]\.`=/|\$\^\*{}()\'-])|(\\.))*\1') + line_continuation = re.compile(r'([^#]*\S)(\s+|\t)\\$') + linenum=0 + for line in input(checkdir+"/"+y+".ebuild"): + linenum += 1 + # Gentoo copyright check + if linenum == 1: + match = gentoo_copyright.match(line) + if not match: + myerrormsg = "Copyright header Error. Possibly date related." + stats["ebuild.badheader"] +=1 + fails["ebuild.badheader"].append(x+"/"+y+".ebuild: %s" % myerrormsg) + # Gentoo license check + elif linenum == 2: + match = gentoo_license.match(line) + if not match: + myerrormsg = "Gentoo License Error." + stats["ebuild.badheader"] +=1 + fails["ebuild.badheader"].append(x+"/"+y+".ebuild: %s" % myerrormsg) + else: + match = ignore_line.match(line) + if not match: + # Excluded Blank lines and full line comments. Good! + # Leading Spaces Check + match = leading_spaces.match(line) + if not match: + #Line has got leading spaces. Bad! + myerrormsg = "Leading Space Syntax Error. Line %d" % linenum + stats["ebuild.minorsyn"] +=1 + fails["ebuild.minorsyn"].append(x+"/"+y+".ebuild: %s" % myerrormsg) + # Trailing whitespace check + match = trailing_whitespace.match(line) + if not match: + #Line has got trailing whitespace. Bad! + myerrormsg = "Trailing whitespace Syntax Error. Line %d" % linenum + stats["ebuild.minorsyn"] +=1 + fails["ebuild.minorsyn"].append(x+"/"+y+".ebuild: %s" % myerrormsg) + # Line continuation check + match = continuation_symbol.match(line) + if match: + #Excluded lines not even containing a " \" match. Good! + line = re.sub(line_continuation_quoted,"\"\"",line) + #line has been edited to collapsed "" and '' quotes to "". Good! + match = continuation_symbol.match(line) + if match: + #Again exclude lines not even containing a " \" match. Good! + #This repetition is done for a slight performance increase + match = line_continuation.match(line) + if not match: + #Line has a line continuation error. Bad! + myerrormsg = "Line continuation (\"\\\") Syntax Error. Line %d" % linenum + stats["ebuild.majorsyn"] +=1 + fails["ebuild.majorsyn"].append(x+"/"+y+".ebuild: %s" % myerrormsg) # Check for 'all unstable' or 'all masked' -- ACCEPT_KEYWORDS is stripped # XXX -- Needs to be implemented in dep code. Can't determine ~arch nicely.