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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Thu Dec 30 14:56:54 CET 2010


Revision: 12136
          http://gar.svn.sourceforge.net/gar/?rev=12136&view=rev
Author:   wahwah
Date:     2010-12-30 13:56:53 +0000 (Thu, 30 Dec 2010)

Log Message:
-----------
checkpkg: Adding CheckDanglingSymlinks

Checks for targets of symlinks.  If a package contains a symlink, the target
path must either be provided by the package itself, or by its direct
dependency.

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 13:56:21 UTC (rev 12135)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-12-30 13:56:53 UTC (rev 12136)
@@ -1173,6 +1173,18 @@
           % (pkgname, repr(pkgmap_entry["path"]), repr(base_dir)))
 
 
+def CheckDanglingSymlinks(pkg_data, error_mgr, logger, messenger):
+  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":
+      error_mgr.NeedFile(
+          pkgmap_entry["target"],
+          "%s contains a symlink (%s) which needs the target file: %s."
+          % (pkgname, repr(pkgmap_entry["path"]), repr(pkgmap_entry["target"])))
+
+
 def CheckSonameMustNotBeEqualToFileNameIfFilenameEndsWithSo(
     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-30 13:56:21 UTC (rev 12135)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2010-12-30 13:56:53 UTC (rev 12136)
@@ -1515,5 +1515,23 @@
     self.error_mgr_mock.NeedFile('/etc/opt/csw/init.d', mox.IsA(str))
 
 
+class TestCheckDanglingSymlinks(CheckpkgUnitTestHelper,
+                                unittest.TestCase):
+  FUNCTION_NAME = 'CheckDanglingSymlinks'
+
+  def CheckpkgTest(self):
+    self.pkg_data = copy.deepcopy(tree_stats[0])
+    self.pkg_data["pkgmap"].append(
+        {'class': 'none',
+         'group': None,
+         'line': None,
+         'mode': None,
+         'path': '/opt/csw/lib/postgresql/9.0/lib/libpq.so.5',
+         'type': 's',
+         'user': None,
+         'target': '/opt/csw/lib/libpq.so.5'})
+    self.error_mgr_mock.NeedFile('/opt/csw/lib/libpq.so.5', 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