[csw-devel] SF.net SVN: gar:[8892] csw/mgar/gar/v2
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sun Feb 28 17:58:21 CET 2010
Revision: 8892
http://gar.svn.sourceforge.net/gar/?rev=8892&view=rev
Author: wahwah
Date: 2010-02-28 16:58:21 +0000 (Sun, 28 Feb 2010)
Log Message:
-----------
mGAR v2: checkpkg, implemented the new API, ready to start porting checks.
Modified Paths:
--------------
csw/mgar/gar/v2/bin/checkpkg
csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-archall.py
csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py
csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-missing-symbols.py
csw/mgar/gar/v2/lib/python/checkpkg.py
csw/mgar/gar/v2/lib/python/package_checks.py
csw/mgar/gar/v2/lib/python/package_checks_test.py
csw/mgar/gar/v2/tests/run_tests.py
Added Paths:
-----------
csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py
csw/mgar/gar/v2/lib/python/package_checks_old.py
csw/mgar/gar/v2/lib/python/package_checks_old_test.py
Modified: csw/mgar/gar/v2/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg 2010-02-28 16:35:23 UTC (rev 8891)
+++ csw/mgar/gar/v2/bin/checkpkg 2010-02-28 16:58:21 UTC (rev 8892)
@@ -262,15 +262,6 @@
# Check for some common errors
if [[ $pkgname != "CSWcommon" ]] ; then
- if [[ $LOGNAME != "root" ]] ; then
- nawk '$6 == "'$LOGNAME'" {print; exit 1}' $EXTRACTDIR/$pkgname/pkgmap
- if [[ $? -eq 1 ]] ; then
- print ERROR: files owned by $LOGNAME in prototype file
- rm -rf $EXTRACTDIR $TMPARCHIVE
- exit 1
- fi
- fi
-
egrep 'd none /opt ' $EXTRACTDIR/$pkgname/pkgmap
if [[ $? -eq 0 ]] ; then
errmsg You should not have an entry for /opt in your prototype file
Modified: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-archall.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-archall.py 2010-02-28 16:35:23 UTC (rev 8891)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-archall.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -16,7 +16,7 @@
"..", "..", "lib", "python"]
sys.path.append(os.path.join(*path_list))
import checkpkg
-import package_checks
+import package_checks_old
def main():
options, args = checkpkg.GetOptions()
@@ -29,7 +29,7 @@
options.debug)
check_manager.RegisterIndividualCheck(
- package_checks.CheckArchitectureVsContents)
+ package_checks_old.CheckArchitectureVsContents)
exit_code, screen_report, tags_report = check_manager.Run()
f = open(options.output, "w")
f.write(tags_report)
Added: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py (rev 0)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -0,0 +1,48 @@
+#!/opt/csw/bin/python2.6
+# $Id$
+
+"""This is a dummy check. You can use it as a boilerplate for your own checks.
+
+Copy it and modify.
+"""
+
+import logging
+import os.path
+import sys
+import re
+
+CHECKPKG_MODULE_NAME = "Second checkpkg API version"
+
+# The following bit of code sets the correct path to Python libraries
+# distributed with GAR.
+path_list = [os.path.dirname(__file__),
+ "..", "..", "lib", "python"]
+sys.path.append(os.path.join(*path_list))
+import checkpkg
+import opencsw
+
+
+def main():
+ options, args = checkpkg.GetOptions()
+ if options.debug:
+ logging.basicConfig(level=logging.DEBUG)
+ else:
+ logging.basicConfig(level=logging.INFO)
+ md5sums = args
+ # CheckpkgManager2 class abstracts away things such as the collection of
+ # results.
+ check_manager = checkpkg.CheckpkgManager2(CHECKPKG_MODULE_NAME,
+ options.stats_basedir,
+ md5sums,
+ options.debug)
+ # Running the checks, reporting and exiting.
+ exit_code, screen_report, tags_report = check_manager.Run()
+ f = open(options.output, "w")
+ f.write(tags_report)
+ f.close()
+ print screen_report.strip()
+ sys.exit(exit_code)
+
+
+if __name__ == '__main__':
+ main()
Property changes on: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-auto.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Id
Modified: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py 2010-02-28 16:35:23 UTC (rev 8891)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -17,7 +17,7 @@
"..", "..", "lib", "python"]
sys.path.append(os.path.join(*path_list))
import checkpkg
-import package_checks
+import package_checks_old
def main():
options, args = checkpkg.GetOptions()
@@ -29,9 +29,12 @@
md5sums,
options.debug)
# Registering functions defined above.
- check_manager.RegisterIndividualCheck(package_checks.CatalognameLowercase)
- check_manager.RegisterIndividualCheck(package_checks.FileNameSanity)
- check_manager.RegisterIndividualCheck(package_checks.PkginfoSanity)
+ check_manager.RegisterIndividualCheck(package_checks_old.CatalognameLowercase)
+ check_manager.RegisterIndividualCheck(package_checks_old.FileNameSanity)
+ check_manager.RegisterIndividualCheck(package_checks_old.PkginfoSanity)
+ check_manager.RegisterIndividualCheck(package_checks_old.ArchitectureSanity)
+ check_manager.RegisterIndividualCheck(package_checks_old.CheckBuildingUser)
+ check_manager.RegisterIndividualCheck(package_checks_old.CheckPkgmapPaths)
# Running the checks, reporting and exiting.
exit_code, screen_report, tags_report = check_manager.Run()
f = open(options.output, "w")
Modified: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-missing-symbols.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-missing-symbols.py 2010-02-28 16:35:23 UTC (rev 8891)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-missing-symbols.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -19,7 +19,7 @@
"..", "..", "lib", "python"]
sys.path.append(os.path.join(*path_list))
import checkpkg
-import package_checks
+import package_checks_old
# Defining checking functions.
@@ -33,7 +33,7 @@
md5sums,
options.debug)
# Registering functions defined above.
- check_manager.RegisterSetCheck(package_checks.CheckForMissingSymbols)
+ check_manager.RegisterSetCheck(package_checks_old.CheckForMissingSymbols)
# Running the checks, reporting and exiting.
exit_code, screen_report, tags_report = check_manager.Run()
f = open(options.output, "w")
Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py 2010-02-28 16:35:23 UTC (rev 8891)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -19,6 +19,7 @@
import yaml
from Cheetah import Template
import opencsw
+import package_checks
SYSTEM_PKGMAP = "/var/sadm/install/contents"
WS_RE = re.compile(r"\s+")
@@ -30,6 +31,7 @@
DO_NOT_REPORT_MISSING = set([])
DO_NOT_REPORT_MISSING_RE = [r"SUNW.*", r"\*SUNW.*"]
DUMP_BIN = "/usr/ccs/bin/dump"
+PSTAMP_RE = r"(?P<username>\w)+@(?P<hostname>\w+)-(?P<timestamp>\d+)"
SYSTEM_SYMLINKS = (
("/opt/csw/bdb4", ["/opt/csw/bdb42"]),
@@ -162,6 +164,14 @@
return m.group(1) if m else None
+def ExtractBuildUsername(pkginfo):
+ m = re.match(PSTAMP_RE, pkginfo["PSTAMP"])
+ if m:
+ return m.group("username")
+ else:
+ return None
+
+
class SystemPkgmap(object):
"""A class to hold and manipulate the /var/sadm/install/contents file.
@@ -704,8 +714,8 @@
-class CheckpkgManager(object):
- """Takes care of calling checking functions"""
+class CheckpkgManagerBase(object):
+ """Common functions between the older and newer calling functions."""
def __init__(self, name, stats_basedir, md5sum_list, debug=False):
self.debug = debug
@@ -717,44 +727,12 @@
self.set_checks = []
self.packages = []
- def RegisterIndividualCheck(self, function):
- self.individual_checks.append(function)
-
- def RegisterSetCheck(self, function):
- self.set_checks.append(function)
-
def GetPackageStatsList(self):
stats_list = []
for md5sum in self.md5sum_list:
stats_list.append(PackageStats(None, self.stats_basedir, md5sum))
return stats_list
- def GetAllTags(self, packages_data):
- errors = {}
- for pkg_data in packages_data:
- for function in self.individual_checks:
- all_stats = pkg_data.GetAllStats()
- errors_for_pkg = function(all_stats, debug=self.debug)
- if errors_for_pkg:
- errors[all_stats["basic_stats"]["pkgname"]] = errors_for_pkg
- # Set checks
- for function in self.set_checks:
- set_errors = function([x.GetAllStats() for x in packages_data],
- debug=self.debug)
- if set_errors:
- # These were generated by a set, but are likely to be bound to specific
- # packages. We'll try to preserve the package assignments.
- for tag in set_errors:
- if tag.pkgname:
- if not tag.pkgname in errors:
- errors[tag.pkgname] = []
- errors[tag.pkgname].append(tag)
- else:
- if "package-set" not in errors:
- errors["package-set"] = []
- errors["package-set"].append(error)
- return errors
-
def FormatReports(self, errors):
namespace = {
"name": self.name,
@@ -780,6 +758,131 @@
return (exit_code, screen_report, tags_report)
+class CheckpkgManager(CheckpkgManagerBase):
+ """Takes care of calling checking functions.
+
+ This is an old API as of 2010-02-28.
+ """
+ def RegisterIndividualCheck(self, function):
+ self.individual_checks.append(function)
+
+ def RegisterSetCheck(self, function):
+ self.set_checks.append(function)
+
+ def SetErrorsToDict(self, set_errors, a_dict):
+ # These were generated by a set, but are likely to be bound to specific
+ # packages. We'll try to preserve the package assignments.
+ for tag in set_errors:
+ if tag.pkgname:
+ if not tag.pkgname in errors:
+ errors[tag.pkgname] = []
+ errors[tag.pkgname].append(tag)
+ else:
+ if "package-set" not in errors:
+ errors["package-set"] = []
+ errors["package-set"].append(error)
+ return a_dict
+
+ def GetAllTags(self, packages_data):
+ errors = {}
+ for pkg_data in packages_data:
+ for function in self.individual_checks:
+ all_stats = pkg_data.GetAllStats()
+ errors_for_pkg = function(all_stats, debug=self.debug)
+ if errors_for_pkg:
+ errors[all_stats["basic_stats"]["pkgname"]] = errors_for_pkg
+ # Set checks
+ for function in self.set_checks:
+ set_errors = function([x.GetAllStats() for x in packages_data],
+ debug=self.debug)
+ if set_errors:
+ errors = self.SetErrorsToDict(set_errors, errors)
+ return errors
+
+
+class CheckpkgManager2(CheckpkgManagerBase):
+ """The second incarnation of the checkpkg manager.
+
+ Implements the API to be used by checking functions.
+
+ Its purpose is to reduce the amount of boilerplate code and allow for easier
+ unit test writing.
+ """
+ class IndividualErrorGatherer(object):
+ """To be passed to the checking functions.
+
+ Wraps the creation of CheckpkgTag objects.
+ """
+
+ def __init__(self, pkgname):
+ self.pkgname = pkgname
+ self.errors = []
+
+ def ReportError(self, tag_name, tag_info=None, msg=None):
+ self.errors.append(
+ CheckpkgTag(self.pkgname, tag_name, tag_info, msg))
+
+ def SetErrorGatherer(object):
+ """To be bassed to set checking functions."""
+ def __init__(self):
+ self.errors = []
+
+ def ReportError(self, pkgname, tag_name, tag_info=None, msg=None):
+ self.errors.append(
+ CheckpkgTag(pkgname, tag_name, tag_info, msg))
+
+ def _RegisterIndividualCheck(self, function):
+ self.individual_checks.append(function)
+
+ def _RegisterSetCheck(self, function):
+ self.set_checks.append(function)
+
+ def _AutoregisterChecks(self):
+ """Autodetects all defined checks."""
+ logging.debug("CheckpkgManager2._AutoregisterChecks()")
+ checkpkg_module = package_checks
+ members = dir(checkpkg_module)
+ for member_name in members:
+ logging.debug("member_name: %s", repr(member_name))
+ member = getattr(checkpkg_module, member_name)
+ if callable(member):
+ if member_name.startswith("Check"):
+ logging.debug("Registering individual check %s", repr(member_name))
+ self._RegisterIndividualCheck(member)
+ elif member_name.startswith("SetCheck"):
+ logging.debug("Registering set check %s", repr(member_name))
+ self._RegisterIndividualCheck(member)
+
+ def GetAllTags(self, packages_data):
+ errors = {}
+ logging_level = logging.INFO
+ if self.debug:
+ logging_level = logging.DEBUG
+ # Individual checks
+ for pkg_data in packages_data:
+ for function in self.individual_checks:
+ all_stats = pkg_data.GetAllStats()
+ pkgname = all_stats["basic_stats"]["pkgname"]
+ error_mgr = self.IndividualErrorGatherer(pkgname)
+ logger = logging.getLogger(pkgname)
+ function(all_stats, error_mgr, logger=logger)
+ if error_mgr.errors:
+ errors[pkgname] = error_mgr.errors
+ # Set checks
+ for function in self.set_checks:
+ pkgs_data = [x.GetAllStats() for x in packages_data]
+ logger = logging.getLogger("SetCheck %s" % function)
+ error_mgr = self.SetErrorGatherer()
+ function(pkgs_data, error_mgr, logger)
+ if error_mgr.errors:
+ errors = self.SetErrorsToDict(error_mgr.errors, errors)
+ return errors
+
+ def Run(self):
+ self._AutoregisterChecks()
+ return super(CheckpkgManager2, self).Run()
+
+
def ParseTagLine(line):
"""Parses a line from the tag.${module} file.
@@ -1142,18 +1245,18 @@
in_file_name = os.path.join(stats_path, "%s.yml" % name)
in_file_name_pickle = os.path.join(stats_path, "%s.pickle" % name)
if os.path.exists(in_file_name_pickle):
- logging.debug("ReadObject(): reading %s", repr(in_file_name_pickle))
+ # logging.debug("ReadObject(): reading %s", repr(in_file_name_pickle))
f = open(in_file_name_pickle, "r")
obj = cPickle.load(f)
f.close()
- logging.debug("ReadObject(): finished reading %s",
- repr(in_file_name_pickle))
+ # logging.debug("ReadObject(): finished reading %s",
+ # repr(in_file_name_pickle))
else:
- logging.debug("ReadObject(): reading %s", repr(in_file_name))
+ # logging.debug("ReadObject(): reading %s", repr(in_file_name))
f = open(in_file_name, "r")
obj = yaml.safe_load(f)
f.close()
- logging.debug("ReadObject(): finished reading %s", repr(in_file_name))
+ # logging.debug("ReadObject(): finished reading %s", repr(in_file_name))
return obj
def ReadSavedStats(self):
Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py 2010-02-28 16:35:23 UTC (rev 8891)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -4,286 +4,13 @@
# - individual package checks
# - set checks
#
-# Some ideas for the future development of the checks. Here's what a check
-# could look like:
+# Individual checks need to be named "Check<something>", while set checks are named
+# "SetCheck<something>".
#
-# class FooCheck(checkpkg.IndividualCheck):
-# """Simplest check for an individual package."""
-#
-# def CheckExampleOne(self):
-# """First idea, with an ReportError method."""
-# if self.catalogname != self.catalogname.lower():
-# self.ReportError("catalogname-not-lowercase")
-#
-# def CheckExampleTwo(self):
-# """Second idea, more similar to a unit test."""
-# self.checkEqual(self.catalogname,
-# self.catalogname.lower(),
-# "catalogname-not-lowercase")
-#
-# What would be needed to do that:
-#
-# - Have a class that looks for classes derived from checkpkg.IndividualCheck,
-# run SetUp on them (which sets things such as self.catalogname) and then
-# Check().
-# - Read all the data and set appropriate member names.
-#
-# Set checks would be slightly more complicated.
-#
-# class BarCheck(checkpkg.SetCheck):
-# """More complex check for multiple packages.
-#
-# We cannot have package data as class members any more, we have to use
-# a class member with a list of objects containing packages' data.
-#
-# In this class, checkEqual() methods needs one more parameter, denoting
-# the package to assign the error to.
-# """
-#
-# def Check(self):
-# for pkg in self.pkgs:
-# self.checkEqual(pkg.catalogname,
-# pkg.catalogname.lower(),
-# pkg,
-# "catalogname-not-lowercase")
-#
-# A question: What would unit tests of these checks look like?
-#
-# Alternately, a function-based approach is possible:
-#
-# def IndividualCheckCatalogname(pkg_data, checkpkg_mgr, debug):
-# catalogname = pkg_data["basic_stats"]["catalogname"]
-# if catalogname != catalogname.lower():
-# checkpkg_mgr.ReportError("catalogname-not-lowercase")
-#
-# Here, unit testing of these functions would always require mock objects. But
-# overall it looks like a simpler approach.
-#
-# Instead of the debug flag, a logger could be used, although it would make
-# testing slightly annoying, since it would be necessary to mock
-# all the calls to the logger.
-#
-# def IndividualCheckCatalogname(pkg_data, checkpkg_mgr, logger):
-# catalogname = pkg_data["basic_stats"]["catalogname"]
-# logger.debug("catalogname: %s", catalogname)
-# if catalogname != catalogname.lower():
-# checkpkg_mgr.ReportError("catalogname-not-lowercase")
-#
-#
+# def CheckSomething(pkg_data, error_mgr, logger):
+# logger.debug("Checking something.")
+# error_mgr.ReportError("something-is-wrong")
-import checkpkg
-import re
-
-ARCH_RE = re.compile(r"(sparcv(8|9)|i386|amd64)")
-
-MAX_CATALOGNAME_LENGTH = 20
-MAX_PKGNAME_LENGTH = 20
-MAX_DESCRIPTION_LENGTH = 100
-ARCH_LIST = ["sparc", "i386", "all"]
-VERSION_RE = r".*,REV=(20[01][0-9]\.[0-9][0-9]\.[0-9][0-9]).*"
-
-def CatalognameLowercase(pkg_data, debug):
- errors = []
- # Here's how to report an error:
- catalogname = pkg_data["basic_stats"]["catalogname"]
- if catalogname != catalogname.lower():
- errors.append(checkpkg.CheckpkgTag(
- pkg_data["basic_stats"]["pkgname"],
- "catalogname-not-lowercase"))
- if not re.match(r"^\w+$", catalogname):
- errors.append(checkpkg.CheckpkgTag(
- pkg_data["basic_stats"]["pkgname"],
- "catalogname-is-not-a-simple-word"))
- return errors
-
-
-def FileNameSanity(pkg_data, debug):
- errors = []
- basic_stats = pkg_data["basic_stats"]
- revision_info = basic_stats["parsed_basename"]["revision_info"]
- catalogname = pkg_data["basic_stats"]["catalogname"]
- pkgname = pkg_data["basic_stats"]["pkgname"]
- if "REV" not in revision_info:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "rev-tag-missing-in-filename"))
- if len(catalogname) > MAX_CATALOGNAME_LENGTH:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "catalogname-too-long"))
- if len(pkgname) > MAX_PKGNAME_LENGTH:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "pkgname-too-long"))
- if basic_stats["parsed_basename"]["osrel"] == "unspecified":
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "osrel-tag-not-specified"))
- return errors
-
-
-def PkginfoSanity(pkg_data, debug):
- """pkginfo sanity checks.
-
-if [ "$maintname" = "" ] ; then
- # the old format, in the DESC field
- maintname=`sed -n 's/^DESC=.*for CSW by //p' $TMPFILE`
-
- # Since the DESC field has been coopted, take
- # description from second half of NAME field now.
- desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
-else
- if [ "$desc" = "" ] ; then
- desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
- fi
-fi
-
-software=`sed -n 's/^NAME=\([^ -]*\) -.*$/\1/p' $TMPFILE`
-version=`sed -n 's/^VERSION=//p' $TMPFILE`
-desc=`sed -n 's/^DESC=//p' $TMPFILE`
-email=`sed -n 's/^EMAIL=//p' $TMPFILE`
-maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
-hotline=`sed -n 's/^HOTLINE=//p' $TMPFILE`
-basedir=`sed -n 's/^BASEDIR=//p' $TMPFILE`
-pkgarch=`sed -n 's/^ARCH=//p' $TMPFILE|head -1`
-
-if [ "$software" = "" ] ; then errmsg $f: software field not set properly in NAME ; fi
-if [ "$pkgname" = "" ] ; then errmsg $f: pkgname field blank ; fi
-if [ "$desc" = "" ] ; then errmsg $f: no description in either NAME or DESC field ; fi
-if [ ${#desc} -gt 100 ] ; then errmsg $f: description greater than 100 chars ; fi
-if [ "$version" = "" ] ; then errmsg $f: VERSION field blank ; fi
-if [ "$maintname" = "" ] ; then errmsg $f: maintainer name not detected. Fill out VENDOR field properly ; fi
-if [ "$email" = "" ] ; then errmsg $f: EMAIL field blank ; fi
-if [ "$hotline" = "" ] ; then errmsg $f: HOTLINE field blank ; fi
- """
- errors = []
- catalogname = pkg_data["basic_stats"]["catalogname"]
- pkgname = pkg_data["basic_stats"]["pkgname"]
- pkginfo = pkg_data["pkginfo"]
- if not catalogname:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "empty-catalogname"))
- if not pkgname:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "empty-pkgname"))
- if not "VERSION" in pkginfo or not pkginfo["VERSION"]:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "pkginfo-version-field-missing"))
- desc = checkpkg.ExtractDescription(pkginfo)
- if not desc:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "description-missing"))
- if len(desc) > MAX_DESCRIPTION_LENGTH:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "description-too-long"))
- # maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
- maintname = checkpkg.ExtractMaintainerName(pkginfo)
- if not maintname:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "maintainer-name-not-set"))
- # email
- if not pkginfo["EMAIL"]:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "email-blank"))
- # hotline
- if not pkginfo["HOTLINE"]:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "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"))
- 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))
- if pkginfo["ARCH"] not in ARCH_LIST:
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "non-standard-architecture", pkginfo["ARCH"]))
- return errors
-
-
-def ArchitectureSanity(pkg_data, debug):
- errors = []
- basic_stats = pkg_data["basic_stats"]
- pkgname = basic_stats["pkgname"]
- pkginfo = pkg_data["pkginfo"]
- filename = basic_stats["pkg_basename"]
- arch = pkginfo["ARCH"]
- filename_re = r"-%s-" % arch
- if not re.search(filename_re, filename):
- errors.append(checkpkg.CheckpkgTag(
- pkgname, "srv4-filename-architecture-mismatch", arch))
-
-
-def CheckArchitectureVsContents(pkg_data, debug):
- """Verifies the relationship between package contents and architecture."""
- errors = []
- binaries = pkg_data["binaries"]
- pkginfo = pkg_data["pkginfo"]
- pkgmap = pkg_data["pkgmap"]
- arch = pkginfo["ARCH"]
- pkgname = pkg_data["basic_stats"]["pkgname"]
- reasons_to_be_arch_specific = []
- pkgmap_paths = [x["path"] for x in pkgmap]
- for pkgmap_path in pkgmap_paths:
- if re.search(ARCH_RE, str(pkgmap_path)):
- reasons_to_be_arch_specific.append((
- "archall-with-arch-paths",
- pkgmap_path,
- "path %s looks arch-specific" % pkgmap_path))
- for binary in binaries:
- reasons_to_be_arch_specific.append((
- "archall-with-binaries",
- binary,
- "package contains binary %s" % binary))
- if arch == "all":
- for tag, param, desc in reasons_to_be_arch_specific:
- errors.append(checkpkg.CheckpkgTag(pkgname, tag, param))
- elif not reasons_to_be_arch_specific:
- # This is not a clean way of handling messages for the user, but there's
- # not better way at the moment.
- print "Package %s does not contain any binaries." % pkgname
- print "Consider making it ARCHALL = 1 instead of %s:" % arch
- print "ARCHALL_%s = 1" % pkgname
- print ("However, be aware that there might be other reasons "
- "to keep it architecture-specific.")
- return errors
-
-
-def CheckForMissingSymbols(pkgs_data, debug):
- """Analyzes missing symbols reported by ldd -r.
-
- 1. Collect triplets: pkgname, binary, missing symbol
- 2. If there are any missing symbols, collect all the symbols that are provided
- by the set of packages.
- 3. From the list of missing symbols, remove all symbols that are provided
- by the set of packages.
- 4. Report any remaining symbols as errors.
-
- What indexes do we need?
-
- symbol -> (pkgname, binary)
- set(allsymbols)
- """
- errors = []
- missing_symbols = []
- all_symbols = set()
- for pkg_data in pkgs_data:
- pkgname = pkg_data["basic_stats"]["pkgname"]
- binaries = pkg_data["binaries"]
- for binary in binaries:
- for ldd_elem in pkg_data["ldd_dash_r"][binary]:
- if ldd_elem["state"] == "symbol-not-found":
- missing_symbols.append((pkgname,
- binary,
- ldd_elem["symbol"]))
- for symbol in pkg_data["defined_symbols"][binary]:
- all_symbols.add(symbol)
- # Remove symbols defined elsewhere.
- while missing_symbols:
- ms_pkgname, ms_binary, ms_symbol = missing_symbols.pop()
- if ms_symbol not in all_symbols:
- errors.append(checkpkg.CheckpkgTag(
- ms_pkgname, "symbol-not-found", "%s %s" % (ms_binary, ms_symbol)))
- return errors
+def CheckPkgmap(pkg_data, error_mgr, logger):
+ # error_mgr.ReportError("foo")
+ pass
Copied: csw/mgar/gar/v2/lib/python/package_checks_old.py (from rev 8886, csw/mgar/gar/v2/lib/python/package_checks.py)
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_old.py (rev 0)
+++ csw/mgar/gar/v2/lib/python/package_checks_old.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -0,0 +1,258 @@
+#!/opt/csw/bin/python2.6
+# coding=utf-8
+# $Id$
+
+import checkpkg
+import re
+
+ARCH_RE = re.compile(r"(sparcv(8|9)|i386|amd64)")
+
+MAX_CATALOGNAME_LENGTH = 20
+MAX_PKGNAME_LENGTH = 20
+MAX_DESCRIPTION_LENGTH = 100
+ARCH_LIST = ["sparc", "i386", "all"]
+VERSION_RE = r".*,REV=(20[01][0-9]\.[0-9][0-9]\.[0-9][0-9]).*"
+ONLY_ALLOWED_IN_PKG = {
+ "CSWcommon": ("/opt", "",)
+}
+
+def CatalognameLowercase(pkg_data, debug):
+ errors = []
+ # Here's how to report an error:
+ catalogname = pkg_data["basic_stats"]["catalogname"]
+ if catalogname != catalogname.lower():
+ errors.append(checkpkg.CheckpkgTag(
+ pkg_data["basic_stats"]["pkgname"],
+ "catalogname-not-lowercase"))
+ if not re.match(r"^\w+$", catalogname):
+ errors.append(checkpkg.CheckpkgTag(
+ pkg_data["basic_stats"]["pkgname"],
+ "catalogname-is-not-a-simple-word"))
+ return errors
+
+
+def FileNameSanity(pkg_data, debug):
+ errors = []
+ basic_stats = pkg_data["basic_stats"]
+ revision_info = basic_stats["parsed_basename"]["revision_info"]
+ catalogname = pkg_data["basic_stats"]["catalogname"]
+ pkgname = pkg_data["basic_stats"]["pkgname"]
+ if "REV" not in revision_info:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "rev-tag-missing-in-filename"))
+ if len(catalogname) > MAX_CATALOGNAME_LENGTH:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "catalogname-too-long"))
+ if len(pkgname) > MAX_PKGNAME_LENGTH:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "pkgname-too-long"))
+ if basic_stats["parsed_basename"]["osrel"] == "unspecified":
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "osrel-tag-not-specified"))
+ return errors
+
+
+def PkginfoSanity(pkg_data, debug):
+ """pkginfo sanity checks.
+
+if [ "$maintname" = "" ] ; then
+ # the old format, in the DESC field
+ maintname=`sed -n 's/^DESC=.*for CSW by //p' $TMPFILE`
+
+ # Since the DESC field has been coopted, take
+ # description from second half of NAME field now.
+ desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
+else
+ if [ "$desc" = "" ] ; then
+ desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
+ fi
+fi
+
+software=`sed -n 's/^NAME=\([^ -]*\) -.*$/\1/p' $TMPFILE`
+version=`sed -n 's/^VERSION=//p' $TMPFILE`
+desc=`sed -n 's/^DESC=//p' $TMPFILE`
+email=`sed -n 's/^EMAIL=//p' $TMPFILE`
+maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
+hotline=`sed -n 's/^HOTLINE=//p' $TMPFILE`
+basedir=`sed -n 's/^BASEDIR=//p' $TMPFILE`
+pkgarch=`sed -n 's/^ARCH=//p' $TMPFILE|head -1`
+
+if [ "$software" = "" ] ; then errmsg $f: software field not set properly in NAME ; fi
+if [ "$pkgname" = "" ] ; then errmsg $f: pkgname field blank ; fi
+if [ "$desc" = "" ] ; then errmsg $f: no description in either NAME or DESC field ; fi
+if [ ${#desc} -gt 100 ] ; then errmsg $f: description greater than 100 chars ; fi
+if [ "$version" = "" ] ; then errmsg $f: VERSION field blank ; fi
+if [ "$maintname" = "" ] ; then errmsg $f: maintainer name not detected. Fill out VENDOR field properly ; fi
+if [ "$email" = "" ] ; then errmsg $f: EMAIL field blank ; fi
+if [ "$hotline" = "" ] ; then errmsg $f: HOTLINE field blank ; fi
+ """
+ errors = []
+ catalogname = pkg_data["basic_stats"]["catalogname"]
+ pkgname = pkg_data["basic_stats"]["pkgname"]
+ pkginfo = pkg_data["pkginfo"]
+ if not catalogname:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "empty-catalogname"))
+ if not pkgname:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "empty-pkgname"))
+ if not "VERSION" in pkginfo or not pkginfo["VERSION"]:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "pkginfo-version-field-missing"))
+ desc = checkpkg.ExtractDescription(pkginfo)
+ if not desc:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "description-missing"))
+ if len(desc) > MAX_DESCRIPTION_LENGTH:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "description-too-long"))
+ # maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
+ maintname = checkpkg.ExtractMaintainerName(pkginfo)
+ if not maintname:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "maintainer-name-not-set"))
+ # email
+ if not pkginfo["EMAIL"]:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "email-blank"))
+ # hotline
+ if not pkginfo["HOTLINE"]:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "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"))
+ 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))
+ if pkginfo["ARCH"] not in ARCH_LIST:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "non-standard-architecture", pkginfo["ARCH"]))
+ if "PSTAMP" in pkginfo:
+ if not re.match(checkpkg.PSTAMP_RE, pkginfo["PSTAMP"]):
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "pkginfo-pkstamp-in-wrong-format",
+ msg=("It should be 'username at hostname-timestamp', "
+ "but it's %s." % repr(pkginfo["PSTAMP"]))))
+ else:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "pkginfo-pstamp-missing"))
+ return errors
+
+
+def ArchitectureSanity(pkg_data, debug):
+ errors = []
+ basic_stats = pkg_data["basic_stats"]
+ pkgname = basic_stats["pkgname"]
+ pkginfo = pkg_data["pkginfo"]
+ filename = basic_stats["pkg_basename"]
+ arch = pkginfo["ARCH"]
+ filename_re = r"-%s-" % arch
+ if not re.search(filename_re, filename):
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "srv4-filename-architecture-mismatch", arch))
+ return errors
+
+
+def CheckArchitectureVsContents(pkg_data, debug):
+ """Verifies the relationship between package contents and architecture."""
+ errors = []
+ binaries = pkg_data["binaries"]
+ pkginfo = pkg_data["pkginfo"]
+ pkgmap = pkg_data["pkgmap"]
+ arch = pkginfo["ARCH"]
+ pkgname = pkg_data["basic_stats"]["pkgname"]
+ reasons_to_be_arch_specific = []
+ pkgmap_paths = [x["path"] for x in pkgmap]
+ for pkgmap_path in pkgmap_paths:
+ if re.search(ARCH_RE, str(pkgmap_path)):
+ reasons_to_be_arch_specific.append((
+ "archall-with-arch-paths",
+ pkgmap_path,
+ "path %s looks arch-specific" % pkgmap_path))
+ for binary in binaries:
+ reasons_to_be_arch_specific.append((
+ "archall-with-binaries",
+ binary,
+ "package contains binary %s" % binary))
+ if arch == "all":
+ for tag, param, desc in reasons_to_be_arch_specific:
+ errors.append(checkpkg.CheckpkgTag(pkgname, tag, param))
+ elif not reasons_to_be_arch_specific:
+ # This is not a clean way of handling messages for the user, but there's
+ # not better way at the moment.
+ print "Package %s does not contain any binaries." % pkgname
+ print "Consider making it ARCHALL = 1 instead of %s:" % arch
+ print "ARCHALL_%s = 1" % pkgname
+ print ("However, be aware that there might be other reasons "
+ "to keep it architecture-specific.")
+ return errors
+
+
+def CheckForMissingSymbols(pkgs_data, debug):
+ """Analyzes missing symbols reported by ldd -r.
+
+ 1. Collect triplets: pkgname, binary, missing symbol
+ 2. If there are any missing symbols, collect all the symbols that are provided
+ by the set of packages.
+ 3. From the list of missing symbols, remove all symbols that are provided
+ by the set of packages.
+ 4. Report any remaining symbols as errors.
+
+ What indexes do we need?
+
+ symbol -> (pkgname, binary)
+ set(allsymbols)
+ """
+ errors = []
+ missing_symbols = []
+ all_symbols = set()
+ for pkg_data in pkgs_data:
+ pkgname = pkg_data["basic_stats"]["pkgname"]
+ binaries = pkg_data["binaries"]
+ for binary in binaries:
+ for ldd_elem in pkg_data["ldd_dash_r"][binary]:
+ if ldd_elem["state"] == "symbol-not-found":
+ missing_symbols.append((pkgname,
+ binary,
+ ldd_elem["symbol"]))
+ for symbol in pkg_data["defined_symbols"][binary]:
+ all_symbols.add(symbol)
+ # Remove symbols defined elsewhere.
+ while missing_symbols:
+ ms_pkgname, ms_binary, ms_symbol = missing_symbols.pop()
+ if ms_symbol not in all_symbols:
+ errors.append(checkpkg.CheckpkgTag(
+ ms_pkgname, "symbol-not-found", "%s %s" % (ms_binary, ms_symbol)))
+ return errors
+
+
+def CheckBuildingUser(pkg_data, debug):
+ errors = []
+ pkgname = pkg_data["basic_stats"]["pkgname"]
+ username = checkpkg.ExtractBuildUsername(pkg_data["pkginfo"])
+ for entry in pkg_data["pkgmap"]:
+ if entry["user"] and entry["user"] == username:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname,
+ "file-owned-by-building-user",
+ "%s, %s" % (entry["path"], entry["user"])))
+ return errors
+
+def CheckPkgmapPaths(pkg_data, debug):
+ errors = []
+ username = checkpkg.ExtractBuildUsername(pkg_data["pkginfo"])
+ for entry in pkg_data["pkgmap"]:
+ file_path = entry["path"]
+ if file_path == "/opt":
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname,
+ ("wrong-path-in-pkgmap", file_path)))
+ return errors
+
Copied: csw/mgar/gar/v2/lib/python/package_checks_old_test.py (from rev 8886, csw/mgar/gar/v2/lib/python/package_checks_test.py)
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_old_test.py (rev 0)
+++ csw/mgar/gar/v2/lib/python/package_checks_old_test.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -0,0 +1,129 @@
+#!/opt/csw/bin/python2.6
+# coding=utf-8
+# $Id$
+
+import unittest
+import package_checks_old as pc
+import yaml
+import os.path
+
+BASE_DIR = os.path.dirname(__file__)
+TESTDATA_DIR = os.path.join(BASE_DIR, "testdata")
+
+class PackageChecksUnitTest(unittest.TestCase):
+
+ def setUp(self):
+ self.pkg_data_1 = {
+ "basic_stats": {
+ "pkgname": "CSWfoo"
+ }
+ }
+ self.pkg_data_2 = {
+ 'basic_stats': {
+ 'parsed_basename':
+ {'revision_info': {'REV': '2010.02.15'},
+ 'catalogname': 'python_tk',
+ 'full_version_string': '2.6.4,REV=2010.02.15',
+ 'version': '2.6.4',
+ 'version_info': {
+ 'minor version': '6',
+ 'major version': '2',
+ 'patchlevel': '4'},
+ 'osrel': 'SunOS5.8',
+ 'arch': 'sparc',
+ 'vendortag': 'CSW',
+ },
+ 'pkgname': 'CSWpython-tk',
+ 'stats_version': 1,
+ 'pkg_basename': 'python_tk-2.6.4,REV=2010.02.15-SunOS5.8-sparc-CSW.pkg.gz',
+ 'pkg_path': '/tmp/pkg_lL0HDH/python_tk-2.6.4,REV=2010.02.15-SunOS5.8-sparc-CSW.pkg.gz',
+ 'catalogname': 'python_tk'}}
+
+ def LoadData(self, name):
+ file_name = os.path.join(TESTDATA_DIR, "%s.yml" % name)
+ f = open(file_name, "rb")
+ data = yaml.safe_load(f)
+ f.close()
+ return data
+
+ def testCatalogName_1(self):
+ self.pkg_data_1["basic_stats"]["catalogname"] = "Foo"
+ errors = pc.CatalognameLowercase(self.pkg_data_1, False)
+ self.failUnless(errors)
+
+ def testCatalogName_2(self):
+ self.pkg_data_1["basic_stats"]["catalogname"] = "foo"
+ errors = pc.CatalognameLowercase(self.pkg_data_1, False)
+ self.failIf(errors)
+
+ def testCatalogNameSpecialCharacters(self):
+ self.pkg_data_1["basic_stats"]["catalogname"] = "foo+abc&123"
+ errors = pc.CatalognameLowercase(self.pkg_data_1, False)
+ self.failUnless(errors)
+
+ def testFileNameSanity(self):
+ del(self.pkg_data_2["basic_stats"]["parsed_basename"]["revision_info"]["REV"])
+ errors = pc.FileNameSanity(self.pkg_data_2, False)
+ self.failUnless(errors)
+
+ def testCheckArchitectureVsContents(self):
+ self.pkg_data_2["pkgmap"] = self.LoadData("example-1-pkgmap")
+ self.pkg_data_2["binaries"] = []
+ self.pkg_data_2["pkginfo"] = self.LoadData("example-1-pkginfo")
+ errors = pc.CheckArchitectureVsContents(self.pkg_data_2, False)
+ self.failIf(errors)
+
+ def testCheckForMissingSymbols(self):
+ ldd_dash_r_yml = """opt/csw/lib/postgresql/8.4/_int.so:
+- {path: /usr/lib/libc.so.1, soname: libc.so.1, state: OK, symbol: null}
+- {path: /usr/lib/libdl.so.1, soname: libdl.so.1, state: OK, symbol: null}
+- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
+ state: symbol-not-found, symbol: CurrentMemoryContext}
+- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
+ state: symbol-not-found, symbol: MemoryContextAlloc}
+- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
+ state: symbol-not-found, symbol: errstart}
+- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
+ state: symbol-not-found, symbol: errcode}
+opt/csw/lib/postgresql/8.4/_int2.so:
+- {path: /usr/lib/libdl.so.1, soname: libdl.so.1, state: OK, symbol: null}"""
+ defined_symbols_yml = """opt/csw/lib/postgresql/8.4/_int.so: [Pg_magic_func, _fini, _init, _int_contained,
+ _int_contains, _int_different, _int_inter, _int_overlap, _int_same, _int_union,
+ _int_unique, _intbig_in, _intbig_out, boolop, bqarr_in, bqarr_out, compASC, compDESC,
+ copy_intArrayType, execconsistent, g_int_compress, g_int_consistent, g_int_decompress,
+ g_int_penalty, g_int_picksplit, g_int_same, g_int_union, g_intbig_compress, g_intbig_consistent,
+ g_intbig_decompress, g_intbig_penalty, g_intbig_picksplit, g_intbig_same, g_intbig_union,
+ gensign, ginconsistent, ginint4_consistent, ginint4_queryextract, icount, idx, inner_int_contains,
+ inner_int_inter, inner_int_overlap, inner_int_union, int_to_intset, intarray_add_elem,
+ intarray_concat_arrays, intarray_del_elem, intarray_match_first, intarray_push_array,
+ intarray_push_elem, internal_size, intset, intset_subtract, intset_union_elem, isort,
+ new_intArrayType, pg_finfo__int_contained, pg_finfo__int_contains, pg_finfo__int_different,
+ pg_finfo__int_inter, pg_finfo__int_overlap, pg_finfo__int_same, pg_finfo__int_union,
+ pg_finfo__intbig_in, pg_finfo__intbig_out, pg_finfo_boolop, pg_finfo_bqarr_in, pg_finfo_bqarr_out,
+ pg_finfo_g_int_compress, pg_finfo_g_int_consistent, pg_finfo_g_int_decompress, pg_finfo_g_int_penalty,
+ pg_finfo_g_int_picksplit, pg_finfo_g_int_same, pg_finfo_g_int_union, pg_finfo_g_intbig_compress,
+ pg_finfo_g_intbig_consistent, pg_finfo_g_intbig_decompress, pg_finfo_g_intbig_penalty,
+ pg_finfo_g_intbig_picksplit, pg_finfo_g_intbig_same, pg_finfosc, subarray, uniq]
+opt/csw/lib/postgresql/8.4/adminpack.so: [Pg_magic_func, _fini, _init, pg_file_rename,
+ pg_file_unlink, pg_file_write, pg_finfo_pg_file_rename, pg_finfo_pg_file_unlink,
+ pg_finfo_pg_file_write, pg_finfo_pg_logdir_ls, pg_logdir_ls]
+opt/csw/lib/postgresql/8.4/_int2.so: []
+ """
+
+ self.pkg_data_2["ldd_dash_r"] = yaml.safe_load(ldd_dash_r_yml)
+ self.pkg_data_2["defined_symbols"] = yaml.safe_load(defined_symbols_yml)
+ self.pkg_data_2["binaries"] = ["opt/csw/lib/postgresql/8.4/_int.so",
+ "opt/csw/lib/postgresql/8.4/_int2.so"]
+ errors = pc.CheckForMissingSymbols([self.pkg_data_2], False)
+ self.failUnless(errors)
+
+
+ def testArchitectureSanity(self):
+ self.pkg_data_2["pkginfo"] = {}
+ self.pkg_data_2["pkginfo"]["ARCH"] = "i386"
+ errors = pc.ArchitectureSanity(self.pkg_data_2, False)
+ self.failUnless(errors)
+
+
+if __name__ == '__main__':
+ unittest.main()
Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py 2010-02-28 16:35:23 UTC (rev 8891)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -10,114 +10,5 @@
BASE_DIR = os.path.dirname(__file__)
TESTDATA_DIR = os.path.join(BASE_DIR, "testdata")
-class PackageChecksUnitTest(unittest.TestCase):
-
- def setUp(self):
- self.pkg_data_1 = {
- "basic_stats": {
- "pkgname": "CSWfoo"
- }
- }
- self.pkg_data_2 = {
- 'basic_stats': {
- 'parsed_basename':
- {'revision_info': {'REV': '2010.02.15'},
- 'catalogname': 'python_tk',
- 'full_version_string': '2.6.4,REV=2010.02.15',
- 'version': '2.6.4',
- 'version_info': {
- 'minor version': '6',
- 'major version': '2',
- 'patchlevel': '4'}},
- 'pkgname': 'CSWpython-tk',
- 'stats_version': 1,
- 'pkg_basename': 'python_tk-2.6.4,REV=2010.02.15-SunOS5.8-sparc-CSW.pkg.gz',
- 'pkg_path': '/tmp/pkg_lL0HDH/python_tk-2.6.4,REV=2010.02.15-SunOS5.8-sparc-CSW.pkg.gz',
- 'catalogname': 'python_tk'}}
-
- def LoadData(self, name):
- file_name = os.path.join(TESTDATA_DIR, "%s.yml" % name)
- f = open(file_name, "rb")
- data = yaml.safe_load(f)
- f.close()
- return data
-
- def testCatalogName_1(self):
- self.pkg_data_1["basic_stats"]["catalogname"] = "Foo"
- errors = pc.CatalognameLowercase(self.pkg_data_1, False)
- self.failUnless(errors)
-
- def testCatalogName_2(self):
- self.pkg_data_1["basic_stats"]["catalogname"] = "foo"
- errors = pc.CatalognameLowercase(self.pkg_data_1, False)
- self.failIf(errors)
-
- def testCatalogNameSpecialCharacters(self):
- self.pkg_data_1["basic_stats"]["catalogname"] = "foo+abc&123"
- errors = pc.CatalognameLowercase(self.pkg_data_1, False)
- self.failUnless(errors)
-
- def testFileNameSanity(self):
- del(self.pkg_data_2["basic_stats"]["parsed_basename"]["revision_info"]["REV"])
- errors = pc.FileNameSanity(self.pkg_data_2, False)
- self.failUnless(errors)
-
- def testCheckArchitectureVsContents(self):
- self.pkg_data_2["pkgmap"] = self.LoadData("example-1-pkgmap")
- self.pkg_data_2["binaries"] = []
- self.pkg_data_2["pkginfo"] = self.LoadData("example-1-pkginfo")
- errors = pc.CheckArchitectureVsContents(self.pkg_data_2, False)
- self.failIf(errors)
-
- def testCheckForMissingSymbols(self):
- ldd_dash_r_yml = """opt/csw/lib/postgresql/8.4/_int.so:
-- {path: /usr/lib/libc.so.1, soname: libc.so.1, state: OK, symbol: null}
-- {path: /usr/lib/libdl.so.1, soname: libdl.so.1, state: OK, symbol: null}
-- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
- state: symbol-not-found, symbol: CurrentMemoryContext}
-- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
- state: symbol-not-found, symbol: MemoryContextAlloc}
-- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
- state: symbol-not-found, symbol: errstart}
-- {path: /tmp/pkg_W8UcnK/CSWlibpq-84/root/opt/csw/lib/postgresql/8.4/_int.so, soname: null,
- state: symbol-not-found, symbol: errcode}
-opt/csw/lib/postgresql/8.4/_int2.so:
-- {path: /usr/lib/libdl.so.1, soname: libdl.so.1, state: OK, symbol: null}"""
- defined_symbols_yml = """opt/csw/lib/postgresql/8.4/_int.so: [Pg_magic_func, _fini, _init, _int_contained,
- _int_contains, _int_different, _int_inter, _int_overlap, _int_same, _int_union,
- _int_unique, _intbig_in, _intbig_out, boolop, bqarr_in, bqarr_out, compASC, compDESC,
- copy_intArrayType, execconsistent, g_int_compress, g_int_consistent, g_int_decompress,
- g_int_penalty, g_int_picksplit, g_int_same, g_int_union, g_intbig_compress, g_intbig_consistent,
- g_intbig_decompress, g_intbig_penalty, g_intbig_picksplit, g_intbig_same, g_intbig_union,
- gensign, ginconsistent, ginint4_consistent, ginint4_queryextract, icount, idx, inner_int_contains,
- inner_int_inter, inner_int_overlap, inner_int_union, int_to_intset, intarray_add_elem,
- intarray_concat_arrays, intarray_del_elem, intarray_match_first, intarray_push_array,
- intarray_push_elem, internal_size, intset, intset_subtract, intset_union_elem, isort,
- new_intArrayType, pg_finfo__int_contained, pg_finfo__int_contains, pg_finfo__int_different,
- pg_finfo__int_inter, pg_finfo__int_overlap, pg_finfo__int_same, pg_finfo__int_union,
- pg_finfo__intbig_in, pg_finfo__intbig_out, pg_finfo_boolop, pg_finfo_bqarr_in, pg_finfo_bqarr_out,
- pg_finfo_g_int_compress, pg_finfo_g_int_consistent, pg_finfo_g_int_decompress, pg_finfo_g_int_penalty,
- pg_finfo_g_int_picksplit, pg_finfo_g_int_same, pg_finfo_g_int_union, pg_finfo_g_intbig_compress,
- pg_finfo_g_intbig_consistent, pg_finfo_g_intbig_decompress, pg_finfo_g_intbig_penalty,
- pg_finfo_g_intbig_picksplit, pg_finfo_g_intbig_same, pg_finfosc, subarray, uniq]
-opt/csw/lib/postgresql/8.4/adminpack.so: [Pg_magic_func, _fini, _init, pg_file_rename,
- pg_file_unlink, pg_file_write, pg_finfo_pg_file_rename, pg_finfo_pg_file_unlink,
- pg_finfo_pg_file_write, pg_finfo_pg_logdir_ls, pg_logdir_ls]"""
-
- self.pkg_data_2["ldd_dash_r"] = yaml.safe_load(ldd_dash_r_yml)
- self.pkg_data_2["defined_symbols"] = yaml.safe_load(defined_symbols_yml)
- self.pkg_data_2["binaries"] = ["opt/csw/lib/postgresql/8.4/_int.so",
- "opt/csw/lib/postgresql/8.4/_int2.so"]
- errors = pc.CheckForMissingSymbols([self.pkg_data_2], False)
- self.failUnless(errors)
-
-
- def testArchitectureSanity(self):
- self.pkg_data_2["pkginfo"] = {}
- self.pkg_data_2["pkginfo"]["ARCH"] = "i386"
- errors = pc.ArchitectureSanity(self.pkg_data_2, False)
- self.failUnless(errors)
-
-
-if __name__ == '__main__':
- unittest.main()
+class Foo(unittest.TestCase):
+ pass
Modified: csw/mgar/gar/v2/tests/run_tests.py
===================================================================
--- csw/mgar/gar/v2/tests/run_tests.py 2010-02-28 16:35:23 UTC (rev 8891)
+++ csw/mgar/gar/v2/tests/run_tests.py 2010-02-28 16:58:21 UTC (rev 8892)
@@ -10,11 +10,12 @@
# To add more test files, create <name>.py file and add a corresponding line
# here:
-from checkpkg_test import *
-from example_test import *
-from opencsw_test import *
-from overrides_test import *
-from package_checks_test import *
+from checkpkg_test import *
+from example_test import *
+from opencsw_test import *
+from overrides_test import *
+from package_checks_test import *
+from package_checks_old_test import *
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