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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Fri Feb 18 00:41:56 CET 2011


Revision: 13354
          http://gar.svn.sourceforge.net/gar/?rev=13354&view=rev
Author:   wahwah
Date:     2011-02-17 23:41:55 +0000 (Thu, 17 Feb 2011)

Log Message:
-----------
checkpkg: Check that catalogname matches pkgname

Adding a check that throws an error of catalogname doesn't match the pkgname.

It is loosely based on the standards page[1], and more specific.

[1] http://www.opencsw.org/extend-it/contribute-packages/build-standards/package-creation/

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/README
    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/README
===================================================================
--- csw/mgar/gar/v2/lib/python/README	2011-02-17 23:28:58 UTC (rev 13353)
+++ csw/mgar/gar/v2/lib/python/README	2011-02-17 23:41:55 UTC (rev 13354)
@@ -3,7 +3,6 @@
 ==Checkpkg==
 
 Checks to implement:
- - foo_bar != CSWfoo-bar -> error
  - *dev(el)? -> error, suggest *-dev
  - *-?rt -> error, suggest specific library packages
  - empty package without 'transitional' in the name --> error, suggest
@@ -14,6 +13,9 @@
  - Dependency on CSWcas-initsmf + rc* files --> error
  - A package must not be incompatible with itself
 
+Checks implemented:
+ - foo_bar != CSWfoo-bar -> error
+ - outside /opt/csw, /etc/opt/csw, /var/opt/csw -> error
 
 Development plan for checkpkg:
 - Notify maintainers when their package is available from mirrors

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2011-02-17 23:28:58 UTC (rev 13353)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2011-02-17 23:41:55 UTC (rev 13354)
@@ -26,6 +26,7 @@
 import dependency_checks as depchecks
 import configuration as c
 import sharedlib_utils as su
+import struct_util
 from Cheetah import Template
 import common_constants
 import logging
@@ -1223,6 +1224,22 @@
           "file=%s" % pkgmap_entry["path"])
 
 
+def CheckCatalognameMatchesPkgname(pkg_data, error_mgr, logger, messenger):
+  pkgname = pkg_data["basic_stats"]["pkgname"]
+  catalogname = pkg_data["basic_stats"]["catalogname"]
+  std_catalogname = struct_util.MakeCatalognameByPkgname(pkgname)
+  if catalogname != std_catalogname:
+    msg = (
+        "The catalogname should match the pkgname. "
+        "For more information, see "
+        "http://www.opencsw.org/extend-it/contribute-packages/"
+        "build-standards/package-creation/")
+    error_mgr.ReportError(
+        'catalogname-does-not-match-pkgname',
+        'pkgname=%s catalogname=%s expected-catalogname=%s'
+        % (pkgname, catalogname, std_catalogname))
+
+
 def CheckSonameMustNotBeEqualToFileNameIfFilenameEndsWithSo(
     pkg_data, error_mgr, logger, messenger):
   shared_libs = set(su.GetSharedLibs(pkg_data))

Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py	2011-02-17 23:28:58 UTC (rev 13353)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py	2011-02-17 23:41:55 UTC (rev 13354)
@@ -1694,5 +1694,26 @@
     self.pkg_data = mercurial_stats[0]
 
 
+class TestCheckCatalognameMatchesPkgname(CheckpkgUnitTestHelper,
+                                         unittest.TestCase):
+  FUNCTION_NAME = 'CheckCatalognameMatchesPkgname'
+
+  def CheckpkgTest(self):
+    self.pkg_data = copy.deepcopy(tree_stats[0])
+    basic_stats = self.pkg_data["basic_stats"]
+    basic_stats["catalogname"] = "foo_bar"
+    basic_stats["pkgname"] = "CSWfoo-bar-baz"
+    self.error_mgr_mock.ReportError(
+        'catalogname-does-not-match-pkgname',
+        'pkgname=CSWfoo-bar-baz catalogname=foo_bar '
+        'expected-catalogname=foo_bar_baz')
+
+  def CheckpkgTest2(self):
+    self.pkg_data = copy.deepcopy(tree_stats[0])
+
+  def testTwo(self):
+    self.RunCheckpkgTest(self.CheckpkgTest2)
+
+
 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