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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sat Jun 26 15:54:37 CEST 2010


Revision: 10338
          http://gar.svn.sourceforge.net/gar/?rev=10338&view=rev
Author:   wahwah
Date:     2010-06-26 13:54:37 +0000 (Sat, 26 Jun 2010)

Log Message:
-----------
mGAR v2: checkpkg, emulating deinstallation of packages prior to installation, fixes a problem with CSWrrd that Dago recently saw.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/dependency_checks.py
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/package_checks_test.py
    csw/mgar/pkg/rrdtool/branches/x11-reloaded/Makefile

Modified: csw/mgar/gar/v2/lib/python/dependency_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/dependency_checks.py	2010-06-26 02:05:49 UTC (rev 10337)
+++ csw/mgar/gar/v2/lib/python/dependency_checks.py	2010-06-26 13:54:37 UTC (rev 10338)
@@ -17,7 +17,7 @@
 
 def Libraries(pkg_data, error_mgr, logger, path_and_pkg_by_soname):
   pkgname = pkg_data["basic_stats"]["pkgname"]
-  logger.debug("Package %s", pkgname)
+  logger.debug("Libraries(): pkgname = %s", repr(pkgname))
   orphan_sonames = []
   required_deps = []
   isalist = pkg_data["isalist"]
@@ -26,26 +26,33 @@
       resolved = False
       path_list = path_and_pkg_by_soname[soname].keys()
       logger.debug("%s @ %s: looking for %s in %s",
-                   soname, binary_info["path"], binary_info["runpath"], path_list)
+                   soname,
+                   binary_info["path"],
+                   binary_info["runpath"],
+                   path_list)
       runpath_list = binary_info["runpath"] + checkpkg.SYS_DEFAULT_RUNPATH
       for runpath in runpath_list:
-        resolved_path = checkpkg.ResolveSoname(runpath, soname, isalist, path_list)
+        resolved_path = checkpkg.ResolveSoname(runpath,
+                                               soname,
+                                               isalist,
+                                               path_list)
         if resolved_path:
           logger.debug("%s needed by %s:",
                  soname, binary_info["path"])
-          # print "%s => %s" % (binary_info["runpath"], resolved_path)
           logger.debug("=> %s provided by %s",
               resolved_path, path_and_pkg_by_soname[soname][resolved_path])
           resolved = True
           req_pkg = path_and_pkg_by_soname[soname][resolved_path][-1]
-          reason = "provides %s/%s needed by %s" % (resolved_path, soname, binary_info["path"])
+          reason = ("provides %s/%s needed by %s"
+                    % (resolved_path, soname, binary_info["path"]))
           for bad_path, bad_soname, msg in DEPRECATED_LIBRARY_LOCATIONS:
             if resolved_path == bad_path and soname == bad_soname:
               logger.debug("Bad lib found: %s/%s", bad_path, bad_soname)
               error_mgr.ReportError(
                   pkgname,
                   "deprecated-library",
-                  "%s %s %s/%s" % (binary_info["path"], msg, resolved_path, soname))
+                  ("%s %s %s/%s"
+                   % (binary_info["path"], msg, resolved_path, soname)))
           required_deps.append((req_pkg, reason))
           break
       if not resolved:

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-06-26 02:05:49 UTC (rev 10337)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-06-26 13:54:37 UTC (rev 10338)
@@ -181,6 +181,28 @@
           entry["path"])
 
 
+def RemovePackagesUnderInstallation(paths_and_pkgs_by_soname,
+                                    pkgs_to_be_installed):
+  """Emulates uninstallation of packages prior to installation
+  of the new ones.
+  {'libfoo.so.1': {u'/opt/csw/lib': [u'CSWlibfoo']}}
+  """
+  # for brevity
+  ptbi = set(pkgs_to_be_installed)
+  ppbs = paths_and_pkgs_by_soname
+  new_ppbs = {}
+  for soname in ppbs:
+    if soname not in new_ppbs:
+      new_ppbs[soname] = {}
+    for binary_path in ppbs[soname]:
+      for pkgname in ppbs[soname][binary_path]:
+        if pkgname not in ptbi:
+          if binary_path not in new_ppbs[soname]:
+            new_ppbs[soname][binary_path] = []
+          new_ppbs[soname][binary_path].append(pkgname)
+  return new_ppbs
+
+
 def SetCheckLibraries(pkgs_data, error_mgr, logger, messenger):
   """Second version of the library checking code.
 
@@ -193,6 +215,7 @@
      3.1. Resolve all NEEDED sonames
   """
   needed_sonames = []
+  pkgs_to_be_installed = [x["basic_stats"]["pkgname"] for x in pkgs_data]
   for pkg_data in pkgs_data:
     for binary_info in pkg_data["binaries_dump_info"]:
       needed_sonames.extend(binary_info["needed sonames"])
@@ -202,8 +225,11 @@
   for needed_soname in needed_sonames:
     path_and_pkg_by_soname[needed_soname] = error_mgr.GetPathsAndPkgnamesByBasename(
         needed_soname)
+  # Removing files from packages that are to be installed.
+  path_and_pkg_by_soname = RemovePackagesUnderInstallation(
+      path_and_pkg_by_soname, pkgs_to_be_installed)
   # Adding overlay based on the given package set
-  # TODO: Emulate package removal
+  # Considering files from the set under examination.
   for pkg_data in pkgs_data:
     pkgname = pkg_data["basic_stats"]["pkgname"]
     for binary_info in pkg_data["binaries_dump_info"]:

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-06-26 02:05:49 UTC (rev 10337)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-06-26 13:54:37 UTC (rev 10338)
@@ -23,6 +23,7 @@
 DEFAULT_PKG_STATS = checkpkg.PackageStats(None, CHECKPKG_STATS_DIR, DEFAULT_DATA_MD5)
 DEFAULT_PKG_DATA = DEFAULT_PKG_STATS.GetAllStats()
 
+
 class CheckpkgUnitTestHelper(object):
   """Wraps common components of checkpkg tests."""
 
@@ -281,7 +282,8 @@
     # self.error_mgr_mock.ReportError('linked-against-discouraged-library',
     #                                 'libImlib2.so.1.4.2 libX11.so.4')
 
-class TestSetCheckSharedLibraryConsistency2_1(CheckpkgUnitTestHelper, unittest.TestCase):
+class TestSetCheckSharedLibraryConsistency2_1(CheckpkgUnitTestHelper,
+                                              unittest.TestCase):
   FUNCTION_NAME = 'SetCheckLibraries'
   def CheckpkgTest(self):
     self.pkg_data = [td_1.pkg_data]
@@ -451,6 +453,76 @@
     self.pkg_data = [self.pkg_data]
 
 
+class TestRemovePackagesUnderInstallation(unittest.TestCase):
+
+  def testRemoveNone(self):
+    paths_and_pkgs_by_soname = {
+        'libfoo.so.1': {u'/opt/csw/lib': [u'CSWlibfoo']}}
+    packages_to_be_installed = [u'CSWbar']
+    self.assertEqual(
+        paths_and_pkgs_by_soname,
+        pc.RemovePackagesUnderInstallation(paths_and_pkgs_by_soname,
+                                           packages_to_be_installed))
+
+  def testRemoveOne(self):
+    paths_and_pkgs_by_soname = {
+        'libfoo.so.1': {u'/opt/csw/lib': [u'CSWlibfoo']}}
+    packages_to_be_installed = [u'CSWlibfoo']
+    self.assertEqual(
+        {'libfoo.so.1': {}},
+        pc.RemovePackagesUnderInstallation(paths_and_pkgs_by_soname,
+                                           packages_to_be_installed))
+
+
+class TestSharedLibsInAnInstalledPackageToo(CheckpkgUnitTestHelper,
+                                            unittest.TestCase):
+  """If a shared library is provided by one of the packages that are in the set
+  under test, take into account that the installed library will be removed at
+  install time.
+
+  The idea for the test:
+    - Test two packages: CSWbar and CSWlibfoo
+    - CSWbar depends on a library from libfoo
+    - CSWlibfoo is installed
+    - The new CSWlibfoo is broken and is missing the library
+  """
+  FUNCTION_NAME = 'SetCheckLibraries'
+  # Contains only necessary bits.  The data listed in full.
+  CSWbar_DATA = {
+        'basic_stats': {'catalogname': 'bar',
+                        'pkgname': 'CSWbar',
+                        'stats_version': 1},
+        'binaries_dump_info': [{'base_name': 'bar',
+                                'needed sonames': ['libfoo.so.1'],
+                                'path': 'opt/csw/bin/bar',
+                                'runpath': ['/opt/csw/lib'],
+                                'soname': 'rsync',
+                                'soname_guessed': True}],
+        'depends': (('CSWlibfoo', None),),
+        'isalist': [],
+        'pkgmap': [],
+        }
+  CSWlibfoo_DATA = {
+        'basic_stats': {'catalogname': 'libfoo',
+                        'pkgname': 'CSWlibfoo',
+                        'stats_version': 1},
+        'binaries_dump_info': [],
+        'depends': [],
+        'isalist': [],
+        'pkgmap': [],
+      }
+  def CheckpkgTest(self):
+    self.error_mgr_mock.GetPathsAndPkgnamesByBasename('libfoo.so.1').AndReturn({
+       u'/opt/csw/lib': [u'CSWlibfoo'],
+    })
+    self.error_mgr_mock.ReportError(
+        'CSWbar',
+        'soname-not-found',
+        'libfoo.so.1 is needed by opt/csw/bin/bar')
+    self.error_mgr_mock.ReportError('CSWbar', 'surplus-dependency', 'CSWlibfoo')
+    self.pkg_data = [self.CSWbar_DATA, self.CSWlibfoo_DATA]
+
+
 class TestCheckLibrariesDlopenLibs_1(CheckpkgUnitTestHelper, unittest.TestCase):
   """For dlopen-style shared libraries, libraries from /opt/csw/lib should be
   counted as dependencies.  It's only a heuristic though."""

Modified: csw/mgar/pkg/rrdtool/branches/x11-reloaded/Makefile
===================================================================
--- csw/mgar/pkg/rrdtool/branches/x11-reloaded/Makefile	2010-06-26 02:05:49 UTC (rev 10337)
+++ csw/mgar/pkg/rrdtool/branches/x11-reloaded/Makefile	2010-06-26 13:54:37 UTC (rev 10338)
@@ -78,25 +78,13 @@
 PKGFILES_CSWpy-rrdtool = $(libdir)/python/.*
 PKGFILES_CSWrbrrd = $(libdir)/ruby/.*
 
-CHECKPKG_OVERRIDES_CSWrrd += soname-not-found|libm.so.2|is|needed|by|opt/csw/bin/amd64/rrdcached
-CHECKPKG_OVERRIDES_CSWrrd += soname-not-found|libm.so.2|is|needed|by|opt/csw/bin/amd64/rrdcgi
-CHECKPKG_OVERRIDES_CSWrrd += soname-not-found|libm.so.2|is|needed|by|opt/csw/bin/amd64/rrdtool
-CHECKPKG_OVERRIDES_CSWrrd += soname-not-found|libm.so.2|is|needed|by|opt/csw/bin/amd64/rrdupdate
+CHECKPKG_OVERRIDES_CSWrrd += soname-not-found
 
 CHECKPKG_OVERRIDES_CSWrrd += missing-dependency|CSWperl
-CHECKPKG_OVERRIDES_CSWrrd += surplus-dependency|CSWrrdrt
 
-CHECKPKG_OVERRIDES_CSWpy-rrdtool += missing-dependency|CSWrrd
-CHECKPKG_OVERRIDES_CSWpy-rrdtool += surplus-dependency|CSWrrdrt
+CHECKPKG_OVERRIDES_CSWrbrrd += bad-rpath-entry
+CHECKPKG_OVERRIDES_CSWrbrrd += bad-rpath-entry
 
-CHECKPKG_OVERRIDES_CSWpmrrd += missing-dependency|CSWrrd
-CHECKPKG_OVERRIDES_CSWpmrrd += surplus-dependency|CSWrrdrt
-
-CHECKPKG_OVERRIDES_CSWrbrrd += missing-dependency|CSWrrd
-CHECKPKG_OVERRIDES_CSWrbrrd += surplus-dependency|CSWrrdrt
-CHECKPKG_OVERRIDES_CSWrbrrd += bad-rpath-entry|/home/dam/mgar/pkg/rrdtool/branches/x11-reloaded/work/solaris9-sparc/install-isa-sparcv8/opt/csw/lib|opt/csw/lib/ruby/site_ruby/1.8/sparc-solaris2.8/RRD.so
-CHECKPKG_OVERRIDES_CSWrbrrd += bad-rpath-entry|/home/dam/mgar/pkg/rrdtool/branches/x11-reloaded/work/solaris9-i386/install-isa-i386/opt/csw/lib|opt/csw/lib/ruby/site_ruby/1.8/i386-solaris2.8/RRD.so
-
 include gar/category.mk
 
 pre-build-modulated:


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