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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Thu Dec 30 03:50:31 CET 2010


Revision: 12132
          http://gar.svn.sourceforge.net/gar/?rev=12132&view=rev
Author:   wahwah
Date:     2010-12-30 02:50:31 +0000 (Thu, 30 Dec 2010)

Log Message:
-----------
checkpkg: Check base dirs for class not-none

The 'none' class creates missing directories automatically.  All other classes
might suffer from missing base directories - report missing base directories
as errors.

The same goes for symlinks.

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

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-12-30 02:49:59 UTC (rev 12131)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-12-30 02:50:31 UTC (rev 12132)
@@ -1153,17 +1153,23 @@
                pkgmap_entry["path"]))
 
 
-def CheckSymlinksBaseDirs(pkg_data, error_mgr, logger, messenger):
-  """If a symlink is in a non-existing directory, installation fails."""
+def CheckBaseDirs(pkg_data, error_mgr, logger, messenger):
+  """Symlinks and nonstandard class files need base directories
+
+  This cannot be made a general check, because there would be too many false
+  positives.  However, symlinks and nonstandard class files are so prone to
+  this problem that it makes sense to throw errors if they miss base
+  directories.
+  """
   pkgname = pkg_data["basic_stats"]["pkgname"]
   for pkgmap_entry in pkg_data["pkgmap"]:
     if "path" not in pkgmap_entry: continue
     if not pkgmap_entry["path"]: continue
-    if pkgmap_entry["type"] == "s":
+    if pkgmap_entry["type"] == "s" or pkgmap_entry["class"] != "none":
       base_dir = os.path.dirname(pkgmap_entry["path"])
       error_mgr.NeedFile(
           base_dir,
-          "%s contains a symlink %s which needs a base directory: %s."
+          "%s contains %s which needs a base directory: %s."
           % (pkgname, repr(pkgmap_entry["path"]), repr(base_dir)))
 
 

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-12-30 02:49:59 UTC (rev 12131)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-12-30 02:50:31 UTC (rev 12132)
@@ -1480,13 +1480,13 @@
     self.error_mgr_mock.ReportError('obsolete-dependency', 'CSWlibcups')
 
 
-class TestCheckSymlinksBaseDirs(CheckpkgUnitTestHelper,
-                                unittest.TestCase):
-  """Test whether appropriate files are provided."""
-  FUNCTION_NAME = 'disabledCheckSymlinksBaseDirs'
+class TestCheckBaseDirs(CheckpkgUnitTestHelper,
+                        unittest.TestCase):
+  """Test whether appropriate base directories are provided."""
+  FUNCTION_NAME = 'CheckBaseDirs'
 
   def CheckpkgTest(self):
-    self.pkg_data = tree_stats[0]
+    self.pkg_data = copy.deepcopy(tree_stats[0])
     self.pkg_data["pkgmap"].append(
         {'class': 'none',
          'group': None,
@@ -1498,5 +1498,22 @@
     self.error_mgr_mock.NeedFile('/opt/csw/lib', mox.IsA(str))
 
 
+class TestCheckBaseDirsNotNoneClass(CheckpkgUnitTestHelper,
+                                    unittest.TestCase):
+  FUNCTION_NAME = 'CheckBaseDirs'
+
+  def CheckpkgTest(self):
+    self.pkg_data = copy.deepcopy(tree_stats[0])
+    self.pkg_data["pkgmap"].append(
+        {'class': 'cswinitsmf',
+         'group': None,
+         'line': None,
+         'mode': None,
+         'path': '/etc/opt/csw/init.d/foo',
+         'type': 'f',
+         'user': None})
+    self.error_mgr_mock.NeedFile('/etc/opt/csw/init.d', mox.IsA(str))
+
+
 if __name__ == '__main__':
   unittest.main()


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