bug 106544 , glep31 enforcement checks
authorBrian Harring <ferringb@gentoo.org>
Sat, 24 Sep 2005 02:53:14 +0000 (02:53 -0000)
committerBrian Harring <ferringb@gentoo.org>
Sat, 24 Sep 2005 02:53:14 +0000 (02:53 -0000)
svn path=/main/branches/2.0/; revision=2020

ChangeLog
bin/repoman

index 6ef8d58e875af2743fe986cb4c7804b1fc08d29a..b153cbac85763fb16fda460bafbbf9fd05b01f1c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@
     2. /var/cache/edb/world is now /var/lib/portage/world.
     3. /etc/portage/profile/virtuals is _USER_ configs only.
 
+  23 Sep 2005; Brian Harring <ferringb@gentoo.org> bin/repoman:
+  bug 106544, glep31 enforcement checks.
+
   20 Sep 2005; Brian Harring <ferringb@gentoo.org> pym/portage.py:
   Cleanup after python, remove module from sys.modules that was a failed import 
   for selinux code- identified by Tudor Alexandru Dragos in bug #106363 .
index 1554f0bdb98bfb227e3fc0b057777d403636104a..6f0f5c32d47a9260d3766a0a96e8ed06975bb473 100755 (executable)
@@ -13,6 +13,13 @@ os.environ["PORTAGE_CALLER"]="repoman"
 sys.path = ["/usr/lib/portage/pym"]+sys.path
 version="1.2"  
 
+allowed_filename_chars="a-zA-Z0-9._-+:"
+allowed_filename_chars_set = {}
+map(allowed_filename_chars_set.setdefault, map(chr, range(ord('a'), ord('z')+1)))
+map(allowed_filename_chars_set.setdefault, map(chr, range(ord('A'), ord('Z')+1)))
+map(allowed_filename_chars_set.setdefault, map(chr, range(ord('0'), ord('9')+1)))
+map(allowed_filename_chars_set.setdefault, map(chr, map(ord, [".", "-", "_", "+", ":"])))
+
 import string,signal,re,pickle,tempfile
 
 import portage
@@ -21,6 +28,8 @@ import portage_const
 import portage_dep
 import cvstree
 import time
+import codecs
+
 from output import *
 #bold, darkgreen, darkred, green, red, turquoise, yellow
 
@@ -85,6 +94,8 @@ qahelp={
        "filedir.missing":"Package lacks a files directory",
        "file.executable":"Ebuilds, digests, metadata.xml, Manifest, and ChangeLog do note need the executable bit",
        "file.size":"Files in the files directory must be under 20k",
+       "file.name":"File/dir name must be composed of only the following chars: %s " % allowed_filename_chars,
+       "file.UTF8":"File is not UTF8 compliant",
        "KEYWORDS.missing":"Ebuilds that have a missing KEYWORDS variable",
        "LICENSE.missing":"Ebuilds that have a missing LICENSE variable",
        "DESCRIPTION.missing":"Ebuilds that have a missing DESCRIPTION variable",
@@ -663,6 +674,29 @@ for x in scanlist:
                                stats["file.executable"] += 1
                                fails["file.executable"].append(checkdir+"/"+y)
        digestlist=[]
+
+       for y in checkdirlist:
+               for c in y.strip(os.path.sep):
+                       if c not in allowed_filename_chars_set:
+                               stats["file.name"] += 1
+                               fails["file.name"].append("%s/%s: char '%s'" % (checkdir, y, c))
+                               break
+
+               if not (y in ("ChangeLog", "metadata.xml") or y.endswith(".ebuild")):
+                       continue
+               try:
+                       line = 1
+                       for l in codecs.open(y, "r", "utf8"):
+                               line +=1
+               except UnicodeDecodeError, ue:
+                       stats["file.UTF8"] += 1
+                       s = ue.object[:ue.start]
+                       l2 = s.count("\n")
+                       line += l2
+                       if l2 != 0:
+                               s = s[s.rfind("\n") + 1:]
+                       fails["file.UTF8"].append("%s/%s: line %i, just after: '%s'" % (checkdir, y, line, s))
+
        if isCvs:
                try:
                        mystat=os.stat(checkdir+"/files")[0]
@@ -799,6 +833,13 @@ for x in scanlist:
                                stats["file.size"] += 1
                                fails["file.size"].append("("+ str(mystat.st_size/1024) + "K) "+x+"/files/"+y)
 
+                       for c in y.strip(os.path.sep):
+                               if c not in allowed_filename_chars_set:
+                                       stats["file.name"] += 1
+                                       fails["file.name"].append("%s/%s: char '%s'" % (checkdir, y, c))
+                                       break
+
+
        if "ChangeLog" not in checkdirlist:
                stats["changelog.missing"]+=1
                fails["changelog.missing"].append(x+"/ChangeLog")