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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Thu Dec 16 11:32:52 CET 2010


Revision: 11963
          http://gar.svn.sourceforge.net/gar/?rev=11963&view=rev
Author:   wahwah
Date:     2010-12-16 10:32:52 +0000 (Thu, 16 Dec 2010)

Log Message:
-----------
checkpkg: Use baseisadirs when suggesting splits

Fixes #42: checkpkg should suggest using 'baseisadirs'

There is a still, in my opinion, unresolved issue, of what to do in cases
where libraries aren't in /opt/csw/lib.  I'll leave it for now and make
improvements later.

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

Modified: csw/mgar/gar/v2/lib/python/dependency_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/dependency_checks.py	2010-12-15 23:29:18 UTC (rev 11962)
+++ csw/mgar/gar/v2/lib/python/dependency_checks.py	2010-12-16 10:32:52 UTC (rev 11963)
@@ -4,6 +4,7 @@
 import os.path
 import re
 import ldd_emul
+import sharedlib_utils
 
 # This shared library is present on Solaris 10 on amd64, but it's missing on
 # Solaris 8 on i386.  It's okay if it's missing.
@@ -254,3 +255,34 @@
     if not dependency_fulfilled:
       missing_dep_groups.append(pkgnames)
   return missing_dep_groups
+
+def SuggestLibraryPackage(error_mgr, messenger,
+    pkgname, catalogname,
+    description,
+    lib_path, lib_basename, soname):
+  escaped_soname = sharedlib_utils.EscapeRegex(soname)
+  escaped_basename = sharedlib_utils.EscapeRegex(lib_basename)
+  messenger.SuggestGarLine("# The following lines define a new package: "
+                           "%s" % pkgname)
+  messenger.SuggestGarLine("PACKAGES += %s" % pkgname)
+  messenger.SuggestGarLine(
+      "CATALOGNAME_%s = %s"
+      % (pkgname, catalogname))
+  # The exact library file (which can be different from what soname suggests)
+  messenger.SuggestGarLine(
+      r'PKGFILES_%s += '
+      r'$(call baseisadirs,$(libdir),%s)'
+      % (pkgname, escaped_basename))
+  # Name regex based on the soname, plus potential symlinks
+  messenger.SuggestGarLine(
+      r'PKGFILES_%s += '
+      r'$(call baseisadirs,$(libdir),%s(\.\d+)*)'
+      % (pkgname, escaped_soname))
+  messenger.SuggestGarLine(
+      "SPKG_DESC_%s += %s, %s"
+      % (pkgname, description, soname))
+  messenger.SuggestGarLine(
+      "RUNTIME_DEP_PKGS_%s += %s"
+      % (pkgname, pkgname))
+  messenger.SuggestGarLine(
+      "# The end of %s definition" % pkgname)

Modified: csw/mgar/gar/v2/lib/python/dependency_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/dependency_checks_test.py	2010-12-15 23:29:18 UTC (rev 11962)
+++ csw/mgar/gar/v2/lib/python/dependency_checks_test.py	2010-12-16 10:32:52 UTC (rev 11963)
@@ -354,5 +354,47 @@
        "e.g. '/opt/csw/apache2/bin/foo'")]]
     self.assertEqual(expected, result)
 
+
+class SuggestLibraryPackage(mox.MoxTestBase):
+
+  def testBasic(self):
+    error_mgr_mock = self.mox.CreateMock(
+        checkpkg_lib.IndividualCheckInterface)
+    messenger_mock = self.mox.CreateMock(
+        checkpkg_lib.CheckpkgMessenger)
+    pkgname = "CSWfoo-bar"
+    catalogname = "foo_bar"
+    description = "A foo bar package"
+    # TODO: What if the path is different?
+    lib_path = "opt/csw/lib"
+    lib_basename = "libfoo.so.1.2.3"
+    lib_soname = "libfoo.so.1"
+    messenger_mock.SuggestGarLine(
+        r'# The following lines define a new package: CSWfoo-bar')
+    messenger_mock.SuggestGarLine(
+        r'PACKAGES += CSWfoo-bar')
+    messenger_mock.SuggestGarLine(
+        r'CATALOGNAME_CSWfoo-bar = foo_bar')
+    messenger_mock.SuggestGarLine(
+        r'PKGFILES_CSWfoo-bar += '
+        r'$(call baseisadirs,$(libdir),libfoo\.so\.1\.2\.3)')
+    messenger_mock.SuggestGarLine(
+        r'PKGFILES_CSWfoo-bar += '
+        r'$(call baseisadirs,$(libdir),libfoo\.so\.1(\.\d+)*)')
+    messenger_mock.SuggestGarLine(
+        'SPKG_DESC_CSWfoo-bar += A foo bar package, libfoo.so.1')
+    messenger_mock.SuggestGarLine(
+        r'RUNTIME_DEP_PKGS_CSWfoo-bar += CSWfoo-bar')
+    messenger_mock.SuggestGarLine(
+        r'# The end of CSWfoo-bar definition')
+    self.mox.ReplayAll()
+    dependency_checks.SuggestLibraryPackage(
+        error_mgr_mock,
+        messenger_mock,
+        pkgname, catalogname,
+        description,
+        lib_path, lib_basename, lib_soname)
+
+
 if __name__ == '__main__':
   unittest.main()

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-12-15 23:29:18 UTC (rev 11962)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-12-16 10:32:52 UTC (rev 11963)
@@ -1083,28 +1083,13 @@
         lib_path, lib_basename = os.path.split(binary_info["path"])
         tmp = su.MakePackageNameBySoname(soname)
         policy_pkgname_list, policy_catalogname_list = tmp
-        messenger.SuggestGarLine("# The following lines define a new package: "
-                                 "%s" % policy_pkgname_list[0])
-        messenger.SuggestGarLine("PACKAGES += %s" % policy_pkgname_list[0])
-        messenger.SuggestGarLine(
-            "CATALOGNAME_%s = %s"
-            % (policy_pkgname_list[0], policy_catalogname_list[0]))
-        messenger.SuggestGarLine(
-            "PKGFILES_%s += /%s"
-            % (policy_pkgname_list[0], os.path.join(lib_path, lib_basename)))
-        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]))
-        messenger.SuggestGarLine(
-            "# The end of %s definition" % policy_pkgname_list[0])
+        depchecks.SuggestLibraryPackage(error_mgr, messenger,
+          policy_pkgname_list[0],
+          policy_catalogname_list[0],
+          description,
+          lib_path, lib_basename, soname)
 
       check_names = False
     else:
@@ -1137,17 +1122,17 @@
             % (binary_info["path"],
                soname, pkgname,
                ",".join(policy_pkgname_list)))
+
         suggested_pkgname = policy_pkgname_list[0]
-        messenger.SuggestGarLine(
-            "PACKAGES += %s" % suggested_pkgname)
-        messenger.SuggestGarLine(
-            "CATALOGNAME_%s = %s"
-            % (suggested_pkgname, policy_catalogname_list[0]))
-        messenger.SuggestGarLine(
-            "PKGFILES_%s += /%s" % (suggested_pkgname, binary_info["path"]))
-        lib_basename, lib_filename = os.path.split(binary_info["path"])
-        messenger.SuggestGarLine(
-            "PKGFILES_%s += /%s/%s.*" % (suggested_pkgname, lib_basename, soname))
+        lib_path, lib_basename = os.path.split(binary_info["path"])
+        pkginfo = pkg_data["pkginfo"]
+        description = " ".join(pkginfo["NAME"].split(" ")[2:])
+        depchecks.SuggestLibraryPackage(error_mgr, messenger,
+          suggested_pkgname,
+          policy_catalogname_list[0],
+          description,
+          lib_path, lib_basename, soname)
+
         messenger.OneTimeMessage(
             soname,
             "This shared library (%s) is in a directory indicating that it "

Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils.py	2010-12-15 23:29:18 UTC (rev 11962)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils.py	2010-12-16 10:32:52 UTC (rev 11963)
@@ -272,3 +272,9 @@
 def GetIsalist(str_arch):
   arch = ArchByString(str_arch)
   return common_constants.ISALISTS_BY_ARCH[arch]
+
+
+def EscapeRegex(s):
+  """Needs to be improved to escape more characters."""
+  s = s.replace(r'.', r'\.')
+  return s


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