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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Oct 15 01:47:41 CEST 2010


Revision: 11302
          http://gar.svn.sourceforge.net/gar/?rev=11302&view=rev
Author:   wahwah
Date:     2010-10-14 23:47:41 +0000 (Thu, 14 Oct 2010)

Log Message:
-----------
mGAR v2: checkpkg, better handling of shared library policy wrt sonames such as libnspr4.so.

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

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-10-14 23:07:54 UTC (rev 11301)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-10-14 23:47:41 UTC (rev 11302)
@@ -999,34 +999,35 @@
         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:
+    sonames = sorted(set([x[0] for x in linkable_shared_libs]))
+    tmp = su.MakePackageNameBySonameCollection(sonames)
+    multilib_pkgnames, multilib_catalogname = tmp
+    if not multilib_pkgnames:
       error_mgr.ReportError(
           "non-uniform-lib-versions-in-package",
           "sonames=%s"
-          % sorted(set(sonames)))
+          % (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, sorted(set(sonames))))
+          "Package %s contains shared libraries, and their soname "
+          "versions are not in sync: %s.  This means that "
+          "each soname is likely to be retired at a different time "
+          "and each soname is best placed in a separate package, "
+          "named after soname and version. "
+          % (pkgname, sonames))
       # If the sonames aren't uniform, there's no point in trying to match
       # sonames versus pkgname.
+      messenger.SuggestGarLine(
+          "# Suggesting how to separate out shared libraries.")
+      messenger.SuggestGarLine(
+          "# You will most probably need to further edit these lines. "
+          "Use with caution!")
       for soname, binary_info in linkable_shared_libs:
         lib_path, lib_basename = os.path.split(binary_info["path"])
-        messenger.SuggestGarLine(
-            "# Suggesting how to separate out %s"
-            % soname)
-        messenger.SuggestGarLine(
-            "# You will most probably need to further edit these lines. "
-            "Use with caution!")
         tmp = su.MakePackageNameBySoname(soname)
         policy_pkgname_list, policy_catalogname_list = tmp
         messenger.SuggestGarLine("PACKAGES += %s" % policy_pkgname_list[0])
         messenger.SuggestGarLine(
-            "CATALOGNAME_%s += %s"
+            "CATALOGNAME_%s = %s"
             % (policy_pkgname_list[0], policy_catalogname_list[0]))
         messenger.SuggestGarLine(
             "PKGFILES_%s += /%s"
@@ -1034,26 +1035,31 @@
         messenger.SuggestGarLine(
             "PKGFILES_%s += /%s\.[0-9\.]+"
             % (policy_pkgname_list[0], os.path.join(lib_path, soname)))
+        pkginfo = pkg_data["pkginfo"]
+        description = " ".join(pkginfo["NAME"].split(" ")[2:])
         messenger.SuggestGarLine(
+            "SPKG_DESC_%s += %s, %s"
+            % (policy_pkgname_list[0], description, soname))
+        messenger.SuggestGarLine(
             "RUNTIME_DEP_PKGS_%s += %s"
             % (pkgname, policy_pkgname_list[0]))
 
       check_names = False
     else:
-      if multilib_pkgname != pkgname:
+      if pkgname not in multilib_pkgnames:
         error_mgr.ReportError(
             "shared-lib-pkgname-mismatch",
             "sonames=%s "
             "pkgname=%s "
             "expected=%s "
-            % (sorted(set(sonames)), pkgname, multilib_pkgname))
+            % (sonames, pkgname, multilib_pkgnames))
         messenger.Message(
             "The collection of sonames (%s) "
             "is expected to be in package "
             "named %s, but the package name is %s. "
             "More information: "
             "http://wiki.opencsw.org/checkpkg-error-tags"
-            % (sonames, multilib_pkgname, pkgname))
+            % (sonames, multilib_pkgnames, pkgname))
         check_names = False
   if check_names:
     for soname, binary_info in linkable_shared_libs:

Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils.py	2010-10-14 23:07:54 UTC (rev 11301)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils.py	2010-10-14 23:47:41 UTC (rev 11302)
@@ -4,6 +4,7 @@
 import re
 import os.path
 
+
 SPARCV8_PATHS = ('sparcv8', 'sparcv8-fsmuld',
                  'sparcv7', 'sparc')
 SPARCV8PLUS_PATHS = ('sparcv8plus+vis2', 'sparcv8plus+vis', 'sparcv8plus')
@@ -15,9 +16,11 @@
 LEGIT_CHAR_RE = re.compile(r"[a-zA-Z0-9\+]+")
 SONAME_VERSION_RE = re.compile("^(?P<name>.*)\.so\.(?P<version>[\d\.]+)$")
 
+
 class SonameParsingException(Exception):
   pass
 
+
 def IsLibraryLinkable(file_path):
   arch_subdirs = (SPARCV8_PATHS + SPARCV8PLUS_PATHS + SPARCV9_PATHS
                   + INTEL_386_PATHS + AMD64_PATHS)
@@ -107,11 +110,13 @@
     m = SONAME_VERSION_RE.search(soname)
     if m:
       versions.append(m.groupdict()["version"])
+    else:
+      versions.append("")
   versions_set = set(versions)
   if len(versions_set) > 1 or not versions_set:
-    return None
+    return (False, None)
   else:
-    return versions_set.pop()
+    return (True, versions_set.pop())
 
 
 def MakePackageNameBySonameCollection(sonames):
@@ -120,8 +125,8 @@
   Try to find the largest common prefix in the sonames, and establish
   whether there is a common version to them.
   """
-  common_version = GetCommonVersion(sonames)
-  if not common_version:
+  common_version_exists, common_version = GetCommonVersion(sonames)
+  if not common_version_exists:
     # If the sonames don't have a common version, they shouldn't be together
     # in one package.
     return None
@@ -139,12 +144,16 @@
   lcs = CollectionLongestCommonSubstring(copy.copy(common_substring_candidates))
   pkgnames = [
       "CSW" + SanitizeWithChar("lib%s%s" % (lcs, common_version), "-"),
-      "CSW" + SanitizeWithChar("lib%s-%s" % (lcs, common_version), "-"),
   ]
+  dashed = "CSW" + SanitizeWithChar("lib%s-%s" % (lcs, common_version), "-")
+  if dashed not in pkgnames:
+    pkgnames.append(dashed)
   catalognames = [
       SanitizeWithChar("lib%s%s" % (lcs, common_version), "_"),
-      SanitizeWithChar("lib%s_%s" % (lcs, common_version), "_"),
   ]
+  underscored = SanitizeWithChar("lib%s_%s" % (lcs, common_version), "_")
+  if underscored not in catalognames:
+    catalognames.append(underscored)
   return pkgnames, catalognames
 
 

Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py	2010-10-14 23:07:54 UTC (rev 11301)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils_test.py	2010-10-14 23:47:41 UTC (rev 11302)
@@ -157,17 +157,21 @@
 
   def testGetCommonVersionSimple(self):
     sonames = ["libfoo.so.0", "libfoo_util.so.0"]
-    self.assertEqual("0", su.GetCommonVersion(sonames))
+    self.assertEqual((True, "0"), su.GetCommonVersion(sonames))
 
   def testGetCommonVersionMore(self):
     sonames = ["libfoo.so.0.2.1", "libfoo_util.so.0.2.1"]
-    self.assertEqual("0.2.1", su.GetCommonVersion(sonames))
+    self.assertEqual((True, "0.2.1"), su.GetCommonVersion(sonames))
 
   def testGetCommonVersionInvalid(self):
     sonames = ["libfoo.so.0.2.1", "libfoo_util.so.0.2.3"]
-    self.assertEqual(None, su.GetCommonVersion(sonames))
+    self.assertEqual((False, None), su.GetCommonVersion(sonames))
 
+  def testGetCommonVersionEndsWithSo(self):
+    sonames = ["libfoo1.so", "libfoo1.so"]
+    self.assertEqual((True, ""), su.GetCommonVersion(sonames))
 
+
 class MakePackageNameBySonameCollectionUnitTest(unittest.TestCase):
 
   def testMakePackageNameBySonameCollectionTwo(self):
@@ -198,7 +202,15 @@
     sonames = ["libfoo.so.0", "libfoo_util.so.1"]
     self.assertEqual(None, su.MakePackageNameBySonameCollection(sonames))
 
+  def testMakePackageNameBySonameCollectionMultipleSo(self):
+    sonames = ["libfoo1.so", "libfoo1.so"]
+    expected = (
+        ["CSWlibfoo1"],
+        ["libfoo1"],
+    )
+    self.assertEqual(expected, su.MakePackageNameBySonameCollection(sonames))
 
+
 class CommomSubstringTest(unittest.TestCase):
 
   def testLongestCommonSubstring_1(self):


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