[csw-maintainers] [PATCH 5/5] checkpkg: Checking if catalogname matches pkgname

Maciej Blizinski maciej at opencsw.org
Sat Feb 12 07:58:36 CET 2011


From: Maciej Bliziński <maciej at opencsw.org>

I've recently seen some patches correcting the pkgname vs catalogname
correspondence in packages.

Here's a patch that makes checkpkg verify that catalognames correspond to
pkgnames.

Our build standards page[1] currently recommends the naming in which e.g.
CSWsoftdoc corresponds to soft_doc.  We've recently started to introduce more
separators to pkgnames, so perhaps the standards page should be updated.

I'm aware of multiple packages in which pkgname does not correspond to
catalogname.  If we commit this change in, maintainers will see many
(overridable, as always) instances of this check triggering an error.  On the
plus side, the patch will make it harder to make a mistake when creating new
packages or reworking the old ones.  I've seen two recent code commits in our
repository, dealing with exactly this - making pkgname and catalogname match.

Would you, maintainers, like this check to be introduced?

Maciej

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

---
 gar/v2/lib/python/README                 |    4 +++-
 gar/v2/lib/python/package_checks.py      |   12 ++++++++++++
 gar/v2/lib/python/package_checks_test.py |   20 ++++++++++++++++++++
 3 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/gar/v2/lib/python/README b/gar/v2/lib/python/README
index a09f074..40c296d 100644
--- a/gar/v2/lib/python/README
+++ b/gar/v2/lib/python/README
@@ -3,7 +3,6 @@ This directory contains Python libraries, mostly related to checkpkg.
 ==Checkpkg==
 
 Checks to implement:
- - foo_bar != CSWfoo-bar -> error
  - *dev(el)? -> error, suggest *-devel
  - *-?rt -> error, suggest specific library packages
  - empty package without 'transitional' in the name --> error, suggest
@@ -13,6 +12,9 @@ Checks to implement:
  	 ('transitional', 'stub', 'legacy')
  - Dependency on CSWcas-initsmf + rc* files --> error
 
+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
diff --git a/gar/v2/lib/python/package_checks.py b/gar/v2/lib/python/package_checks.py
index a65097b..e282544 100644
--- a/gar/v2/lib/python/package_checks.py
+++ b/gar/v2/lib/python/package_checks.py
@@ -26,6 +26,7 @@ import textwrap
 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,17 @@ def CheckPrefixDirs(pkg_data, error_mgr, logger, messenger):
           "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:
+    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):
   pass
diff --git a/gar/v2/lib/python/package_checks_test.py b/gar/v2/lib/python/package_checks_test.py
index 98e6e70..8e3dcc5 100755
--- a/gar/v2/lib/python/package_checks_test.py
+++ b/gar/v2/lib/python/package_checks_test.py
@@ -1655,5 +1655,25 @@ class TestCheckPrefixDirs(CheckpkgUnitTestHelper,
     self.RunCheckpkgTest(self.CheckpkgTest4)
 
 
+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()
-- 
1.7.1



More information about the maintainers mailing list