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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Dec 27 13:28:01 CET 2010


Revision: 12099
          http://gar.svn.sourceforge.net/gar/?rev=12099&view=rev
Author:   wahwah
Date:     2010-12-27 12:28:01 +0000 (Mon, 27 Dec 2010)

Log Message:
-----------
checkpkg: New check for base dirs of symlinks

When a base directory for a regular file is missing, it's automatically
created by pkgadd.  However, if the file is a symlink, installation fails.
Indicating that base directories are needed 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-27 12:27:35 UTC (rev 12098)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-12-27 12:28:01 UTC (rev 12099)
@@ -1152,10 +1152,26 @@
             % (pkg_data["basic_stats"]["catalogname"],
                pkgmap_entry["path"]))
 
+
+def CheckSymlinksBaseDirs(pkg_data, error_mgr, logger, messenger):
+  """If a symlink is in a non-existing directory, installation fails."""
+  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":
+    	base_dir = os.path.dirname(pkgmap_entry["path"])
+    	error_mgr.NeedFile(
+    	    base_dir,
+          "%s provides a symlink %s which needs a base directory: %s."
+    	    % (pkgname, repr(pkgmap_entry["path"]), repr(base_dir)))
+
+
 def CheckSonameMustNotBeEqualToFileNameIfFilenameEndsWithSo(
     pkg_data, error_mgr, logger, messenger):
   pass
 
+
 def CheckLinkableSoFileMustBeAsymlink(
     pkg_data, error_mgr, logger, messenger):
   pass

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-12-27 12:27:35 UTC (rev 12098)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-12-27 12:28:01 UTC (rev 12099)
@@ -1480,5 +1480,23 @@
     self.error_mgr_mock.ReportError('obsolete-dependency', 'CSWlibcups')
 
 
+class TestCheckSymlinksBaseDirs(CheckpkgUnitTestHelper,
+                                unittest.TestCase):
+  """Test whether appropriate files are provided."""
+  FUNCTION_NAME = 'CheckSymlinksBaseDirs'
+
+  def CheckpkgTest(self):
+    self.pkg_data = tree_stats[0]
+    self.pkg_data["pkgmap"].append(
+        {'class': 'none',
+         'group': None,
+         'line': '1 s none /opt/csw/lib/libneon.so.27=libneon.so.27.2.0',
+         'mode': None,
+         'path': '/opt/csw/lib/libneon.so.27',
+         'type': 's',
+         'user': None})
+    self.error_mgr_mock.NeedFile('/opt/csw/lib', 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