[csw-devel] SF.net SVN: gar:[8210] csw/mgar/gar/v2
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Thu Jan 28 13:12:06 CET 2010
Revision: 8210
http://gar.svn.sourceforge.net/gar/?rev=8210&view=rev
Author: wahwah
Date: 2010-01-28 12:12:06 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
mGAR v2: a check for class consistency
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/opencsw.py
Added Paths:
-----------
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py
Added: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py (rev 0)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py 2010-01-28 12:12:06 UTC (rev 8210)
@@ -0,0 +1,61 @@
+#!/opt/csw/bin/python2.6
+# $Id$
+
+"""This is a dummy check. You can use it as a boilerplate for your own checks.
+
+Copy it and modify.
+"""
+
+import logging
+import os.path
+import sys
+import re
+
+# The following bit of code sets the correct path to Python libraries
+# distributed with GAR.
+path_list = [os.path.dirname(__file__),
+ "..", "..", "lib", "python"]
+sys.path.append(os.path.join(*path_list))
+import checkpkg
+import opencsw
+
+
+def CheckActionClasses(pkg):
+ """Checks the consistency between classes in the prototype and pkginfo."""
+ errors = []
+ pkginfo = pkg.GetParsedPkginfo()
+ pkgmap = pkg.GetPkgmap()
+ pkginfo_classes = set(re.split(opencsw.WS_RE, pkginfo["CLASSES"]))
+ pkgmap_classes = pkgmap.GetClasses()
+ only_in_pkginfo = pkginfo_classes.difference(pkgmap_classes)
+ only_in_pkgmap = pkgmap_classes.difference(pkginfo_classes)
+ for cls in only_in_pkginfo:
+ errors.append(
+ opencsw.PackageError("Class %s is only in pkginfo" % repr(cls)))
+ for cls in only_in_pkgmap:
+ errors.append(
+ opencsw.PackageError("Class %s is only in pkgmap" % repr(cls)))
+ if only_in_pkginfo or only_in_pkgmap:
+ errors.append(
+ opencsw.PackageError(
+ "pkginfo_classes: %s, pkgmap classes: %s" % (
+ pkginfo_classes, pkgmap_classes)))
+ return errors
+
+
+def main():
+ options, args = checkpkg.GetOptions()
+ pkgnames = args
+ check_manager = checkpkg.CheckpkgManager(
+ "class action scripts / prototype integrity",
+ options.extractdir,
+ pkgnames,
+ options.debug)
+ check_manager.RegisterIndividualCheck(CheckActionClasses)
+ exit_code, report = check_manager.Run()
+ print report.strip()
+ sys.exit(exit_code)
+
+
+if __name__ == '__main__':
+ main()
Property changes on: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg-actionclasses.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Id
Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py 2010-01-28 12:07:40 UTC (rev 8209)
+++ csw/mgar/gar/v2/lib/python/opencsw.py 2010-01-28 12:12:06 UTC (rev 8210)
@@ -196,7 +196,7 @@
for line in catalog_source:
# Working around the GPG signature
if line.startswith("#"): continue
- if "BEGIN PGP SIGNED MESSAGE" in line: continue
+ if "BEGIN PGP SIGNED MESSAGE" in line: continue
if line.startswith("Hash:"): continue
if len(line.strip()) <= 0: continue
if "BEGIN PGP SIGNATURE" in line: break
@@ -631,11 +631,25 @@
class Pkgmap(object):
+ """Represents the pkgmap of the package.
+ The plan:
+
+ entries = [
+ {
+ 'path': ...,
+ 'class': ...,
+ (more fields?)
+ }, ...
+ ]
+ """
+
def __init__(self, input, permissions=False,
strip=None):
self.paths = set()
self.analyze_permissions = permissions
+ self.entries = []
+ self.classes = None
for line in input:
fields = re.split(r'\s+', line)
if strip:
@@ -643,19 +657,41 @@
fields = [re.sub(strip_re, "", x) for x in fields]
logging.debug(fields)
line_to_add = None
+ installed_path = None
+ prototype_class = None
if len(fields) < 2:
continue
elif fields[1] in ('f', 'd'):
line_to_add = fields[3]
+ installed_path = fields[3]
+ prototype_class = fields[2]
if self.analyze_permissions:
line_to_add += " %s" % fields[4]
elif fields[1] in ('s', 'l'):
link_from, link_to = fields[3].split("=")
+ installed_path = link_from
line_to_add = "%s --> %s" % (link_from, link_to)
+ prototype_class = fields[2]
if line_to_add:
self.paths.add(line_to_add)
+ entry = {
+ "line": line,
+ }
+ if installed_path:
+ entry["path"] = installed_path
+ entry["class"] = prototype_class
+ self.entries.append(entry)
+ def GetClasses(self):
+ """The assumtion is that the set of classes never changes."""
+ if not self.classes:
+ self.classes = set()
+ for entry in self.entries:
+ if entry["class"]:
+ self.classes.add(entry["class"])
+ return self.classes
+
class PackageComparator(object):
def __init__(self, file_name_a, file_name_b,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list