[csw-devel] SF.net SVN: gar:[8961] csw/mgar/gar/v2
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Thu Mar 4 09:44:21 CET 2010
Revision: 8961
http://gar.svn.sourceforge.net/gar/?rev=8961&view=rev
Author: wahwah
Date: 2010-03-04 08:44:20 +0000 (Thu, 04 Mar 2010)
Log Message:
-----------
mGAR v2: checkpkg, reporting an error when there's a file in .../init.d/ which is not of the cswinitsmf class.
Modified Paths:
--------------
csw/mgar/gar/v2/bin/analyze_module_results.py
csw/mgar/gar/v2/lib/python/checkpkg.py
csw/mgar/gar/v2/lib/python/opencsw.py
csw/mgar/gar/v2/lib/python/package_checks.py
csw/mgar/gar/v2/lib/python/package_checks_old.py
csw/mgar/gar/v2/lib/python/package_checks_test.py
Modified: csw/mgar/gar/v2/bin/analyze_module_results.py
===================================================================
--- csw/mgar/gar/v2/bin/analyze_module_results.py 2010-03-04 08:38:56 UTC (rev 8960)
+++ csw/mgar/gar/v2/bin/analyze_module_results.py 2010-03-04 08:44:20 UTC (rev 8961)
@@ -48,7 +48,7 @@
print " If you're getting errors at the same time, maybe you didn't"
print " specify the overrides correctly."
for override in unapplied_overrides:
- print "* %s" % override
+ print "* Unused %s" % override
sys.exit(exit_code)
Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py 2010-03-04 08:38:56 UTC (rev 8960)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py 2010-03-04 08:44:20 UTC (rev 8961)
@@ -810,7 +810,16 @@
Its purpose is to reduce the amount of boilerplate code and allow for easier
unit test writing.
"""
- class IndividualErrorGatherer(object):
+ class CheckInterfaceBase(object):
+ """Base class for check proxies.
+
+ It wraps access to the /var/sadm/install/contents cache.
+ """
+
+ def __init__(self, system_pkgmap):
+ self.system_pkgmap = system_pkgmap
+
+ class IndividualCheckInterface(CheckInterfaceBase):
"""To be passed to the checking functions.
Wraps the creation of CheckpkgTag objects.
@@ -824,7 +833,7 @@
self.errors.append(
CheckpkgTag(self.pkgname, tag_name, tag_info, msg))
- def SetErrorGatherer(object):
+ def SetCheckInterface(object):
"""To be bassed to set checking functions."""
def __init__(self):
self.errors = []
@@ -865,21 +874,21 @@
for function in self.individual_checks:
all_stats = pkg_data.GetAllStats()
pkgname = all_stats["basic_stats"]["pkgname"]
- error_mgr = self.IndividualErrorGatherer(pkgname)
+ check_interface = self.IndividualCheckInterface(pkgname)
logger = logging.getLogger("%s-%s" % (pkgname, function.__name__))
logger.debug("Calling %s", function.__name__)
- function(all_stats, error_mgr, logger=logger)
- if error_mgr.errors:
- errors[pkgname] = error_mgr.errors
+ function(all_stats, check_interface, logger=logger)
+ if check_interface.errors:
+ errors[pkgname] = check_interface.errors
# Set checks
for function in self.set_checks:
pkgs_data = [x.GetAllStats() for x in packages_data]
logger = logging.getLogger("SetCheck-%s" % (function.__name__,))
- error_mgr = self.SetErrorGatherer()
+ check_interface = self.SetCheckInterface()
logger.debug("Calling %s", function.__name__)
- function(pkgs_data, error_mgr, logger)
- if error_mgr.errors:
- errors = self.SetErrorsToDict(error_mgr.errors, errors)
+ function(pkgs_data, check_interface, logger)
+ if check_interface.errors:
+ errors = self.SetErrorsToDict(check_interface.errors, errors)
return errors
def Run(self):
@@ -1097,7 +1106,8 @@
basic_stats["stats_version"] = PACKAGE_STATS_VERSION
basic_stats["pkg_path"] = self.srv4_pkg.pkg_path
basic_stats["pkg_basename"] = os.path.basename(self.srv4_pkg.pkg_path)
- basic_stats["parsed_basename"] = opencsw.ParsePackageFileName(basic_stats["pkg_basename"])
+ basic_stats["parsed_basename"] = opencsw.ParsePackageFileName(
+ basic_stats["pkg_basename"])
basic_stats["pkgname"] = dir_pkg.pkgname
basic_stats["catalogname"] = dir_pkg.GetCatalogname()
return basic_stats
Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py 2010-03-04 08:38:56 UTC (rev 8960)
+++ csw/mgar/gar/v2/lib/python/opencsw.py 2010-03-04 08:44:20 UTC (rev 8961)
@@ -787,7 +787,7 @@
stdout, stderr = find_proc.communicate()
ret = find_proc.wait()
if ret:
- logging.error("The find command returned an error.")
+ logging.error("The %s command returned an error.", repr(find_tmpl))
dotslash_re = re.compile(r"^./")
def StripRe(x, strip_re):
return re.sub(strip_re, "", x)
Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py 2010-03-04 08:38:56 UTC (rev 8960)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2010-03-04 08:44:20 UTC (rev 8961)
@@ -84,6 +84,19 @@
error_mgr.ReportError("pkginfo-bad-catalogname")
+def CheckSmfIntegration(pkg_data, error_mgr, logger):
+ init_re = re.compile(r"/init\.d/")
+ for entry in pkg_data["pkgmap"]:
+ if not entry["path"]:
+ continue
+ if not re.search(init_re, entry["path"]):
+ continue
+ if entry["class"] != "cswinitsmf":
+ error_mgr.ReportError(
+ "init-file-missing-cswinitsmf-class",
+ "%s class=%s" % (entry["path"], entry["class"]))
+
+
def SetCheckDependencies(pkgs_data, error_mgr, logger):
"""Dependencies must be either installed in the system, or in the set."""
pass
Modified: csw/mgar/gar/v2/lib/python/package_checks_old.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_old.py 2010-03-04 08:38:56 UTC (rev 8960)
+++ csw/mgar/gar/v2/lib/python/package_checks_old.py 2010-03-04 08:44:20 UTC (rev 8961)
@@ -2,6 +2,8 @@
# coding=utf-8
# $Id$
+"""This module uses an old API. Please do not add new checks here."""
+
import checkpkg
import re
@@ -102,30 +104,30 @@
maintname = checkpkg.ExtractMaintainerName(pkginfo)
if not maintname:
errors.append(checkpkg.CheckpkgTag(
- pkgname, "maintainer-name-not-set"))
+ pkgname, "pkginfo-maintainer-name-not-set"))
# email
if not pkginfo["EMAIL"]:
errors.append(checkpkg.CheckpkgTag(
- pkgname, "email-blank"))
+ pkgname, "pkginfo-blank-email"))
# hotline
if not pkginfo["HOTLINE"]:
errors.append(checkpkg.CheckpkgTag(
- pkgname, "hotline-blank"))
+ pkgname, "pkginfo-hotline-blank"))
pkginfo_version = pkg_data["basic_stats"]["parsed_basename"]["full_version_string"]
if pkginfo_version != pkginfo["VERSION"]:
errors.append(checkpkg.CheckpkgTag(
pkgname, "filename-version-does-not-match-pkginfo-version"))
if re.search(r"-", pkginfo["VERSION"]):
errors.append(checkpkg.CheckpkgTag(
- pkgname, "minus-not-allowed-in-version"))
+ pkgname, "pkginfo-minus-in-version"))
if not re.match(VERSION_RE, pkginfo["VERSION"]):
msg = ("Version regex: %s, version value: %s."
% (repr(VERSION_RE), repr(pkginfo["VERSION"])))
errors.append(checkpkg.CheckpkgTag(
- pkgname, "version-does-not-match-regex", msg=msg))
+ pkgname, "pkginfo-version-wrong-format", msg=msg))
if pkginfo["ARCH"] not in ARCH_LIST:
errors.append(checkpkg.CheckpkgTag(
- pkgname, "non-standard-architecture", pkginfo["ARCH"]))
+ pkgname, "pkginfo-nonstandard-architecture", pkginfo["ARCH"]))
if "PSTAMP" in pkginfo:
if not re.match(checkpkg.PSTAMP_RE, pkginfo["PSTAMP"]):
errors.append(checkpkg.CheckpkgTag(
Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py 2010-03-04 08:38:56 UTC (rev 8960)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py 2010-03-04 08:44:20 UTC (rev 8961)
@@ -28,7 +28,7 @@
def testDefault(self):
self.logger_mock = self.mocker.CreateMock(logging.Logger)
self.error_mgr_mock = self.mocker.CreateMock(
- checkpkg.CheckpkgManager2.IndividualErrorGatherer)
+ checkpkg.CheckpkgManager2.IndividualCheckInterface)
self.CheckpkgTest()
self.mocker.ReplayAll()
getattr(pc, self.FUNCTION_NAME)(self.pkg_data, self.error_mgr_mock, self.logger_mock)
@@ -62,6 +62,34 @@
self.pkg_data["pkginfo"]["NAME"] = 'foo-bar - This catalog name is bad'
self.error_mgr_mock.ReportError('pkginfo-bad-catalogname')
+class TestCheckCatalogname(CheckpkgUnitTestHelper, unittest.TestCase):
+ FUNCTION_NAME = 'CheckSmfIntegration'
+ def CheckpkgTest(self):
+ self.pkg_data["pkgmap"].append({
+ "class": "none",
+ "group": "bin",
+ "line": "1 f none /etc/opt/csw/init.d/foo 0644 root bin 36372 24688 1266395027",
+ "mode": '0755',
+ "path": "/etc/opt/csw/init.d/foo",
+ "type": "f",
+ "user": "root"
+ })
+ self.error_mgr_mock.ReportError('init-file-missing-cswinitsmf-class',
+ '/etc/opt/csw/init.d/foo class=none')
+class TestCheckCatalognameGood(CheckpkgUnitTestHelper, unittest.TestCase):
+ FUNCTION_NAME = 'CheckSmfIntegration'
+ def CheckpkgTest(self):
+ self.pkg_data["pkgmap"].append({
+ "class": "cswinitsmf",
+ "group": "bin",
+ "line": "1 f none /etc/opt/csw/init.d/foo 0644 root bin 36372 24688 1266395027",
+ "mode": '0755',
+ "path": "/etc/opt/csw/init.d/foo",
+ "type": "f",
+ "user": "root"
+ })
+
+
if __name__ == '__main__':
- unittest.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