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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Mar 14 15:38:43 CET 2010


Revision: 9163
          http://gar.svn.sourceforge.net/gar/?rev=9163&view=rev
Author:   wahwah
Date:     2010-03-14 14:38:43 +0000 (Sun, 14 Mar 2010)

Log Message:
-----------
mGAR v2: checkpkg, removed old API tests, moved all Python checks to a separate executable.

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/checkpkg
    csw/mgar/gar/v2/lib/python/checkpkg.py
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/package_checks_test.py

Added Paths:
-----------
    csw/mgar/gar/v2/bin/checkpkg_run_modules.py

Removed Paths:
-------------
    csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py
    csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py
    csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-you-can-write-your-own.py
    csw/mgar/gar/v2/lib/python/package_checks_old.py
    csw/mgar/gar/v2/lib/python/package_checks_old_test.py

Modified: csw/mgar/gar/v2/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/bin/checkpkg	2010-03-14 14:38:43 UTC (rev 9163)
@@ -339,6 +339,20 @@
 	fi
 done
 
+# This check is special; it uses one executable for all the checks written in Python.
+printf "${BOLD}${module_name_format}${COLOR_RESET} running..." "Python tests"
+${command_basedir}/checkpkg_run_modules.py \
+    ${extra_options} \
+    -b "${checkpkg_stats_basedir}" \
+    -o "${EXTRACTDIR}/tags.python-checks" \
+    ${md5sums}
+if [[ "$?" -ne 0 ]]; then
+  printf "\r${module_name_format} ${RED}[ERROR]${COLOR_RESET}        \\n" "${plugin_name}"
+  test_suite_ok=0
+else
+  printf "\r${module_name_format} [Done]        \\n" "${plugin_name}"
+fi
+
 if [[ ${test_suite_ok} -ne 1 ]]; then
 	errmsg "One or more modular tests have finished with an error."
 else

Copied: csw/mgar/gar/v2/bin/checkpkg_run_modules.py (from rev 9153, csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py)
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg_run_modules.py	                        (rev 0)
+++ csw/mgar/gar/v2/bin/checkpkg_run_modules.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -0,0 +1,46 @@
+#!/opt/csw/bin/python2.6
+# $Id$
+
+"""This script runs all the checks written in Python."""
+
+import logging
+import os.path
+import sys
+import re
+
+CHECKPKG_MODULE_NAME = "Second checkpkg API version"
+
+# 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 main():
+  options, args = checkpkg.GetOptions()
+  if options.debug:
+    logging.basicConfig(level=logging.DEBUG)
+  else:
+    logging.basicConfig(level=logging.INFO)
+  md5sums = args
+  # CheckpkgManager2 class abstracts away things such as the collection of
+  # results.
+  check_manager = checkpkg.CheckpkgManager2(CHECKPKG_MODULE_NAME,
+                                            options.stats_basedir,
+                                            md5sums,
+                                            options.debug)
+  # Running the checks, reporting and exiting.
+  exit_code, screen_report, tags_report = check_manager.Run()
+  f = open(options.output, "w")
+  f.write(tags_report)
+  f.close()
+  if screen_report:
+    sys.stdout.write(screen_report)
+  sys.exit(exit_code)
+
+
+if __name__ == '__main__':
+  main()

Deleted: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -1,48 +0,0 @@
-#!/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
-
-CHECKPKG_MODULE_NAME = "Second checkpkg API version"
-
-# 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 main():
-  options, args = checkpkg.GetOptions()
-  if options.debug:
-    logging.basicConfig(level=logging.DEBUG)
-  else:
-    logging.basicConfig(level=logging.INFO)
-  md5sums = args
-  # CheckpkgManager2 class abstracts away things such as the collection of
-  # results.
-  check_manager = checkpkg.CheckpkgManager2(CHECKPKG_MODULE_NAME,
-                                            options.stats_basedir,
-                                            md5sums,
-                                            options.debug)
-  # Running the checks, reporting and exiting.
-  exit_code, screen_report, tags_report = check_manager.Run()
-  f = open(options.output, "w")
-  f.write(tags_report)
-  f.close()
-  print screen_report.strip()
-  sys.exit(exit_code)
-
-
-if __name__ == '__main__':
-  main()

Deleted: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -1,46 +0,0 @@
-#!/opt/csw/bin/python2.6
-# $Id$
-
-"""This is a dummy module. You can use it as a boilerplate for your own modules.
-
-Copy it and modify.
-"""
-
-import os.path
-import sys
-
-CHECKPKG_MODULE_NAME = "basic checks ported from Korn shell"
-
-# 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 package_checks_old
-
-def main():
-  options, args = checkpkg.GetOptions()
-  md5sums = args
-  # CheckpkgManager class abstracts away things such as the collection of
-  # results.
-  check_manager = checkpkg.CheckpkgManager(CHECKPKG_MODULE_NAME,
-                                           options.stats_basedir,
-                                           md5sums,
-                                           options.debug)
-  # Registering functions defined above.
-  check_manager.RegisterIndividualCheck(package_checks_old.FileNameSanity)
-  check_manager.RegisterIndividualCheck(package_checks_old.PkginfoSanity)
-  check_manager.RegisterIndividualCheck(package_checks_old.CheckBuildingUser)
-  check_manager.RegisterIndividualCheck(package_checks_old.CheckPkgmapPaths)
-  # Running the checks, reporting and exiting.
-  exit_code, screen_report, tags_report = check_manager.Run()
-  f = open(options.output, "w")
-  f.write(tags_report)
-  f.close()
-  print screen_report.strip()
-  sys.exit(exit_code)
-
-
-if __name__ == '__main__':
-  main()

Deleted: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-you-can-write-your-own.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-you-can-write-your-own.py	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-you-can-write-your-own.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -1,84 +0,0 @@
-#!/opt/csw/bin/python2.6
-# $Id$
-
-"""This is a dummy module. You can use it as a boilerplate for your own modules.
-
-Copy it and modify.
-"""
-
-import os.path
-import sys
-
-CHECKPKG_MODULE_NAME = "a template of a checkpkg module"
-
-# 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
-
-# Defining the checking functions.  They come in two flavors: individual
-# package checks and set checks.
-
-def MyCheckForAsinglePackage(pkg_data, debug):
-  """Checks an individual package.
-  
-  Gets a DirctoryFormatPackage as an argument, and returns a list of errors.
-
-  Errors should be a list of checkpkg.CheckpkgTag objects:
-  errors.append(checkpkg.CheckpkgTag(pkg.pkgname, "tag-name"))
-
-  You can also add a parameter:
-  errors.append(checkpkg.CheckpkgTag(pkg.pkgname, "tag-name", "/opt/csw/bin/problem"))
-  """
-  errors = []
-  # Checking code for an individual package goes here.  See the
-  # DirectoryFormatPackage class in lib/python/opencsw.py for the available
-  # APIs.
-
-  # Here's how to report an error:
-  something_is_wrong = False
-  if something_is_wrong:
-    errors.append(checkpkg.CheckpkgTag(
-      pkg_data["basic_stats"]["pkgname"],
-      "example-problem", "thing"))
-  return errors
-
-
-def MyCheckForAsetOfPackages(pkgs_data, debug):
-  """Checks a set of packages.
-
-  Sometimes individual checks aren't enough. If you need to write code which
-  needs to examine multiple packages at the same time, use this function.
-
-  Gets a list of packages, returns a list of errors.
-  """
-  errors = []
-  # Checking code goes here.
-  return errors
-
-
-def main():
-  options, args = checkpkg.GetOptions()
-  md5sums = args
-  # CheckpkgManager class abstracts away things such as the collection of
-  # results.
-  check_manager = checkpkg.CheckpkgManager(CHECKPKG_MODULE_NAME,
-                                           options.stats_basedir,
-                                           md5sums,
-                                           options.debug)
-  # Registering functions defined above.
-  check_manager.RegisterIndividualCheck(MyCheckForAsinglePackage)
-  check_manager.RegisterSetCheck(MyCheckForAsetOfPackages)
-  # Running the checks, reporting and exiting.
-  exit_code, screen_report, tags_report = check_manager.Run()
-  f = open(options.output, "w")
-  f.write(tags_report)
-  f.close()
-  print screen_report.strip()
-  sys.exit(exit_code)
-
-
-if __name__ == '__main__':
-  main()

Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -786,34 +786,6 @@
     return (exit_code, screen_report, tags_report)
 
 
-class CheckpkgManager(CheckpkgManagerBase):
-  """Takes care of calling checking functions.
-
-  This is an old API as of 2010-02-28.
-  """
-  def RegisterIndividualCheck(self, function):
-    self.individual_checks.append(function)
-
-  def RegisterSetCheck(self, function):
-    self.set_checks.append(function)
-
-  def GetAllTags(self, packages_data):
-    errors = {}
-    for pkg_data in packages_data:
-      for function in self.individual_checks:
-        all_stats = pkg_data.GetAllStats()
-        errors_for_pkg = function(all_stats, debug=self.debug)
-        if errors_for_pkg:
-          errors[all_stats["basic_stats"]["pkgname"]] = errors_for_pkg
-    # Set checks
-    for function in self.set_checks:
-      set_errors = function([x.GetAllStats() for x in packages_data],
-                            debug=self.debug)
-      if set_errors:
-        errors = self.SetErrorsToDict(set_errors, errors)
-    return errors
-
-
 class CheckInterfaceBase(object):
   """Base class for check proxies.
 

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -39,8 +39,16 @@
     },
 }
 ARCH_RE = re.compile(r"(sparcv(8|9)|i386|amd64)")
+MAX_CATALOGNAME_LENGTH = 20
+MAX_PKGNAME_LENGTH = 20
+ARCH_LIST = ["sparc", "i386", "all"]
+VERSION_RE = r".*,REV=(20[01][0-9]\.[0-9][0-9]\.[0-9][0-9]).*"
+ONLY_ALLOWED_IN_PKG = {
+    "CSWcommon": ("/opt", )
+}
 
 
+
 def CatalognameLowercase(pkg_data, error_mgr, logger):
   catalogname = pkg_data["basic_stats"]["catalogname"]
   if catalogname != catalogname.lower():
@@ -235,7 +243,9 @@
         "orphan_sonames": orphan_sonames,
     }
     t = Template.Template(checkpkg.REPORT_TMPL, searchList=[namespace])
-    print unicode(t)
+    report = unicode(t)
+    if report.strip():
+      print report
     for soname in orphan_sonames:
       error_mgr.ReportError(pkgname, "orphan-soname", soname)
     for missing_dep in missing_deps:
@@ -347,3 +357,143 @@
     logger.info("ARCHALL_%s = 1", pkgname)
     logger.info("However, be aware that there might be other reasons "
                 "to keep it architecture-specific.")
+
+def CheckFileNameSanity(pkg_data, error_mgr, logger):
+  basic_stats = pkg_data["basic_stats"]
+  revision_info = basic_stats["parsed_basename"]["revision_info"]
+  catalogname = pkg_data["basic_stats"]["catalogname"]
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  if "REV" not in revision_info:
+    error_mgr.ReportError("rev-tag-missing-in-filename")
+  if len(catalogname) > MAX_CATALOGNAME_LENGTH:
+    error_mgr.ReportError("catalogname-too-long")
+  if len(pkgname) > MAX_PKGNAME_LENGTH:
+    error_mgr.ReportError("pkgname-too-long")
+  if basic_stats["parsed_basename"]["osrel"] == "unspecified":
+    error_mgr.ReportError("osrel-tag-not-specified")
+
+
+def CheckPkginfoSanity(pkg_data, error_mgr, logger):
+  """pkginfo sanity checks.
+
+if [ "$maintname" = "" ] ; then
+  # the old format, in the DESC field
+  maintname=`sed -n 's/^DESC=.*for CSW by //p' $TMPFILE`
+
+  # Since the DESC field has been coopted, take
+  # description from second half of NAME field now.
+  desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
+else
+  if [ "$desc" = "" ] ; then
+    desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
+  fi
+fi
+
+software=`sed -n 's/^NAME=\([^ -]*\) -.*$/\1/p' $TMPFILE`
+version=`sed -n 's/^VERSION=//p' $TMPFILE`
+desc=`sed -n 's/^DESC=//p' $TMPFILE`
+email=`sed -n 's/^EMAIL=//p' $TMPFILE`
+maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
+hotline=`sed -n 's/^HOTLINE=//p' $TMPFILE`
+basedir=`sed -n 's/^BASEDIR=//p' $TMPFILE`
+pkgarch=`sed -n 's/^ARCH=//p' $TMPFILE|head -1`
+
+if [ "$software" = "" ] ; then errmsg $f: software field not set properly in NAME ; fi
+if [ "$pkgname" = "" ] ; then errmsg $f: pkgname field blank ; fi
+if [ "$desc" = "" ] ; then errmsg $f: no description in either NAME or DESC field ; fi
+if [ ${#desc} -gt 100 ] ; then errmsg $f: description greater than 100 chars ; fi
+if [ "$version" = "" ] ; then errmsg $f: VERSION field blank ;  fi
+if [ "$maintname" = "" ] ; then errmsg $f: maintainer name not detected. Fill out VENDOR field properly ; fi
+if [ "$email" = "" ] ; then errmsg $f: EMAIL field blank ; fi
+if [ "$hotline" = "" ] ; then errmsg $f: HOTLINE field blank ; fi
+  """
+  catalogname = pkg_data["basic_stats"]["catalogname"]
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  pkginfo = pkg_data["pkginfo"]
+  if not catalogname:
+    error_mgr.ReportError("pkginfo-empty-catalogname")
+  if not pkgname:
+    error_mgr.ReportError("pkginfo-empty-pkgname")
+  if not "VERSION" in pkginfo or not pkginfo["VERSION"]:
+    error_mgr.ReportError("pkginfo-version-field-missing")
+  # maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
+  maintname = checkpkg.ExtractMaintainerName(pkginfo)
+  if not maintname:
+    error_mgr.ReportError("pkginfo-maintainer-name-not-set")
+  # email
+  if not pkginfo["EMAIL"]:
+    error_mgr.ReportError("pkginfo-blank-email")
+  # 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")
+  if re.search(r"-", pkginfo["VERSION"]):
+    error_mgr.ReportError("pkginfo-minus-in-version")
+  if not re.match(VERSION_RE, pkginfo["VERSION"]):
+    msg = ("Version regex: %s, version value: %s."
+           % (repr(VERSION_RE), repr(pkginfo["VERSION"])))
+    error_mgr.ReportError("pkginfo-version-wrong-format", msg)
+  if pkginfo["ARCH"] not in ARCH_LIST:
+    error_mgr.ReportError("pkginfo-nonstandard-architecture", pkginfo["ARCH"])
+  if "PSTAMP" in pkginfo:
+    if not re.match(checkpkg.PSTAMP_RE, pkginfo["PSTAMP"]):
+      msg=("It should be 'username at hostname-timestamp', "
+           "but it's %s." % repr(pkginfo["PSTAMP"]))
+      error_mgr.ReportError("pkginfo-pstamp-in-wrong-format", pkginfo["PSTAMP"], msg)
+  else:
+    error_mgr.ReportError("pkginfo-pstamp-missing")
+
+
+def DisabledCheckMissingSymbols(pkgs_data, error_mgr, logger):
+  """Analyzes missing symbols reported by ldd -r.
+
+  1. Collect triplets: pkgname, binary, missing symbol
+  2. If there are any missing symbols, collect all the symbols that are provided
+     by the set of packages.
+  3. From the list of missing symbols, remove all symbols that are provided
+     by the set of packages.
+  4. Report any remaining symbols as errors.
+
+  What indexes do we need?
+
+  symbol -> (pkgname, binary)
+  set(allsymbols)
+  """
+  missing_symbols = []
+  all_symbols = set()
+  for pkg_data in pkgs_data:
+    pkgname = pkg_data["basic_stats"]["pkgname"]
+    binaries = pkg_data["binaries"]
+    for binary in binaries:
+      for ldd_elem in pkg_data["ldd_dash_r"][binary]:
+        if ldd_elem["state"] == "symbol-not-found":
+          missing_symbols.append((pkgname,
+                                  binary,
+                                  ldd_elem["symbol"]))
+      for symbol in pkg_data["defined_symbols"][binary]:
+        all_symbols.add(symbol)
+  # Remove symbols defined elsewhere.
+  while missing_symbols:
+    ms_pkgname, ms_binary, ms_symbol = missing_symbols.pop()
+    if ms_symbol not in all_symbols:
+      error_mgr.ReportError("symbol-not-found", "%s %s" % (ms_binary, ms_symbol))
+
+
+def CheckBuildingUser(pkg_data, error_mgr, logger):
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  username = checkpkg.ExtractBuildUsername(pkg_data["pkginfo"])
+  for entry in pkg_data["pkgmap"]:
+    if entry["user"] and entry["user"] == username:
+      error_mgr.ReportError("file-owned-by-building-user"
+                            "%s, %s" % (entry["path"], entry["user"]))
+
+
+def CheckPkgmapPaths(pkg_data, error_mgr, logger):
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  pkg_paths = set([x["path"] for x in pkg_data["pkgmap"]])
+  for allowed_pkgname in ONLY_ALLOWED_IN_PKG:
+    for disallowed_path in ONLY_ALLOWED_IN_PKG[allowed_pkgname]:
+      if disallowed_path in pkg_paths and pkgname != allowed_pkgname:
+        error_mgr.ReportError("disallowed-path", disallowed_path)

Deleted: csw/mgar/gar/v2/lib/python/package_checks_old.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_old.py	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/lib/python/package_checks_old.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -1,187 +0,0 @@
-#!/opt/csw/bin/python2.6
-# coding=utf-8
-# $Id$
-
-"""This module uses an old API.  Please do not add new checks here."""
-
-import checkpkg
-import re
-
-MAX_CATALOGNAME_LENGTH = 20
-MAX_PKGNAME_LENGTH = 20
-ARCH_LIST = ["sparc", "i386", "all"]
-VERSION_RE = r".*,REV=(20[01][0-9]\.[0-9][0-9]\.[0-9][0-9]).*"
-ONLY_ALLOWED_IN_PKG = {
-    "CSWcommon": ("/opt", "",)
-}
-
-def FileNameSanity(pkg_data, debug):
-  errors = []
-  basic_stats = pkg_data["basic_stats"]
-  revision_info = basic_stats["parsed_basename"]["revision_info"]
-  catalogname = pkg_data["basic_stats"]["catalogname"]
-  pkgname = pkg_data["basic_stats"]["pkgname"]
-  if "REV" not in revision_info:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "rev-tag-missing-in-filename"))
-  if len(catalogname) > MAX_CATALOGNAME_LENGTH:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "catalogname-too-long"))
-  if len(pkgname) > MAX_PKGNAME_LENGTH:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkgname-too-long"))
-  if basic_stats["parsed_basename"]["osrel"] == "unspecified":
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "osrel-tag-not-specified"))
-  return errors
-
-
-def PkginfoSanity(pkg_data, debug):
-  """pkginfo sanity checks.
-
-if [ "$maintname" = "" ] ; then
-  # the old format, in the DESC field
-  maintname=`sed -n 's/^DESC=.*for CSW by //p' $TMPFILE`
-
-  # Since the DESC field has been coopted, take
-  # description from second half of NAME field now.
-  desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
-else
-  if [ "$desc" = "" ] ; then
-    desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
-  fi
-fi
-
-software=`sed -n 's/^NAME=\([^ -]*\) -.*$/\1/p' $TMPFILE`
-version=`sed -n 's/^VERSION=//p' $TMPFILE`
-desc=`sed -n 's/^DESC=//p' $TMPFILE`
-email=`sed -n 's/^EMAIL=//p' $TMPFILE`
-maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
-hotline=`sed -n 's/^HOTLINE=//p' $TMPFILE`
-basedir=`sed -n 's/^BASEDIR=//p' $TMPFILE`
-pkgarch=`sed -n 's/^ARCH=//p' $TMPFILE|head -1`
-
-if [ "$software" = "" ] ; then errmsg $f: software field not set properly in NAME ; fi
-if [ "$pkgname" = "" ] ; then errmsg $f: pkgname field blank ; fi
-if [ "$desc" = "" ] ; then errmsg $f: no description in either NAME or DESC field ; fi
-if [ ${#desc} -gt 100 ] ; then errmsg $f: description greater than 100 chars ; fi
-if [ "$version" = "" ] ; then errmsg $f: VERSION field blank ;  fi
-if [ "$maintname" = "" ] ; then errmsg $f: maintainer name not detected. Fill out VENDOR field properly ; fi
-if [ "$email" = "" ] ; then errmsg $f: EMAIL field blank ; fi
-if [ "$hotline" = "" ] ; then errmsg $f: HOTLINE field blank ; fi
-  """
-  errors = []
-  catalogname = pkg_data["basic_stats"]["catalogname"]
-  pkgname = pkg_data["basic_stats"]["pkgname"]
-  pkginfo = pkg_data["pkginfo"]
-  if not catalogname:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "empty-catalogname"))
-  if not pkgname:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "empty-pkgname"))
-  if not "VERSION" in pkginfo or not pkginfo["VERSION"]:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkginfo-version-field-missing"))
-  # maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
-  maintname = checkpkg.ExtractMaintainerName(pkginfo)
-  if not maintname:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkginfo-maintainer-name-not-set"))
-  # email
-  if not pkginfo["EMAIL"]:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkginfo-blank-email"))
-  # hotline
-  if not pkginfo["HOTLINE"]:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkginfo-hotline-blank"))
-  pkginfo_version = pkg_data["basic_stats"]["parsed_basename"]["full_version_string"]
-  if pkginfo_version != pkginfo["VERSION"]:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "filename-version-does-not-match-pkginfo-version"))
-  if re.search(r"-", pkginfo["VERSION"]):
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkginfo-minus-in-version"))
-  if not re.match(VERSION_RE, pkginfo["VERSION"]):
-    msg = ("Version regex: %s, version value: %s."
-           % (repr(VERSION_RE), repr(pkginfo["VERSION"])))
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkginfo-version-wrong-format", msg=msg))
-  if pkginfo["ARCH"] not in ARCH_LIST:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkginfo-nonstandard-architecture", pkginfo["ARCH"]))
-  if "PSTAMP" in pkginfo:
-    if not re.match(checkpkg.PSTAMP_RE, pkginfo["PSTAMP"]):
-      errors.append(checkpkg.CheckpkgTag(
-        pkgname, "pkginfo-pstamp-in-wrong-format",
-        pkginfo["PSTAMP"],
-        msg=("It should be 'username at hostname-timestamp', "
-             "but it's %s." % repr(pkginfo["PSTAMP"]))))
-  else:
-    errors.append(checkpkg.CheckpkgTag(
-      pkgname, "pkginfo-pstamp-missing"))
-  return errors
-
-
-def CheckForMissingSymbols(pkgs_data, debug):
-  """Analyzes missing symbols reported by ldd -r.
-
-  1. Collect triplets: pkgname, binary, missing symbol
-  2. If there are any missing symbols, collect all the symbols that are provided
-     by the set of packages.
-  3. From the list of missing symbols, remove all symbols that are provided
-     by the set of packages.
-  4. Report any remaining symbols as errors.
-
-  What indexes do we need?
-
-  symbol -> (pkgname, binary)
-  set(allsymbols)
-  """
-  errors = []
-  missing_symbols = []
-  all_symbols = set()
-  for pkg_data in pkgs_data:
-    pkgname = pkg_data["basic_stats"]["pkgname"]
-    binaries = pkg_data["binaries"]
-    for binary in binaries:
-      for ldd_elem in pkg_data["ldd_dash_r"][binary]:
-        if ldd_elem["state"] == "symbol-not-found":
-          missing_symbols.append((pkgname,
-                                  binary,
-                                  ldd_elem["symbol"]))
-      for symbol in pkg_data["defined_symbols"][binary]:
-        all_symbols.add(symbol)
-  # Remove symbols defined elsewhere.
-  while missing_symbols:
-    ms_pkgname, ms_binary, ms_symbol = missing_symbols.pop()
-    if ms_symbol not in all_symbols:
-      errors.append(checkpkg.CheckpkgTag(
-        ms_pkgname, "symbol-not-found", "%s %s" % (ms_binary, ms_symbol)))
-  return errors
-
-
-def CheckBuildingUser(pkg_data, debug):
-  errors = []
-  pkgname = pkg_data["basic_stats"]["pkgname"]
-  username = checkpkg.ExtractBuildUsername(pkg_data["pkginfo"])
-  for entry in pkg_data["pkgmap"]:
-    if entry["user"] and entry["user"] == username:
-      errors.append(checkpkg.CheckpkgTag(
-        pkgname,
-        "file-owned-by-building-user",
-        "%s, %s" % (entry["path"], entry["user"])))
-  return errors
-
-def CheckPkgmapPaths(pkg_data, debug):
-  errors = []
-  username = checkpkg.ExtractBuildUsername(pkg_data["pkginfo"])
-  for entry in pkg_data["pkgmap"]:
-    file_path = entry["path"]
-    if file_path == "/opt":
-      errors.append(checkpkg.CheckpkgTag(
-        pkgname,
-        ("wrong-path-in-pkgmap", file_path)))
-  return errors
-

Deleted: csw/mgar/gar/v2/lib/python/package_checks_old_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_old_test.py	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/lib/python/package_checks_old_test.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -1,100 +0,0 @@
-#!/opt/csw/bin/python2.6
-# coding=utf-8
-# $Id$
-
-import unittest
-import package_checks_old as pc
-import yaml
-import os.path
-
-BASE_DIR = os.path.dirname(__file__)
-TESTDATA_DIR = os.path.join(BASE_DIR, "testdata")
-
-class PackageChecksUnitTest(unittest.TestCase):
-
-  def setUp(self):
-    self.pkg_data_1 = {
-          "basic_stats": {
-                "pkgname": "CSWfoo"
-        }
-    }
-    self.pkg_data_2 = {
-        'basic_stats': {
-          'parsed_basename':
-              {'revision_info': {'REV': '2010.02.15'},
-               'catalogname': 'python_tk',
-               'full_version_string': '2.6.4,REV=2010.02.15',
-               'version': '2.6.4',
-               'version_info': {
-                 'minor version': '6',
-                 'major version': '2',
-                 'patchlevel': '4'},
-               'osrel': 'SunOS5.8',
-               'arch': 'sparc',
-               'vendortag': 'CSW',
-              },
-          'pkgname': 'CSWpython-tk',
-          'stats_version': 1,
-          'pkg_basename': 'python_tk-2.6.4,REV=2010.02.15-SunOS5.8-sparc-CSW.pkg.gz',
-          'pkg_path': '/tmp/pkg_lL0HDH/python_tk-2.6.4,REV=2010.02.15-SunOS5.8-sparc-CSW.pkg.gz',
-          'catalogname': 'python_tk'}}
-
-  def LoadData(self, name):
-    file_name = os.path.join(TESTDATA_DIR, "%s.yml" % name)
-    f = open(file_name, "rb")
-    data = yaml.safe_load(f)
-    f.close()
-    return data
-
-  def testFileNameSanity(self):
-    del(self.pkg_data_2["basic_stats"]["parsed_basename"]["revision_info"]["REV"])
-    errors = pc.FileNameSanity(self.pkg_data_2, False)
-    self.failUnless(errors)
-
-  def testCheckForMissingSymbols(self):
-    ldd_dash_r_yml = """opt/csw/lib/postgresql/8.4/_int.so:
-- {path: /usr/lib/libc.so.1, soname: libc.so.1, state: OK, symbol: null}
-- {path: /usr/lib/libdl.so.1, soname: libdl.so.1, state: OK, symbol: null}
-- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
-  state: symbol-not-found, symbol: CurrentMemoryContext}
-- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
-  state: symbol-not-found, symbol: MemoryContextAlloc}
-- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
-  state: symbol-not-found, symbol: errstart}
-- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
-  state: symbol-not-found, symbol: errcode}
-opt/csw/lib/postgresql/8.4/_int2.so:
-- {path: /usr/lib/libdl.so.1, soname: libdl.so.1, state: OK, symbol: null}"""
-    defined_symbols_yml = """opt/csw/lib/postgresql/8.4/_int.so: [Pg_magic_func, _fini, _init, _int_contained,
-  _int_contains, _int_different, _int_inter, _int_overlap, _int_same, _int_union,
-  _int_unique, _intbig_in, _intbig_out, boolop, bqarr_in, bqarr_out, compASC, compDESC,
-  copy_intArrayType, execconsistent, g_int_compress, g_int_consistent, g_int_decompress,
-  g_int_penalty, g_int_picksplit, g_int_same, g_int_union, g_intbig_compress, g_intbig_consistent,
-  g_intbig_decompress, g_intbig_penalty, g_intbig_picksplit, g_intbig_same, g_intbig_union,
-  gensign, ginconsistent, ginint4_consistent, ginint4_queryextract, icount, idx, inner_int_contains,
-  inner_int_inter, inner_int_overlap, inner_int_union, int_to_intset, intarray_add_elem,
-  intarray_concat_arrays, intarray_del_elem, intarray_match_first, intarray_push_array,
-  intarray_push_elem, internal_size, intset, intset_subtract, intset_union_elem, isort,
-  new_intArrayType, pg_finfo__int_contained, pg_finfo__int_contains, pg_finfo__int_different,
-  pg_finfo__int_inter, pg_finfo__int_overlap, pg_finfo__int_same, pg_finfo__int_union,
-  pg_finfo__intbig_in, pg_finfo__intbig_out, pg_finfo_boolop, pg_finfo_bqarr_in, pg_finfo_bqarr_out,
-  pg_finfo_g_int_compress, pg_finfo_g_int_consistent, pg_finfo_g_int_decompress, pg_finfo_g_int_penalty,
-  pg_finfo_g_int_picksplit, pg_finfo_g_int_same, pg_finfo_g_int_union, pg_finfo_g_intbig_compress,
-  pg_finfo_g_intbig_consistent, pg_finfo_g_intbig_decompress, pg_finfo_g_intbig_penalty,
-  pg_finfo_g_intbig_picksplit, pg_finfo_g_intbig_same, pg_finfosc, subarray, uniq]
-opt/csw/lib/postgresql/8.4/adminpack.so: [Pg_magic_func, _fini, _init, pg_file_rename,
-  pg_file_unlink, pg_file_write, pg_finfo_pg_file_rename, pg_finfo_pg_file_unlink,
-  pg_finfo_pg_file_write, pg_finfo_pg_logdir_ls, pg_logdir_ls]
-opt/csw/lib/postgresql/8.4/_int2.so: []
-  """
-
-    self.pkg_data_2["ldd_dash_r"] = yaml.safe_load(ldd_dash_r_yml)
-    self.pkg_data_2["defined_symbols"] = yaml.safe_load(defined_symbols_yml)
-    self.pkg_data_2["binaries"] = ["opt/csw/lib/postgresql/8.4/_int.so",
-                                   "opt/csw/lib/postgresql/8.4/_int2.so"]
-    errors = pc.CheckForMissingSymbols([self.pkg_data_2], False)
-    self.failUnless(errors)
-
-
-if __name__ == '__main__':
-  unittest.main()

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-03-14 14:33:42 UTC (rev 9162)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-03-14 14:38:43 UTC (rev 9163)
@@ -191,6 +191,11 @@
     # self.failIf(errors)
     pass
 
+class TestCheckFileNameSanity(CheckpkgUnitTestHelper, unittest.TestCase):
+  FUNCTION_NAME = 'CheckFileNameSanity'
+  def CheckpkgTest(self):
+    del(self.pkg_data["basic_stats"]["parsed_basename"]["revision_info"]["REV"])
+    self.error_mgr_mock.ReportError('rev-tag-missing-in-filename')
 
 
 if __name__ == '__main__':


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