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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Oct 10 22:37:31 CEST 2010


Revision: 11222
          http://gar.svn.sourceforge.net/gar/?rev=11222&view=rev
Author:   wahwah
Date:     2010-10-10 20:37:31 +0000 (Sun, 10 Oct 2010)

Log Message:
-----------
mGAR v2: Added the non-uniform-lib-versions-in-package error tag.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/catalog.py
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/package_checks_test.py
    csw/mgar/gar/v2/lib/python/package_test.py
    csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py

Modified: csw/mgar/gar/v2/lib/python/catalog.py
===================================================================
--- csw/mgar/gar/v2/lib/python/catalog.py	2010-10-10 20:36:59 UTC (rev 11221)
+++ csw/mgar/gar/v2/lib/python/catalog.py	2010-10-10 20:37:31 UTC (rev 11222)
@@ -134,6 +134,3 @@
           logging.error("%s is missing the file_basename field", d)
         self.by_basename[d["file_basename"]] = d
     return self.by_basename
-
-
-

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-10-10 20:36:59 UTC (rev 11221)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-10-10 20:37:31 UTC (rev 11222)
@@ -987,6 +987,7 @@
 def CheckSharedLibraryNamingPolicy(pkg_data, error_mgr, logger, messenger):
   pkgname = pkg_data["basic_stats"]["pkgname"]
   shared_libs = set(su.GetSharedLibs(pkg_data))
+  linkable_shared_libs = []
   for binary_info in pkg_data["binaries_dump_info"]:
     if binary_info["path"] in shared_libs:
       if su.IsLibraryLinkable(binary_info["path"]):
@@ -995,27 +996,49 @@
           soname = binary_info["soname"]
         else:
           soname = os.path.split(binary_info["path"])[1]
-        tmp = su.MakePackageNameBySoname(soname)
-        policy_pkgname_list, policy_catalogname_list = tmp
-        if pkgname not in policy_pkgname_list:
-          error_mgr.ReportError(
-              "shared-lib-pkgname-mismatch",
-              "file=%s "
-              "soname=%s "
-              "pkgname=%s "
-              "expected=%s"
-              % (binary_info["path"], soname, pkgname, policy_pkgname_list))
-          messenger.OneTimeMessage(
-              soname,
-              "This shared library (%s) is in a directory indicating that it "
-              "is likely to be linked to by other programs.  If this is the "
-              "case, the library is best packaged separately, in a package "
-              "with a library-specific name.  Examples of such names include: "
-              "%s. If this library is not meant to be linked to by other "
-              "packages, it's best moved to a 'private' directory.  "
-              "For example, instead of /opt/csw/lib/foo.so, "
-              "try /opt/csw/lib/projectname/foo.so."
-              % (binary_info["path"], policy_pkgname_list))
+        linkable_shared_libs.append((soname, binary_info))
+  check_names = True
+  if len(linkable_shared_libs) > 1:
+    sonames = [x[0] for x in linkable_shared_libs]
+    multilib_pkgname = su.MakePackageNameBySonameCollection(sonames)
+    if not multilib_pkgname:
+      error_mgr.ReportError(
+          "non-uniform-lib-versions-in-package",
+          "sonames=%s"
+          % sorted(set(sonames)))
+      messenger.Message(
+          "Package %s contains shared libraries with sonames that "
+          "don't have compatible versions: %s.  This means that "
+          "they are best placed in own packages, with each package "
+          "named after library name and version. "
+          % (pkgname, sonames))
+      # If the sonames aren't uniform, there's no point in trying to match
+      # sonames versus pkgname.
+      check_names = False
+  if check_names:
+    for soname, binary_info in linkable_shared_libs:
+      tmp = su.MakePackageNameBySoname(soname)
+      policy_pkgname_list, policy_catalogname_list = tmp
+      if pkgname not in policy_pkgname_list:
+        error_mgr.ReportError(
+            "shared-lib-pkgname-mismatch",
+            "file=%s "
+            "soname=%s "
+            "pkgname=%s "
+            "expected=%s"
+            % (binary_info["path"], soname, pkgname, policy_pkgname_list))
+        messenger.OneTimeMessage(
+            soname,
+            "This shared library (%s) is in a directory indicating that it "
+            "is likely to be linked to by other programs.  If this is the "
+            "case, the library is best packaged separately, in a package "
+            "with a library-specific name.  Examples of such names include: "
+            "%s. If this library is not meant to be linked to by other "
+            "packages, it's best moved to a 'private' directory.  "
+            "For example, instead of /opt/csw/lib/foo.so, "
+            "try /opt/csw/lib/projectname/foo.so. "
+            "More information: http://wiki.opencsw.org/checkpkg-error-tags"
+            % (binary_info["path"], policy_pkgname_list))
 
 
 

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-10-10 20:36:59 UTC (rev 11221)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-10-10 20:37:31 UTC (rev 11222)
@@ -1,4 +1,4 @@
-#!/opt/csw/bin/python2.6
+#!/usr/bin/env python2.6
 # coding=utf-8
 # $Id$
 
@@ -1319,29 +1319,8 @@
   def CheckpkgTest(self):
     self.pkg_data = neon_stats[0]
     self.error_mgr_mock.ReportError(
-        'shared-lib-pkgname-mismatch',
-        "file=opt/csw/lib/libneon.so.26.0.4 "
-        "soname=libneon.so.26 "
-        "pkgname=CSWneon "
-        "expected=['CSWlibneon26', 'CSWlibneon-26']")
-    self.error_mgr_mock.ReportError(
-        'shared-lib-pkgname-mismatch',
-        "file=opt/csw/lib/libneon.so.27.2.0 "
-        "soname=libneon.so.27 "
-        "pkgname=CSWneon "
-        "expected=['CSWlibneon27', 'CSWlibneon-27']")
-    self.error_mgr_mock.ReportError(
-        'shared-lib-pkgname-mismatch',
-        "file=opt/csw/lib/sparcv9/libneon.so.26.0.4 "
-        "soname=libneon.so.26 "
-        "pkgname=CSWneon "
-        "expected=['CSWlibneon26', 'CSWlibneon-26']")
-    self.error_mgr_mock.ReportError(
-        'shared-lib-pkgname-mismatch',
-        "file=opt/csw/lib/sparcv9/libneon.so.27.2.0 "
-        "soname=libneon.so.27 "
-        "pkgname=CSWneon "
-        "expected=['CSWlibneon27', 'CSWlibneon-27']")
+        'non-uniform-lib-versions-in-package',
+        "sonames=['libneon.so.26', 'libneon.so.27']")
 
 
 class TestCheckSharedLibraryPkgDoesNotHaveTheSoFile(CheckpkgUnitTestHelper, unittest.TestCase):

Modified: csw/mgar/gar/v2/lib/python/package_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_test.py	2010-10-10 20:36:59 UTC (rev 11221)
+++ csw/mgar/gar/v2/lib/python/package_test.py	2010-10-10 20:37:31 UTC (rev 11222)
@@ -4,4 +4,3 @@
 
 if __name__ == '__main__':
   unittest.main()
-

Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py	2010-10-10 20:36:59 UTC (rev 11221)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py	2010-10-10 20:37:31 UTC (rev 11222)
@@ -160,6 +160,14 @@
     )
     self.assertEqual(expected, su.MakePackageNameBySonameCollection(sonames))
 
+  def testMakePackageNameBySonameCollectionRepeated(self):
+    sonames = ["libfoo.so.0", "libfoo.so.0"]
+    expected = (
+        ["CSWlibfoo0", "CSWlibfoo-0"],
+        ["libfoo0", "libfoo_0"],
+    )
+    self.assertEqual(expected, su.MakePackageNameBySonameCollection(sonames))
+
   def testMakePackageNameBySonameCollectionBdb(self):
     sonames = ["libfoo.so.0", "libfoo_util.so.0"]
     expected = (


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