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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Mar 26 09:42:10 CET 2010


Revision: 9379
          http://gar.svn.sourceforge.net/gar/?rev=9379&view=rev
Author:   wahwah
Date:     2010-03-26 08:42:10 +0000 (Fri, 26 Mar 2010)

Log Message:
-----------
mGAR v2: checkpkg, check symbols for Perl modules.

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

Removed Paths:
-------------
    csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-missing-symbols.py

Deleted: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-missing-symbols.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-missing-symbols.py	2010-03-26 08:42:03 UTC (rev 9378)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-missing-symbols.py	2010-03-26 08:42:10 UTC (rev 9379)
@@ -1,47 +0,0 @@
-#!/opt/csw/bin/python2.6
-# $Id$
-
-"""Check for missing symbols in binaries.
-
-http://sourceforge.net/tracker/?func=detail&aid=2939416&group_id=229205&atid=1075770
-"""
-
-import os.path
-import re
-import sys
-import subprocess
-
-CHECKPKG_MODULE_NAME = "missing symbols"
-
-# 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
-
-# Defining checking functions.
-
-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.RegisterSetCheck(package_checks_old.CheckForMissingSymbols)
-  # 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-26 08:42:03 UTC (rev 9378)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py	2010-03-26 08:42:10 UTC (rev 9379)
@@ -24,7 +24,7 @@
 import package_checks
 
 DB_SCHEMA_VERSION = 2L
-PACKAGE_STATS_VERSION = 4L
+PACKAGE_STATS_VERSION = 5L
 SYSTEM_PKGMAP = "/var/sadm/install/contents"
 WS_RE = re.compile(r"\s+")
 NEEDED_SONAMES = "needed sonames"
@@ -952,7 +952,7 @@
       # "defined_symbols",
       "depends",
       "isalist",
-      # "ldd_dash_r",
+      "ldd_dash_r",
       "overrides",
       "pkgchk",
       "pkginfo",
@@ -1193,9 +1193,10 @@
     self.DumpObject(self.GetPkgchkData(), "pkgchk")
     self.DumpObject(dir_pkg.GetParsedPkginfo(), "pkginfo")
     self.DumpObject(dir_pkg.GetPkgmap().entries, "pkgmap")
+    # To be used with Perl modules
+    self.DumpObject(self.GetLddMinusRlines(), "ldd_dash_r")
     # This check is currently disabled, let's save time by not collecting
     # these data.
-    # self.DumpObject(self.GetLddMinusRlines(), "ldd_dash_r")
     # self.DumpObject(self.GetDefinedSymbols(), "defined_symbols")
     self.DumpObject(dir_pkg.GetFilesContaining(BAD_CONTENT_REGEXES), "bad_paths")
     logging.debug("Statistics of %s have been collected.", repr(dir_pkg.pkgname))

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-03-26 08:42:03 UTC (rev 9378)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-03-26 08:42:10 UTC (rev 9379)
@@ -57,6 +57,8 @@
     r'/opt/csw/lib/$$ISALIST',
     r'/opt/csw/lib/SALIST',
 ]
+# Check ldd -r only for Perl modules
+SYMBOLS_CHECK_ONLY_FOR = r"^CSWpm.*$"
 
 
 def CatalognameLowercase(pkg_data, error_mgr, logger):
@@ -534,3 +536,60 @@
         error_mgr.ReportError("bad-rpath-entry",
                               "%s %s" % (binary_info["path"], actual_rpath))
 
+
+def DisabledCheckForMissingSymbols(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 CheckForMissingSymbolsDumb(pkg_data, error_mgr, logger):
+  """Analyzes missing symbols reported by ldd -r.
+
+  Only makes sense for perl modules.
+  """
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  if not re.match(SYMBOLS_CHECK_ONLY_FOR, pkgname):
+    return
+  found = False
+  for binary_info in pkg_data["binaries_dump_info"]:
+    for ldd_elem in pkg_data["ldd_dash_r"][binary_info["path"]]:
+      if ldd_elem["state"] == "symbol-not-found":
+        error_mgr.ReportError("symbol-not-found",
+                              "e.g. %s misses %s" % (binary_info["path"], ldd_elem["symbol"]))
+        found = True
+        break
+    if found:
+      break


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