[csw-devel] SF.net SVN: gar:[8104] csw/mgar/gar/v2/bin

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Thu Jan 21 12:13:13 CET 2010


Revision: 8104
          http://gar.svn.sourceforge.net/gar/?rev=8104&view=rev
Author:   wahwah
Date:     2010-01-21 11:13:10 +0000 (Thu, 21 Jan 2010)

Log Message:
-----------
mGAR v2: checkpkg, emulating the effect of the /opt/csw/lib/i386 -> . symlink during package installation; printing out a message about checking the package cache.

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/checkpkg
    csw/mgar/gar/v2/bin/checkpkg.d/checkpkg.py
    csw/mgar/gar/v2/bin/checkpkg.d/checkpkg_test.py
    csw/mgar/gar/v2/bin/checkpkg.d/update_contents_cache.py

Property Changed:
----------------
    csw/mgar/gar/v2/bin/checkpkg.d/update_contents_cache.py

Modified: csw/mgar/gar/v2/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg	2010-01-21 09:53:55 UTC (rev 8103)
+++ csw/mgar/gar/v2/bin/checkpkg	2010-01-21 11:13:10 UTC (rev 8104)
@@ -556,7 +556,6 @@
 
 set_variables_for_individual_package_check "$f"
 
-echo "Running modular tests"
 test_suite_ok=1
 checkpkg_scriptname=`basename $0`
 checkpkg_basedir=${0%/${checkpkg_scriptname}}
@@ -571,6 +570,7 @@
 debugmsg "plugindir: '$plugindir'"
 log_files=""
 if [[ -d "$plugindir" ]]; then
+  echo "Running modular tests"
 	# echo plugin dir exists
 	for plugin in "${plugindir}"/checkpkg-*; do
 		if [[ -x "${plugin}" ]]; then

Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg.py	2010-01-21 09:53:55 UTC (rev 8103)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg.py	2010-01-21 11:13:10 UTC (rev 8104)
@@ -24,6 +24,11 @@
 DO_NOT_REPORT_SURPLUS = set([u"CSWcommon", u"CSWcswclassutils", u"CSWisaexec"])
 DO_NOT_REPORT_MISSING = set([u"SUNWlibC", u"SUNWcsl", u"SUNWlibms",
                              u"*SUNWcslr", u"*SUNWlibC", u"*SUNWlibms"])
+SYSTEM_SYMLINKS = (
+    ("/opt/csw/bdb4", ["/opt/csw/bdb42"]),
+    ("/64", ["/amd64", "/sparcv9"]),
+    ("/opt/csw/lib/i386", ["/opt/csw/lib"]),
+)
 
 # 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.
@@ -182,6 +187,7 @@
       logging.debug("Connecting to the %s database.", self.db_path)
       self.conn = sqlite3.connect(self.db_path)
       if not self.IsDatabaseUpToDate():
+      	logging.warning("Rebuilding the package cache, can take a few minutes.")
         self.PurgeDatabase()
         self.PopulateDatabase()
     else:
@@ -210,6 +216,10 @@
       """)
       self.PopulateDatabase()
 
+  def SymlinkDuringInstallation(self, p):
+    """Emulates the effect of some symlinks present during installations."""
+    p = p.replace("/opt/csw/lib/i386", "/opt/csw/lib")
+
   def PopulateDatabase(self):
     """Imports data into the database.
 
@@ -296,10 +306,11 @@
   def IsDatabaseUpToDate(self):
     f_mtime = self.GetFileMtime()
     d_mtime = self.GetDatabaseMtime()
-    logging.debug("f_mtime", f_mtime, "d_time", d_mtime)
+    logging.debug("f_mtime %s, d_time: %s", f_mtime, d_mtime)
     return self.GetFileMtime() <= self.GetDatabaseMtime()
 
   def PurgeDatabase(self):
+    logging.info("Purging the cache database")
     c = self.conn.cursor()
     sql = "DELETE FROM config;"
     c.execute(sql)
@@ -438,25 +449,27 @@
     expanded_list = [runpath]
   return expanded_list
 
+def ExpandSymlink(symlink, target, input_path):
+  symlink_re = re.compile(r"%s(/|$)" % symlink)
+  if re.search(symlink_re, input_path):
+    result = input_path.replace(symlink, target)
+  else:
+    result = input_path
+  return result
+
 def Emulate64BitSymlinks(runpath_list):
   """Need to emulate the 64 -> amd64, 64 -> sparcv9 symlink
 
   Since we don't know the architecture, we'll adding both amd64 and sparcv9.
   It should be safe.
   """
-  symlinks = (
-      ("/opt/csw/bdb4", ["/opt/csw/bdb42"]),
-      ("/64", ["/amd64", "/sparcv9"]),
-  )
   symlinked_list = []
   for runpath in runpath_list:
-    for symlink, expansion_list in symlinks:
-      symlink_re = re.compile(r"%s(/|$)" % symlink)
-      if re.search(symlink_re, runpath):
-        for expansion in expansion_list:
-          symlinked_list.append(runpath.replace(symlink, expansion))
-      else:
-        symlinked_list.append(runpath)
+    for symlink, expansion_list in SYSTEM_SYMLINKS:
+      for target in expansion_list:
+      	expanded = ExpandSymlink(symlink, target, runpath)
+        if expanded not in symlinked_list:
+        	symlinked_list.append(expanded)
   return symlinked_list
 
 
@@ -484,6 +497,17 @@
       runpath_list = ExpandRunpath(runpath, isalist)
       runpath_list = Emulate64BitSymlinks(runpath_list)
       soname_runpath_data = pkgmap.GetPkgmapLineByBasename(soname)
+      # Emulating the install time symlinks, for instance, if the prototype contains
+      # /opt/csw/lib/i386/foo.so.0 and /opt/csw/lib/i386 is a symlink to ".",
+      # the shared library ends up in /opt/csw/lib/foo.so.0 and should be findable even when
+      # RPATH does not contain $ISALIST.
+      new_soname_runpath_data = {}
+      for p in soname_runpath_data:
+      	expanded_p_list = Emulate64BitSymlinks([p])
+        for expanded_p in expanded_p_list:
+          new_soname_runpath_data[expanded_p] = soname_runpath_data[p]
+      soname_runpath_data = new_soname_runpath_data
+
       logging.debug("%s: will be looking for %s in %s" %
                     (soname, runpath_list, soname_runpath_data.keys()))
       for runpath_expanded in runpath_list:

Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg_test.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg_test.py	2010-01-21 09:53:55 UTC (rev 8103)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg_test.py	2010-01-21 11:13:10 UTC (rev 8104)
@@ -310,6 +310,13 @@
     result = checkpkg.Emulate64BitSymlinks(runpath_list)
     self.assertTrue(expected in result, "%s not in %s" % (expected, result))
 
+  def testEmulate64BitSymlinks_4(self):
+    """No repeated paths because of symlink expansion"""
+    runpath_list = ["/opt/csw/lib"]
+    expected = "/opt/csw/lib"
+    result = checkpkg.Emulate64BitSymlinks(runpath_list)
+    self.assertEquals(1, len(result), "len(%s) != %s" % (result, 1))
+
   def testEmulateSymlinks_3(self):
     runpath_list = ["/opt/csw/bdb4"]
     expected = "/opt/csw/bdb42"
@@ -324,6 +331,22 @@
     self.assertTrue(expected in result, "%s not in %s" % (expected, result))
     self.assertFalse(not_expected in result, "%s is in %s" % (not_expected, result))
 
+  def testEmulateSymlinks_5(self):
+    """Install time symlink expansion."""
+    runpath_list = ["/opt/csw/lib/i386"]
+    expected = "/opt/csw/lib"
+    result = checkpkg.Emulate64BitSymlinks(runpath_list)
+    self.assertTrue(expected in result, "%s not in %s" % (expected, result))
+
+  def testEmulateSymlinks_6(self):
+    """ExpandSymlink for /opt/csw/lib/i386."""
+    runpath_list = ["/opt/csw/lib/i386"]
+    expected = "/opt/csw/lib"
+    not_expected = "/opt/csw/lib/i386"
+    result = checkpkg.ExpandSymlink("/opt/csw/lib/i386", "/opt/csw/lib", "/opt/csw/lib/i386")
+    self.assertTrue(expected in result, "%s not in %s" % (expected, result))
+    self.assertFalse(not_expected in result, "%s is in %s" % (not_expected, result))
+
   def testGetLinesBySoname(self):
     expected = {'foo.so.1': '/opt/csw/lib/isa-value-1/foo.so.1 foo'}
     pkgmap = self.pkgmap_mocker.CreateMock(checkpkg.SystemPkgmap)
@@ -441,11 +464,14 @@
      binaries_by_soname,
      runpath_by_needed_soname) = checkpkg.BuildIndexesBySoname(
          d6.DATA_NEEDED_SONAMES_BY_BINARY)
+    # The original data did not have amd64 in the isalist.
+    isalist = ['amd64', 'pentium_pro+mmx', 'pentium_pro', 'pentium+mmx',
+               'pentium', 'i486', 'i386', 'i86']
     result = checkpkg.GetLinesBySoname(
         pkgmap_stub,
         set([soname]),
         runpath_by_needed_soname,
-        d6.DATA_ISALIST)
+        isalist)
     self.assertEqual(expected, result)
 
   def testGetLinesBySoname_8(self):
@@ -461,6 +487,24 @@
     self.pkgmap_mocker.VerifyAll()
     self.assertEqual(expected, result)
 
+  def testGetLinesBySoname_9(self):
+    """Emulation of binaries installed into /opt/csw/lib/i386.
+
+    The problem is that /opt/csw/lib/i386 is a symlink and the binaries
+    end up in /opt/csw/lib instead.
+    """
+    expected = {'foo.so.0': '/opt/csw/lib/i386/foo.so.0 foo'}
+    lines1 = {"/opt/csw/lib/i386": "/opt/csw/lib/i386/foo.so.0 foo"}
+    pkgmap = self.pkgmap_mocker.CreateMock(checkpkg.SystemPkgmap)
+    pkgmap.GetPkgmapLineByBasename("foo.so.0").AndReturn(lines1)
+    self.pkgmap_mocker.ReplayAll()
+    needed_sonames = set(["foo.so.0"])
+    runpath_by_needed_soname = {"foo.so.0": ["/opt/csw/lib", "/usr/lib"]}
+    isalist = ["isa-value-1", "isa-value-2"]
+    result = checkpkg.GetLinesBySoname(pkgmap, needed_sonames, runpath_by_needed_soname, isalist)
+    self.pkgmap_mocker.VerifyAll()
+    self.assertEqual(expected, result)
+
   def testSanitizeRunpath_1(self):
     self.assertEqual("/opt/csw/lib", checkpkg.SanitizeRunpath("/opt/csw/lib/"))
 

Modified: csw/mgar/gar/v2/bin/checkpkg.d/update_contents_cache.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/update_contents_cache.py	2010-01-21 09:53:55 UTC (rev 8103)
+++ csw/mgar/gar/v2/bin/checkpkg.d/update_contents_cache.py	2010-01-21 11:13:10 UTC (rev 8104)
@@ -1,8 +1,17 @@
 #!/opt/csw/bin/python2.6
+#
+# $Id$
+#
+# This file only creates an instance of SystemPkgmap in order to update the
+# package cache (if necessary), and display the information about the update.
 
 import checkpkg
+import logging
 
+
 def main():
+  print "Checking if the package cache is up to date."
+  logging.basicConfig(level=logging.INFO)
   test_pkgmap = checkpkg.SystemPkgmap()
 
 


Property changes on: csw/mgar/gar/v2/bin/checkpkg.d/update_contents_cache.py
___________________________________________________________________
Added: svn:keywords
   + Id


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