[csw-devel] SF.net SVN: gar:[9903] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon May 17 12:29:31 CEST 2010
Revision: 9903
http://gar.svn.sourceforge.net/gar/?rev=9903&view=rev
Author: wahwah
Date: 2010-05-17 10:29:31 +0000 (Mon, 17 May 2010)
Log Message:
-----------
mGAR v2: checkpkg, CheckDisallowedPaths now uses regexes.
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-05-17 09:56:52 UTC (rev 9902)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2010-05-17 10:29:31 UTC (rev 9903)
@@ -23,13 +23,13 @@
PATHS_ALLOWED_ONLY_IN = {
# Leading slash must be removed.
- "CSWcommon": ["opt",
- "opt/csw/man",
- "opt/csw/doc",
- "opt/csw/info",
- "opt/csw/share/locale/locale.alias"],
- "CSWiconv": ["opt/csw/lib/charset.alias"],
- "CSWtexinfo": ["opt/csw/share/info/dir"],
+ "CSWcommon": [r"opt",
+ r"opt/csw/man.*",
+ r"opt/csw/doc",
+ r"opt/csw/info",
+ r"opt/csw/share/locale/locale.alias"],
+ "CSWiconv": [r"opt/csw/lib/charset.alias"],
+ "CSWtexinfo": [r"opt/csw/share/info/dir"],
}
MAX_DESCRIPTION_LENGTH = 100
LICENSE_TMPL = "/opt/csw/share/doc/%s/license"
@@ -536,15 +536,14 @@
paths_in_pkg.add(entry_path)
for pkgname in paths_only_allowed_in:
if pkgname != pkg_data["basic_stats"]["pkgname"]:
- disallowed_paths = set(paths_only_allowed_in[pkgname])
- intersection = disallowed_paths.intersection(paths_in_pkg)
- if intersection:
- logger.debug("Bad paths found: %s", intersection)
- for bad_path in intersection:
- error_mgr.ReportError(
- "disallowed-path", bad_path,
- "This path is already provided by CSWcommon "
- "or is not allowed for other reasons.")
+ for disallowed_path in paths_only_allowed_in[pkgname]:
+ disallowed_re = re.compile(r"^%s$" % disallowed_path)
+ for path_in_pkg in paths_in_pkg:
+ if disallowed_re.match(path_in_pkg):
+ error_mgr.ReportError(
+ "disallowed-path", path_in_pkg,
+ "This path is already provided by %s "
+ "or is not allowed for other reasons." % pkgname)
def CheckLinkingAgainstSunX11(pkg_data, error_mgr, logger, messenger):
Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py 2010-05-17 09:56:52 UTC (rev 9902)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py 2010-05-17 10:29:31 UTC (rev 9903)
@@ -550,5 +550,24 @@
'or is not allowed for other reasons.')
+class TestCheckDisallowedPaths_2(CheckpkgUnitTestHelper, unittest.TestCase):
+ FUNCTION_NAME = "CheckDisallowedPaths"
+ def CheckpkgTest(self):
+ self.pkg_data["pkgmap"].append({
+ "class": "none",
+ "group": "bin",
+ "line": "doesn't matter here",
+ "mode": '0755',
+ "path": "/opt/csw/man/man1/foo.1",
+ "type": "f",
+ "user": "root"
+ })
+ self.error_mgr_mock.GetCommonPaths('sparc').AndReturn([])
+ self.error_mgr_mock.ReportError(
+ 'disallowed-path', 'opt/csw/man/man1/foo.1',
+ 'This path is already provided by CSWcommon '
+ 'or is not allowed for other reasons.')
+
+
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