[csw-devel] SF.net SVN: gar:[9409] csw/mgar/gar/v2

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Mar 28 15:11:34 CEST 2010


Revision: 9409
          http://gar.svn.sourceforge.net/gar/?rev=9409&view=rev
Author:   wahwah
Date:     2010-03-28 13:11:34 +0000 (Sun, 28 Mar 2010)

Log Message:
-----------
mGAR v2: checkpkg, better message handling, added CheckpkgMessenger class. Printing GAR line suggestions together near the end of the output.

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/checkpkg_run_modules.py
    csw/mgar/gar/v2/lib/python/checkpkg.py
    csw/mgar/gar/v2/lib/python/checkpkg_test.py
    csw/mgar/gar/v2/lib/python/gartest.py
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/package_checks_test.py
    csw/mgar/gar/v2/tests/static/example/checksums

Modified: csw/mgar/gar/v2/bin/checkpkg_run_modules.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg_run_modules.py	2010-03-28 12:04:52 UTC (rev 9408)
+++ csw/mgar/gar/v2/bin/checkpkg_run_modules.py	2010-03-28 13:11:34 UTC (rev 9409)
@@ -39,6 +39,8 @@
   f.close()
   if screen_report:
     sys.stdout.write(screen_report)
+  else:
+    logging.debug("No screen report.")
   sys.exit(exit_code)
 
 

Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py	2010-03-28 12:04:52 UTC (rev 9408)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py	2010-03-28 13:11:34 UTC (rev 9409)
@@ -68,33 +68,39 @@
 )
 
 REPORT_TMPL = u"""#if $missing_deps or $surplus_deps or $orphan_sonames
-# $pkgname:
+Missing dependencies of $pkgname:
 #end if
 #if $missing_deps
-# SUGGESTION: you may want to add some or all of the following as dependencies:
 #for $pkg, $reasons in $sorted($missing_deps)
-# $pkg, reasons:
+$pkg, reasons:
 #for $reason in $reasons
-# - $reason
+ - $reason
 #end for
 RUNTIME_DEP_PKGS_$pkgname += $pkg
 #end for
 #end if
 #if $surplus_deps
-# If you don't know of any reasons to include these dependencies, you might
-# remove them:
+If you don't know of any reasons to include these dependencies, you might remove them:
 #for $pkg in $sorted($surplus_deps)
-# ? $pkg
+? $pkg
 #end for
 #end if
 """
 
-SCREEN_ERROR_REPORT_TMPL = u"""#if $errors and $debug
+SCREEN_ERROR_REPORT_TMPL = u"""#if $errors
+#if $debug
 ERROR: One or more errors have been found by $name.
+#end if
 #for $pkgname in $errors
 $pkgname:
 #for $error in $errors[$pkgname]
+#if $debug
   $repr($error)
+#elif $error.msg
+$textwrap.fill($error.msg, 78, initial_indent="# ", subsequent_indent="# ")
+# -> $repr($error)
+
+#end if
 #end for
 #end for
 #else
@@ -102,6 +108,19 @@
 OK: $repr($name) module found no problems.
 #end if
 #end if
+#if $messages
+#for $msg in $messages
+$textwrap.fill($msg, 78, initial_indent="# ", subsequent_indent="# ")
+#end for
+#end if
+#if $gar_lines
+
+# Checkpkg suggests adding the following lines to the GAR recipe,
+# see above for details:
+#for $line in $gar_lines
+$line
+#end for
+#end if
 """
 
 # http://www.cheetahtemplate.org/docs/users_guide_html_multipage/language.directives.closures.html
@@ -154,18 +173,6 @@
   return options, set(args)
 
 
-def FormatDepsReport(pkgname, missing_deps, surplus_deps, orphan_sonames):
-  """To be removed."""
-  namespace = {
-      "pkgname": pkgname,
-      "missing_deps": missing_deps,
-      "surplus_deps": surplus_deps,
-      "orphan_sonames": orphan_sonames,
-  }
-  t = Template.Template(REPORT_TMPL, searchList=[namespace])
-  return unicode(t)
-
-
 def ExtractDescription(pkginfo):
   desc_re = re.compile(DESCRIPTION_RE)
   m = re.match(desc_re, pkginfo["NAME"])
@@ -590,11 +597,10 @@
     self.msg = msg
 
   def __repr__(self):
-    return (u"CheckpkgTag(%s, %s, %s, %s)"
+    return (u"CheckpkgTag(%s, %s, %s)"
             % (repr(self.pkgname),
                repr(self.tag_name),
-               repr(self.tag_info),
-               repr(self.msg)))
+               repr(self.tag_info)))
 
   def ToGarSyntax(self):
     msg_lines = []
@@ -611,7 +617,6 @@
     return "\n".join(msg_lines)
 
 
-
 class CheckpkgManagerBase(object):
   """Common functions between the older and newer calling functions."""
 
@@ -631,12 +636,14 @@
       stats_list.append(PackageStats(None, self.stats_basedir, md5sum))
     return stats_list
 
-  def FormatReports(self, errors):
+  def FormatReports(self, errors, messages, gar_lines):
     namespace = {
         "name": self.name,
         "errors": errors,
         "debug": self.debug,
         "textwrap": textwrap,
+        "messages": messages,
+        "gar_lines": gar_lines,
     }
     screen_t = Template.Template(SCREEN_ERROR_REPORT_TMPL, searchList=[namespace])
     tags_report_t = Template.Template(TAG_REPORT_TMPL, searchList=[namespace])
@@ -680,8 +687,8 @@
     Returns a tuple of an exit code and a report.
     """
     packages_data = self.GetPackageStatsList()
-    errors = self.GetAllTags(packages_data)
-    screen_report, tags_report = self.FormatReports(errors)
+    errors, messages, gar_lines = self.GetAllTags(packages_data)
+    screen_report, tags_report = self.FormatReports(errors, messages, gar_lines)
     exit_code = 0
     return (exit_code, screen_report, tags_report)
 
@@ -696,12 +703,12 @@
     self.system_pkgmap = system_pkgmap
     if not self.system_pkgmap:
       self.system_pkgmap = SystemPkgmap()
-    self.messages = []
     self.common_paths = {}
 
   def GetPkgmapLineByBasename(self, basename):
     """Proxies calls to self.system_pkgmap."""
-    logging.warning("GetPkgmapLineByBasename(%s): deprecated function", basename)
+    logging.warning("GetPkgmapLineByBasename(%s): deprecated function",
+                    basename)
     return self.system_pkgmap.GetPkgmapLineByBasename(basename)
 
   def GetPathsAndPkgnamesByBasename(self, basename):
@@ -711,9 +718,6 @@
   def GetInstalledPackages(self):
     return self.system_pkgmap.GetInstalledPackages()
 
-  def Message(self, msg):
-    sef.messages.append(msg)
-
   def GetCommonPaths(self, arch):
     """Returns a list of paths for architecture, from gar/etc/commondirs*."""
     assert arch in ('i386', 'sparc', 'all'), "Wrong arch: %s" % repr(arch)
@@ -732,7 +736,6 @@
     return lines
 
 
-
 class IndividualCheckInterface(CheckInterfaceBase):
   """To be passed to the checking functions.
 
@@ -745,7 +748,7 @@
     self.errors = []
 
   def ReportError(self, tag_name, tag_info=None, msg=None):
-    tag = CheckpkgTag(self.pkgname, tag_name, tag_info, msg)
+    tag = CheckpkgTag(self.pkgname, tag_name, tag_info, msg=msg)
     self.errors.append(tag)
 
 
@@ -757,10 +760,23 @@
     self.errors = []
 
   def ReportError(self, pkgname, tag_name, tag_info=None, msg=None):
-    tag = CheckpkgTag(pkgname, tag_name, tag_info, msg)
+    tag = CheckpkgTag(pkgname, tag_name, tag_info, msg=msg)
     self.errors.append(tag)
 
 
+class CheckpkgMessenger(object):
+  """Class responsible for passing messages from checks to the user."""
+  def __init__(self):
+    self.messages = []
+    self.gar_lines = []
+
+  def Message(self, m):
+    self.messages.append(m)
+
+  def SuggestGarLine(self, m):
+    self.gar_lines.append(m)
+
+
 class CheckpkgManager2(CheckpkgManagerBase):
   """The second incarnation of the checkpkg manager.
 
@@ -781,7 +797,7 @@
     checkpkg_module = package_checks
     members = dir(checkpkg_module)
     for member_name in members:
-      logging.debug("member_name: %s", repr(member_name))
+      logging.debug("Examining module member: %s", repr(member_name))
       member = getattr(checkpkg_module, member_name)
       if callable(member):
         if member_name.startswith("Check"):
@@ -793,14 +809,11 @@
 
   def GetAllTags(self, stats_obj_list):
     errors = {}
-    # TODO: Actually configure the logger with the logging level.
-    logging_level = logging.INFO
-    if self.debug:
-      logging_level = logging.DEBUG
     pkgmap = SystemPkgmap()
     logging.debug("Loading all package statistics.")
     pkgs_data = self.GetOptimizedAllStats(stats_obj_list)
     logging.debug("All package statistics loaded.")
+    messenger = CheckpkgMessenger()
     # Individual checks
     for pkg_data in pkgs_data:
       pkgname = pkg_data["basic_stats"]["pkgname"]
@@ -808,18 +821,18 @@
       for function in self.individual_checks:
         logger = logging.getLogger("%s-%s" % (pkgname, function.__name__))
         logger.debug("Calling %s", function.__name__)
-        function(pkg_data, check_interface, logger=logger)
+        function(pkg_data, check_interface, logger=logger, messenger=messenger)
         if check_interface.errors:
           errors[pkgname] = check_interface.errors
     # Set checks
     for function in self.set_checks:
-      logger = logging.getLogger("SetCheck-%s" % (function.__name__,))
+      logger = logging.getLogger(function.__name__)
       check_interface = SetCheckInterface(pkgmap)
       logger.debug("Calling %s", function.__name__)
-      function(pkgs_data, check_interface, logger)
+      function(pkgs_data, check_interface, logger=logger, messenger=messenger)
       if check_interface.errors:
         errors = self.SetErrorsToDict(check_interface.errors, errors)
-    return errors
+    return errors, messenger.messages, messenger.gar_lines
 
   def Run(self):
     self._AutoregisterChecks()
@@ -1170,7 +1183,6 @@
     dir_pkg = self.GetDirFormatPkg()
     logging.info("Collecting %s package statistics.", repr(dir_pkg.pkgname))
     self.DumpObject(dir_pkg.GetAllFilenames(), "all_filenames")
-    self.DumpObject(self.GetBasicStats(), "basic_stats")
     self.DumpObject(dir_pkg.ListBinaries(), "binaries")
     self.DumpObject(self.GetBinaryDumpInfo(), "binaries_dump_info")
     self.DumpObject(dir_pkg.GetDependencies(), "depends")
@@ -1185,6 +1197,10 @@
     # these data.
     # self.DumpObject(self.GetDefinedSymbols(), "defined_symbols")
     self.DumpObject(dir_pkg.GetFilesContaining(BAD_CONTENT_REGEXES), "bad_paths")
+    # This one should be last, so that if the collection is interrupted
+    # in one of the previous runs, the basic_stats.pickle file is not there
+    # or not updated, and the collection is started again.
+    self.DumpObject(self.GetBasicStats(), "basic_stats")
     logging.debug("Statistics of %s have been collected.", repr(dir_pkg.pkgname))
 
   def GetAllStats(self):

Modified: csw/mgar/gar/v2/lib/python/checkpkg_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_test.py	2010-03-28 12:04:52 UTC (rev 9408)
+++ csw/mgar/gar/v2/lib/python/checkpkg_test.py	2010-03-28 13:11:34 UTC (rev 9409)
@@ -184,7 +184,7 @@
           checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "foo-info"),
         ],
     }
-    screen_report, tags_report = m.FormatReports(tags)
+    screen_report, tags_report = m.FormatReports(tags, [])
     expected = u'# Tags reported by testname module\nCSWfoo: foo-tag foo-info\n'
     self.assertEqual(expected, tags_report)
 
@@ -197,7 +197,7 @@
           checkpkg.CheckpkgTag("CSWfoo", "baz-tag"),
         ],
     }
-    screen_report, tags_report = m.FormatReports(tags)
+    screen_report, tags_report = m.FormatReports(tags, [])
     expected = (u'# Tags reported by testname module\n'
                 u'CSWfoo: foo-tag foo-info\n'
                 u'CSWfoo: bar-tag bar-info\n'

Modified: csw/mgar/gar/v2/lib/python/gartest.py
===================================================================
--- csw/mgar/gar/v2/lib/python/gartest.py	2010-03-28 12:04:52 UTC (rev 9408)
+++ csw/mgar/gar/v2/lib/python/gartest.py	2010-03-28 13:11:34 UTC (rev 9409)
@@ -35,7 +35,7 @@
 """
 TMPDIR_PREFIX = "gartest-"
 # FIXME: This information should be pulled out from GAR
-DIR_PKG_OUT_DIR = os.path.join(os.environ["HOME"], "spool.5.8-sparc")
+DIR_PKG_OUT_DIR = os.path.join(os.environ["HOME"], "spool.5.9-sparc")
 
 
 class Error(Exception):

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-03-28 12:04:52 UTC (rev 9408)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-03-28 13:11:34 UTC (rev 9409)
@@ -7,7 +7,7 @@
 # Individual checks need to be named "Check<something>", while set checks are named
 # "SetCheck<something>".
 #
-# def CheckSomething(pkg_data, error_mgr, logger):
+# def CheckSomething(pkg_data, error_mgr, logger, messenger):
 #   logger.debug("Checking something.")
 #   error_mgr.ReportError("something-is-wrong")
 
@@ -76,7 +76,7 @@
 SYMBOLS_CHECK_ONLY_FOR = r"^CSWpm.*$"
 
 
-def CatalognameLowercase(pkg_data, error_mgr, logger):
+def CatalognameLowercase(pkg_data, error_mgr, logger, messenger):
   catalogname = pkg_data["basic_stats"]["catalogname"]
   if catalogname != catalogname.lower():
     error_mgr.ReportError("catalogname-not-lowercase")
@@ -84,7 +84,7 @@
     error_mgr.ReportError("catalogname-is-not-a-simple-word")
 
 
-def CheckDirectoryPermissions(pkg_data, error_mgr, logger):
+def CheckDirectoryPermissions(pkg_data, error_mgr, logger, messenger):
   for entry in pkg_data["pkgmap"]:
     if (entry["type"] == "d"
           and
@@ -95,14 +95,14 @@
                             entry["path"])
 
 
-def CheckNonCswPathsDirectoryPerms(pkg_data, error_mgr, logger):
+def CheckNonCswPathsDirectoryPerms(pkg_data, error_mgr, logger, messenger):
   for entry in pkg_data["pkgmap"]:
     if entry["user"] == "?" or entry["group"] == "?" or entry["mode"] == "?":
       if entry["path"].startswith("/opt/csw"):
         error_mgr.ReportError("pkgmap-question-mark-perms-in-opt-csw", entry["path"])
 
 
-def CheckPerlLocal(pkg_data, error_mgr, logger):
+def CheckPerlLocal(pkg_data, error_mgr, logger, messenger):
   perllocal_re = re.compile(r'/perllocal.pod')
   for entry in pkg_data["pkgmap"]:
     if entry["path"]:
@@ -110,7 +110,7 @@
         error_mgr.ReportError("perllocal-pod-in-pkgmap", entry["path"])
 
 
-def CheckMultipleDepends(pkg_data, error_mgr, logger):
+def CheckMultipleDepends(pkg_data, error_mgr, logger, messenger):
   new_depends = set()
   for pkgname, desc in pkg_data["depends"]:
     if pkgname in new_depends:
@@ -118,7 +118,7 @@
     new_depends.add(pkgname)
 
 
-def CheckDescription(pkg_data, error_mgr, logger):
+def CheckDescription(pkg_data, error_mgr, logger, messenger):
   pkginfo = pkg_data["pkginfo"]
   desc = checkpkg.ExtractDescription(pkginfo)
   if not desc:
@@ -130,13 +130,13 @@
       error_mgr.ReportError("pkginfo-description-not-starting-with-uppercase",
                             desc)
 
-def CheckVendorURL(pkg_data, error_mgr, logger):
+def CheckVendorURL(pkg_data, error_mgr, logger, messenger):
   vendorurl = pkg_data["pkginfo"]["VENDOR"].split(" ")[0]
   vendorurl_re = r"^(http|ftp)\://.+\..+$"
   if not re.match(vendorurl_re, vendorurl):
     error_mgr.ReportError("pkginfo-bad-vendorurl", vendorurl, "Solution: add VENDOR_URL to GAR Recipe") 
 
-def CheckCatalogname(pkg_data, error_mgr, logger):
+def CheckCatalogname(pkg_data, error_mgr, logger, messenger):
   pkginfo = pkg_data["pkginfo"]
   catalogname = pkginfo["NAME"].split(" ")[0]
   catalogname_re = r"^([\w\+]+)$"
@@ -144,7 +144,7 @@
     error_mgr.ReportError("pkginfo-bad-catalogname", catalogname)
 
 
-def CheckSmfIntegration(pkg_data, error_mgr, logger):
+def CheckSmfIntegration(pkg_data, error_mgr, logger, messenger):
   init_re = re.compile(r"/init\.d/")
   for entry in pkg_data["pkgmap"]:
     if not entry["path"]:
@@ -157,7 +157,7 @@
           "%s class=%s" % (entry["path"], entry["class"]))
 
 
-def SetCheckLibraries(pkgs_data, error_mgr, logger):
+def SetCheckLibraries(pkgs_data, error_mgr, logger, messenger):
   """Second versionof the library checking code.
 
   1. Collect all the data from the FS:
@@ -232,10 +232,14 @@
     t = Template.Template(checkpkg.REPORT_TMPL, searchList=[namespace])
     report = unicode(t)
     if report.strip():
-      print report
+      for line in report.splitlines():
+        messenger.Message(line)
+    for missing_dep in missing_deps:
+      messenger.SuggestGarLine(
+          "RUNTIME_DEP_PKGS_%s = %s" % (pkgname, missing_dep))
 
 
-def SetCheckDependencies(pkgs_data, error_mgr, logger):
+def SetCheckDependencies(pkgs_data, error_mgr, logger, messenger):
   """Dependencies must be either installed in the system, or in the set."""
   known_pkgs = set(error_mgr.GetInstalledPackages())
   pkgs_under_check = [x["basic_stats"]["pkgname"] for x in pkgs_data]
@@ -248,14 +252,14 @@
         error_mgr.ReportError(pkgname, "unidentified-dependency", depname)
 
 
-def CheckDependsOnSelf(pkg_data, error_mgr, logger):
+def CheckDependsOnSelf(pkg_data, error_mgr, logger, messenger):
   pkgname = pkg_data["basic_stats"]["pkgname"]
   for depname, dep_desc in pkg_data["depends"]:
     if depname == pkgname:
       error_mgr.ReportError("depends-on-self")
 
 
-def CheckArchitectureSanity(pkg_data, error_mgr, logger):
+def CheckArchitectureSanity(pkg_data, error_mgr, logger, messenger):
   basic_stats = pkg_data["basic_stats"]
   pkgname = basic_stats["pkgname"]
   pkginfo = pkg_data["pkginfo"]
@@ -267,7 +271,7 @@
                           "pkginfo=%s filename=%s" % (arch, filename))
 
 
-def CheckActionClasses(pkg_data, error_mgr, logger):
+def CheckActionClasses(pkg_data, error_mgr, logger, messenger):
   """Checks the consistency between classes in the prototype and pkginfo."""
   pkginfo = pkg_data["pkginfo"]
   pkgmap = pkg_data["pkgmap"]
@@ -286,7 +290,7 @@
     error_mgr.ReportError("action-class-only-in-pkgmap", action_class)
 
 
-def CheckLicenseFile(pkg_data, error_mgr, logger):
+def CheckLicenseFile(pkg_data, error_mgr, logger, messenger):
   """Checks for the presence of the license file."""
   # TODO: Write a unit test
   pkgmap = pkg_data["pkgmap"]
@@ -294,11 +298,12 @@
   license_path = LICENSE_TMPL % catalogname
   pkgmap_paths = [x["path"] for x in pkgmap]
   if license_path not in pkgmap_paths:
-    error_mgr.ReportError("license-missing")
-    logger.info("See http://sourceforge.net/apps/trac/gar/wiki/CopyRight")
+    error_mgr.ReportError(
+        "license-missing", license_path,
+        "See http://sourceforge.net/apps/trac/gar/wiki/CopyRight")
 
 
-def CheckObsoleteDeps(pkg_data, error_mgr, logger):
+def CheckObsoleteDeps(pkg_data, error_mgr, logger, messenger):
   """Checks for obsolete dependencies."""
   deps = set(pkg_data["depends"])
   obsolete_pkg_deps = deps.intersection(set(OBSOLETE_DEPS))
@@ -317,7 +322,7 @@
       logger.info(msg)
 
 
-def CheckArchitectureVsContents(pkg_data, error_mgr, logger):
+def CheckArchitectureVsContents(pkg_data, error_mgr, logger, messenger):
   """Verifies the relationship between package contents and architecture."""
   binaries = pkg_data["binaries"]
   pkginfo = pkg_data["pkginfo"]
@@ -341,13 +346,14 @@
     for tag, param, desc in reasons_to_be_arch_specific:
       error_mgr.ReportError(tag, param, desc)
   elif not reasons_to_be_arch_specific:
-    logger.info("Package %s does not contain any binaries.", pkgname)
-    logger.info("Consider making it ARCHALL = 1 instead of %s:", arch)
-    logger.info("ARCHALL_%s = 1", pkgname)
-    logger.info("However, be aware that there might be other reasons "
-                "to keep it architecture-specific.")
+    messenger.Message("Package %s does not contain any binaries. "
+                      "Consider making it ARCHALL = 1 instead of %s. "
+                      "However, be aware that there might be other reasons "
+                      "to keep it architecture-specific."
+                      % (pkgname, arch))
+    messenger.SuggestGarLine("ARCHALL_%s = 1" % pkgname)
 
-def CheckFileNameSanity(pkg_data, error_mgr, logger):
+def CheckFileNameSanity(pkg_data, error_mgr, logger, messenger):
   basic_stats = pkg_data["basic_stats"]
   revision_info = basic_stats["parsed_basename"]["revision_info"]
   catalogname = pkg_data["basic_stats"]["catalogname"]
@@ -362,7 +368,7 @@
     error_mgr.ReportError("osrel-tag-not-specified")
 
 
-def CheckPkginfoSanity(pkg_data, error_mgr, logger):
+def CheckPkginfoSanity(pkg_data, error_mgr, logger, messenger):
   """pkginfo sanity checks.
 
 if [ "$maintname" = "" ] ; then
@@ -415,23 +421,30 @@
     error_mgr.ReportError("pkginfo-maintainer-name-not-set")
   # email
   if not pkginfo["EMAIL"]:
-    error_mgr.ReportError("pkginfo-blank-email")
+    error_mgr.ReportError("pkginfo-email-blank")
   # hotline
   if not pkginfo["HOTLINE"]:
     error_mgr.ReportError("pkginfo-hotline-blank")
   pkginfo_version = pkg_data["basic_stats"]["parsed_basename"]["full_version_string"]
   if pkginfo_version != pkginfo["VERSION"]:
-    error_mgr.ReportError("filename-version-does-not-match-pkginfo-version")
+    error_mgr.ReportError("filename-version-does-not-match-pkginfo-version",
+                          "filename=%s pkginfo=%s"
+                          % (pkginfo_version, pkginfo["VERSION"]))
   if re.search(r"-", pkginfo["VERSION"]):
-    error_mgr.ReportError("pkginfo-minus-in-version")
+    error_mgr.ReportError("pkginfo-minus-in-version", pkginfo["VERSION"])
   if not re.match(VERSION_RE, pkginfo["VERSION"]):
-    msg = pkginfo["VERSION"]
-    error_mgr.ReportError("pkginfo-version-wrong-format", msg)
+    msg = "Should match %s" % VERSION_RE
+    error_mgr.ReportError("pkginfo-version-wrong-format",
+                          pkginfo["VERSION"],
+                          msg)
   if pkginfo["ARCH"] not in ARCH_LIST:
-    error_mgr.ReportError("pkginfo-nonstandard-architecture", pkginfo["ARCH"])
+    error_mgr.ReportError(
+        "pkginfo-nonstandard-architecture",
+        pkginfo["ARCH"],
+        "known architectures: %s" % ARCH_LIST)
 
 
-def CheckPstamp(pkg_data, error_mgr, logger):
+def CheckPstamp(pkg_data, error_mgr, logger, messenger):
   pkginfo = pkg_data["pkginfo"]
   if "PSTAMP" in pkginfo:
     if not re.match(checkpkg.PSTAMP_RE, pkginfo["PSTAMP"]):
@@ -442,7 +455,7 @@
     error_mgr.ReportError("pkginfo-pstamp-missing")
 
 
-def DisabledCheckMissingSymbols(pkgs_data, error_mgr, logger):
+def DisabledCheckMissingSymbols(pkgs_data, error_mgr, logger, messenger):
   """Analyzes missing symbols reported by ldd -r.
 
   1. Collect triplets: pkgname, binary, missing symbol
@@ -477,7 +490,7 @@
       error_mgr.ReportError("symbol-not-found", "%s %s" % (ms_binary, ms_symbol))
 
 
-def CheckBuildingUser(pkg_data, error_mgr, logger):
+def CheckBuildingUser(pkg_data, error_mgr, logger, messenger):
   pkgname = pkg_data["basic_stats"]["pkgname"]
   username = checkpkg.ExtractBuildUsername(pkg_data["pkginfo"])
   for entry in pkg_data["pkgmap"]:
@@ -486,7 +499,7 @@
                             "%s, %s" % (entry["path"], entry["user"]))
 
 
-def CheckDisallowedPaths(pkg_data, error_mgr, logger):
+def CheckDisallowedPaths(pkg_data, error_mgr, logger, messenger):
   """Checks for disallowed paths, such as common paths."""
   arch = pkg_data["pkginfo"]["ARCH"]
   # Common paths read from the file are absolute, e.g. /opt/csw/lib
@@ -513,10 +526,13 @@
       if intersection:
         logger.debug("Bad paths found: %s", intersection)
         for bad_path in intersection:
-          error_mgr.ReportError("disallowed-path", bad_path)
+          error_mgr.ReportError(
+              "disallowed-path", bad_path,
+              "This path is already provided by CSWcommon "
+              "or is not allowed for other reasons.")
 
 
-def CheckLinkingAgainstSunX11(pkg_data, error_mgr, logger):
+def CheckLinkingAgainstSunX11(pkg_data, error_mgr, logger, messenger):
   for binary_info in pkg_data["binaries_dump_info"]:
     for soname in binary_info["needed sonames"]:
       if (".so" in binary_info["soname"]
@@ -526,7 +542,7 @@
                               "%s %s" % (binary_info["base_name"], soname))
 
 
-def CheckDiscouragedFileNamePatterns(pkg_data, error_mgr, logger):
+def CheckDiscouragedFileNamePatterns(pkg_data, error_mgr, logger, messenger):
   patterns = [re.compile(x) for x in DISCOURAGED_FILE_PATTERNS]
   for entry in pkg_data["pkgmap"]:
     if entry["path"]:
@@ -536,19 +552,19 @@
                                 entry["path"])
 
 
-def CheckBadPaths(pkg_data, error_mgr, logger):
+def CheckBadPaths(pkg_data, error_mgr, logger, messenger):
   for regex in pkg_data["bad_paths"]:
     for file_name in pkg_data["bad_paths"][regex]:
       error_mgr.ReportError("file-with-bad-content", "%s %s" % (regex, file_name))
 
 
-def CheckPkgchk(pkg_data, error_mgr, logger):
+def CheckPkgchk(pkg_data, error_mgr, logger, messenger):
   if pkg_data["pkgchk"]["return_code"] != 0:
     error_mgr.ReportError("pkgchk-failed-with-code", pkg_data["pkgchk"]["return_code"])
     for line in pkg_data["pkgchk"]["stderr_lines"]:
       logger.warn(line)
 
-def CheckRpath(pkg_data, error_mgr, logger):
+def CheckRpath(pkg_data, error_mgr, logger, messenger):
   regex_whitelist = [re.compile(x) for x in RPATH_WHITELIST]
   for binary_info in pkg_data["binaries_dump_info"]:
     actual_rpaths = binary_info["runpath"]
@@ -610,7 +626,7 @@
   return errors
 
 
-def DisableCheckForMissingSymbolsDumb(pkg_data, error_mgr, logger):
+def DisableCheckForMissingSymbolsDumb(pkg_data, error_mgr, logger, messenger):
   """Analyzes missing symbols reported by ldd -r.
 
   So far only made sense for perl modules.  Disables because it falls over on

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-03-28 12:04:52 UTC (rev 9408)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-03-28 13:11:34 UTC (rev 9409)
@@ -27,32 +27,33 @@
   """Wraps common components of checkpkg tests."""
 
   def setUp(self):
-    # This is slow. Let's speed it up somehow.  Move away from yaml and create
-    # a Python module with the data.
     self.pkg_stats = DEFAULT_PKG_STATS
-    self.pkg_data = self.pkg_stats.GetAllStats()
+    # self.pkg_data = self.pkg_stats.GetAllStats()
     # This makes one of the test break. To be investigated.
-    # self.pkg_data = DEFAULT_PKG_DATA
+    self.pkg_data = copy.deepcopy(DEFAULT_PKG_DATA)
     self.mocker = mox.Mox()
 
   def testDefault(self):
 
     class LoggerStub(object):
-
       def debug(self, debug_s, *kwords):
         pass
-
       def info(self, debug_s, *kwords):
         pass
+    class MessengerStub(object):
+      def Message(self, m):
+        pass
     # self.logger_mock = self.mocker.CreateMock(logging.Logger)
     self.logger_mock = LoggerStub()
     self.error_mgr_mock = self.mocker.CreateMock(
         checkpkg.IndividualCheckInterface)
+    self.messenger = MessengerStub()
     self.CheckpkgTest()
     self.mocker.ReplayAll()
     getattr(pc, self.FUNCTION_NAME)(self.pkg_data,
                                     self.error_mgr_mock,
-                                    self.logger_mock)
+                                    self.logger_mock,
+                                    self.messenger)
     self.mocker.VerifyAll()
 
 

Modified: csw/mgar/gar/v2/tests/static/example/checksums
===================================================================
--- csw/mgar/gar/v2/tests/static/example/checksums	2010-03-28 12:04:52 UTC (rev 9408)
+++ csw/mgar/gar/v2/tests/static/example/checksums	2010-03-28 13:11:34 UTC (rev 9409)
@@ -1,2 +1,2 @@
 d388c5613c830fb4571d0457f53580a0  curses.h
-492eba390abe4fe74c185d0d343c2b81  grep
+11e8e7146ab016deabbe8e1fd21c956e  grep


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