[csw-devel] SF.net SVN: gar:[20638] csw/mgar/gar/v2
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sun Apr 7 15:30:59 CEST 2013
Revision: 20638
http://gar.svn.sourceforge.net/gar/?rev=20638&view=rev
Author: wahwah
Date: 2013-04-07 13:30:56 +0000 (Sun, 07 Apr 2013)
Log Message:
-----------
checkpkg: Remove the checkpkg.py file
Modified Paths:
--------------
csw/mgar/gar/v2/bin/checkpkg_collect_stats_test.py
csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py
csw/mgar/gar/v2/lib/python/checkpkg_lib.py
csw/mgar/gar/v2/lib/python/checkpkg_lib_test.py
csw/mgar/gar/v2/lib/python/dependency_checks.py
csw/mgar/gar/v2/lib/python/package_checks.py
csw/mgar/gar/v2/lib/python/package_checks_test.py
Removed Paths:
-------------
csw/mgar/gar/v2/lib/python/checkpkg.py
csw/mgar/gar/v2/lib/python/checkpkg_test.py
Modified: csw/mgar/gar/v2/bin/checkpkg_collect_stats_test.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg_collect_stats_test.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/bin/checkpkg_collect_stats_test.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -11,7 +11,6 @@
path_list = [os.path.dirname(__file__),
"..", "lib", "python"]
sys.path.append(os.path.join(*path_list))
-import checkpkg
import opencsw
Modified: csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/bin/checkpkg_inspect_stats.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -16,7 +16,6 @@
path_list = [os.path.dirname(__file__),
"..", "lib", "python"]
sys.path.append(os.path.join(*path_list))
-import checkpkg
import opencsw
import configuration
@@ -35,7 +34,7 @@
logging.basicConfig(level=logging.INFO)
logging.debug("Collecting statistics about given package files.")
configuration.SetUpSqlobjectConnection()
- pkgstat_objs = checkpkg.GetPackageStatsByFilenamesOrMd5s(
+ pkgstat_objs = checkpkg_lib.GetPackageStatsByFilenamesOrMd5s(
args,
options.debug)
bar = progressbar.ProgressBar()
Deleted: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -1,96 +0,0 @@
-# $Id$
-#
-# This is the checkpkg library, common for all checkpkg tests written in
-# Python.
-
-import itertools
-import logging
-import optparse
-import os.path
-import re
-import pprint
-import progressbar
-import sqlobject
-import subprocess
-import database
-
-import inspective_package
-import models as m
-import common_constants
-import package_stats
-import struct_util
-
-
-DESCRIPTION_RE = r"^([\S]+) - (.*)$"
-
-INSTALL_CONTENTS_AVG_LINE_LENGTH = 102.09710677919261
-SYS_DEFAULT_RUNPATH = [
- "/usr/lib/$ISALIST",
- "/usr/lib",
- "/lib/$ISALIST",
- "/lib",
-]
-
-class Error(Exception):
- pass
-
-
-class ConfigurationError(Error):
- pass
-
-
-class PackageError(Error):
- pass
-
-
-class StdoutSyntaxError(Error):
- pass
-
-
-class SetupError(Error):
- pass
-
-
-class InternalDataError(Error):
- """Problem with internal checkpkg data structures."""
-
-
-def ExtractDescription(pkginfo):
- desc_re = re.compile(DESCRIPTION_RE)
- m = re.match(desc_re, pkginfo["NAME"])
- return m.group(2) if m else None
-
-
-def ExtractMaintainerName(pkginfo):
- maint_re = re.compile("^.*for CSW by (.*)$")
- m = re.match(maint_re, pkginfo["VENDOR"])
- return m.group(1) if m else None
-
-
-def ExtractBuildUsername(pkginfo):
- m = re.match(common_constants.PSTAMP_RE, pkginfo["PSTAMP"])
- return m.group("username") if m else None
-
-
-def GetPackageStatsByFilenamesOrMd5s(args, debug=False):
- filenames = []
- md5s = []
- for arg in args:
- if struct_util.IsMd5(arg):
- md5s.append(arg)
- else:
- filenames.append(arg)
- srv4_pkgs = [inspective_package.InspectiveCswSrv4File(x) for x in filenames]
- pkgstat_objs = []
- pbar = progressbar.ProgressBar()
- pbar.maxval = len(md5s) + len(srv4_pkgs)
- pbar.start()
- counter = itertools.count()
- for pkg in srv4_pkgs:
- pkgstat_objs.append(package_stats.PackageStats(pkg, debug=debug))
- pbar.update(counter.next())
- for md5 in md5s:
- pkgstat_objs.append(package_stats.PackageStats(None, md5sum=md5, debug=debug))
- pbar.update(counter.next())
- pbar.finish()
- return pkgstat_objs
Modified: csw/mgar/gar/v2/lib/python/checkpkg_lib.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_lib.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/lib/python/checkpkg_lib.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -29,18 +29,73 @@
import re
+DESCRIPTION_RE = r"^([\S]+) - (.*)$"
+
+INSTALL_CONTENTS_AVG_LINE_LENGTH = 102.09710677919261
+SYS_DEFAULT_RUNPATH = [
+ "/usr/lib/$ISALIST",
+ "/usr/lib",
+ "/lib/$ISALIST",
+ "/lib",
+]
+
class Error(Exception):
- pass
+ """Generic error."""
class CatalogDatabaseError(Error):
- pass
+ """Problem with the catalog database."""
class DataError(Error):
"""A problem with reading required data."""
+class ConfigurationError(Error):
+ """A problem with checkpkg configuration."""
+
+
+class PackageError(Error):
+ pass
+
+
+class StdoutSyntaxError(Error):
+ pass
+
+
+class SetupError(Error):
+ pass
+
+
+class InternalDataError(Error):
+ """Problem with internal checkpkg data structures."""
+
+
+def GetPackageStatsByFilenamesOrMd5s(args, debug=False):
+ filenames = []
+ md5s = []
+ for arg in args:
+ if struct_util.IsMd5(arg):
+ md5s.append(arg)
+ else:
+ filenames.append(arg)
+ srv4_pkgs = [inspective_package.InspectiveCswSrv4File(x) for x in filenames]
+ pkgstat_objs = []
+ pbar = progressbar.ProgressBar()
+ pbar.maxval = len(md5s) + len(srv4_pkgs)
+ pbar.start()
+ counter = itertools.count()
+ for pkg in srv4_pkgs:
+ pkgstat_objs.append(package_stats.PackageStats(pkg, debug=debug))
+ pbar.update(counter.next())
+ for md5 in md5s:
+ pkgstat_objs.append(package_stats.PackageStats(None, md5sum=md5, debug=debug))
+ pbar.update(counter.next())
+ pbar.finish()
+ return pkgstat_objs
+
+
+
REPORT_TMPL = u"""#if $missing_deps or $surplus_deps or $orphan_sonames
Dependency issues of $pkgname:
#end if
@@ -112,6 +167,23 @@
"""
+def ExtractDescription(pkginfo):
+ desc_re = re.compile(DESCRIPTION_RE)
+ m = re.match(desc_re, pkginfo["NAME"])
+ return m.group(2) if m else None
+
+
+def ExtractMaintainerName(pkginfo):
+ maint_re = re.compile("^.*for CSW by (.*)$")
+ m = re.match(maint_re, pkginfo["VENDOR"])
+ return m.group(1) if m else None
+
+
+def ExtractBuildUsername(pkginfo):
+ m = re.match(common_constants.PSTAMP_RE, pkginfo["PSTAMP"])
+ return m.group("username") if m else None
+
+
class SqlobjectHelperMixin(object):
def __init__(self):
Modified: csw/mgar/gar/v2/lib/python/checkpkg_lib_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_lib_test.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/lib/python/checkpkg_lib_test.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -7,6 +7,7 @@
import unittest
import checkpkg_lib
+import common_constants
import copy
import cPickle
import database
@@ -16,6 +17,8 @@
import package_stats
import package_stats
import pprint
+import re
+import sqlite3
import sqlobject
import tag
import test_base
@@ -479,5 +482,93 @@
self.assertEqual("Because.", needed_file.reason)
+class ExtractorsUnitTest(unittest.TestCase):
+
+ def testExtractDescriptionFromGoodData(self):
+ data = {"NAME": "nspr_devel - Netscape Portable Runtime header files"}
+ result = "Netscape Portable Runtime header files"
+ self.assertEqual(result, checkpkg_lib.ExtractDescription(data))
+
+ def testExtractDescriptionWithBadCatalogname(self):
+ data = {"NAME": "foo-bar - Bad catalogname shouldn't break this function"}
+ result = "Bad catalogname shouldn't break this function"
+ self.assertEqual(result, checkpkg_lib.ExtractDescription(data))
+
+ def testExtractMaintainerName(self):
+ data = {"VENDOR": "https://ftp.mozilla.org/pub/mozilla.org/"
+ "nspr/releases/v4.8/src/ packaged for CSW by "
+ "Maciej Blizinski"}
+ result = "Maciej Blizinski"
+ self.assertEqual(result, checkpkg_lib.ExtractMaintainerName(data))
+
+ def testPstampRegex(self):
+ pstamp = "hson at solaris9s-csw-20100313144445"
+ expected = {
+ 'username': 'hson',
+ 'timestamp': '20100313144445',
+ 'hostname': 'solaris9s-csw'
+ }
+ self.assertEqual(expected, re.match(common_constants.PSTAMP_RE, pstamp).groupdict())
+
+
+class SliceListUnitTest(unittest.TestCase):
+
+ def testOne(self):
+ l = [1, 2, 3, 4, 5]
+ s = 1
+ expected = [[1], [2], [3], [4], [5]]
+ self.assertTrue(expected, checkpkg_lib.SliceList(l, s))
+
+ def testTwo(self):
+ l = [1, 2, 3, 4, 5]
+ s = 2
+ expected = [[1, 2], [3, 4], [5]]
+ self.assertTrue(expected, checkpkg_lib.SliceList(l, s))
+
+
+class SqliteUnitTest(unittest.TestCase):
+
+ """Makes sure that we can lose state between tests."""
+
+ def setUp(self):
+ self.conn = sqlite3.connect(":memory:")
+ self.c = self.conn.cursor()
+
+ def tearDown(self):
+ self.conn = None
+
+ def testCannotCreateTwoTables(self):
+ self.c.execute("CREATE TABLE foo (INT bar);")
+ self.assertRaises(
+ sqlite3.OperationalError,
+ self.c.execute, "CREATE TABLE foo (INT bar);")
+
+ def testOne(self):
+ self.c.execute("CREATE TABLE foo (INT bar);")
+
+ def testTwo(self):
+ self.c.execute("CREATE TABLE foo (INT bar);")
+
+class SqlobjectUnitTest(test_base.SqlObjectTestMixin, unittest.TestCase):
+
+ "Makes sure that we can lose state between methods."
+
+ class TestModel(sqlobject.SQLObject):
+ name = sqlobject.UnicodeCol(length=255, unique=True, notNone=True)
+
+ # This does not work. Why?
+ # def testCannotCreateTwoTables(self):
+ # self.TestModel.createTable()
+ # self.assertRaises(
+ # sqlite3.OperationalError,
+ # self.TestModel.createTable)
+
+ def testOne(self):
+ self.TestModel.createTable()
+
+ def testTwo(self):
+ self.TestModel.createTable()
+
+
if __name__ == '__main__':
unittest.main()
Deleted: csw/mgar/gar/v2/lib/python/checkpkg_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_test.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/lib/python/checkpkg_test.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -1,127 +0,0 @@
-#!/usr/bin/env python2.6
-# $Id$
-
-import copy
-import re
-import unittest
-import mox
-import difflib
-import checkpkg
-import checkpkg_lib
-import database
-import models as m
-import tag
-import package_stats
-import sqlite3
-import sqlobject
-import test_base
-import common_constants
-
-from testdata.tree_stats import pkgstats as tree_stats
-from testdata.neon_stats import pkgstats as neon_stats
-
-"""A set of unit tests for the library checking code.
-
-A bunch of lines to test in the interactive Python shell.
-
-import sys
-sys.path.append("lib/python")
-import checkpkg
-
-sqlite3 ~/.checkpkg/var-sadm-install-contents-cache-build8x
-SELECT * FROM systempkgmap WHERE basename = 'libncursesw.so.5';
-"""
-
-class ExtractorsUnitTest(unittest.TestCase):
-
- def testExtractDescriptionFromGoodData(self):
- data = {"NAME": "nspr_devel - Netscape Portable Runtime header files"}
- result = "Netscape Portable Runtime header files"
- self.assertEqual(result, checkpkg.ExtractDescription(data))
-
- def testExtractDescriptionWithBadCatalogname(self):
- data = {"NAME": "foo-bar - Bad catalogname shouldn't break this function"}
- result = "Bad catalogname shouldn't break this function"
- self.assertEqual(result, checkpkg.ExtractDescription(data))
-
- def testExtractMaintainerName(self):
- data = {"VENDOR": "https://ftp.mozilla.org/pub/mozilla.org/"
- "nspr/releases/v4.8/src/ packaged for CSW by "
- "Maciej Blizinski"}
- result = "Maciej Blizinski"
- self.assertEqual(result, checkpkg.ExtractMaintainerName(data))
-
- def testPstampRegex(self):
- pstamp = "hson at solaris9s-csw-20100313144445"
- expected = {
- 'username': 'hson',
- 'timestamp': '20100313144445',
- 'hostname': 'solaris9s-csw'
- }
- self.assertEqual(expected, re.match(common_constants.PSTAMP_RE, pstamp).groupdict())
-
-
-class SliceListUnitTest(unittest.TestCase):
-
- def testOne(self):
- l = [1, 2, 3, 4, 5]
- s = 1
- expected = [[1], [2], [3], [4], [5]]
- self.assertTrue(expected, checkpkg_lib.SliceList(l, s))
-
- def testTwo(self):
- l = [1, 2, 3, 4, 5]
- s = 2
- expected = [[1, 2], [3, 4], [5]]
- self.assertTrue(expected, checkpkg_lib.SliceList(l, s))
-
-
-class SqliteUnitTest(unittest.TestCase):
-
- "Makes sure that we can lose state between tests."
-
- def setUp(self):
- self.conn = sqlite3.connect(":memory:")
- self.c = self.conn.cursor()
-
- def tearDown(self):
- self.conn = None
-
- def testCannotCreateTwoTables(self):
- self.c.execute("CREATE TABLE foo (INT bar);")
- self.assertRaises(
- sqlite3.OperationalError,
- self.c.execute, "CREATE TABLE foo (INT bar);")
-
- def testOne(self):
- self.c.execute("CREATE TABLE foo (INT bar);")
-
- def testTwo(self):
- self.c.execute("CREATE TABLE foo (INT bar);")
-
-
-class SqlobjectUnitTest(test_base.SqlObjectTestMixin, unittest.TestCase):
-
- "Makes sure that we can lose state between methods."
-
- class TestModel(sqlobject.SQLObject):
- name = sqlobject.UnicodeCol(length=255, unique=True, notNone=True)
-
- # This does not work. Why?
- # def testCannotCreateTwoTables(self):
- # self.TestModel.createTable()
- # self.assertRaises(
- # sqlite3.OperationalError,
- # self.TestModel.createTable)
-
- def testOne(self):
- self.TestModel.createTable()
-
- def testTwo(self):
- self.TestModel.createTable()
-
-
-if __name__ == '__main__':
- # import logging
- # logging.basicConfig(level=logging.DEBUG)
- unittest.main()
Modified: csw/mgar/gar/v2/lib/python/dependency_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/dependency_checks.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/lib/python/dependency_checks.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -1,6 +1,6 @@
# $Id$
-import checkpkg
+import checkpkg_lib
import os.path
import re
import ldd_emul
@@ -79,7 +79,7 @@
path_list = path_and_pkg_by_basename[soname].keys()
runpath_tuple = (
tuple(binary_info["runpath"])
- + tuple(checkpkg.SYS_DEFAULT_RUNPATH))
+ + tuple(checkpkg_lib.SYS_DEFAULT_RUNPATH))
runpath_history = []
first_lib = None
already_resolved_paths = set()
Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -20,6 +20,7 @@
import operator
import os
import checkpkg
+import checkpkg_lib
import opencsw
import pprint
import textwrap
@@ -275,7 +276,7 @@
def CheckDescription(pkg_data, error_mgr, logger, messenger):
pkginfo = pkg_data["pkginfo"]
- desc = checkpkg.ExtractDescription(pkginfo)
+ desc = checkpkg_lib.ExtractDescription(pkginfo)
if not desc:
error_mgr.ReportError("pkginfo-description-missing")
else:
@@ -603,7 +604,7 @@
if not "VERSION" in pkginfo or not pkginfo["VERSION"]:
error_mgr.ReportError("pkginfo-version-field-missing")
# maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
- maintname = checkpkg.ExtractMaintainerName(pkginfo)
+ maintname = checkpkg_lib.ExtractMaintainerName(pkginfo)
if not maintname:
error_mgr.ReportError("pkginfo-maintainer-name-not-set")
# email
@@ -689,7 +690,7 @@
def CheckBuildingUser(pkg_data, error_mgr, logger, messenger):
pkgname = pkg_data["basic_stats"]["pkgname"]
- username = checkpkg.ExtractBuildUsername(pkg_data["pkginfo"])
+ username = checkpkg_lib.ExtractBuildUsername(pkg_data["pkginfo"])
for entry in pkg_data["pkgmap"]:
if entry["user"] and entry["user"] == username:
error_mgr.ReportError("file-owned-by-building-user"
@@ -814,44 +815,6 @@
"%s %s" % (bad, binary_info["path"]))
-def DisabledCheckForMissingSymbols(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 DisabledCheckForMissingSymbolsDumb(pkg_data, error_mgr, logger, messenger):
"""Analyzes missing symbols reported by ldd -r.
@@ -973,7 +936,7 @@
# only available from the file name.
os_release = pkg_data["basic_stats"]["parsed_basename"]["osrel"]
if os_release not in machine_data["allowed"]:
- raise checkpkg.InternalDataError(
+ raise checkpkg_lib.InternalDataError(
"%s not found in machine_data" % os_release)
allowed_paths = set(machine_data["allowed"][os_release])
disallowed_paths = set(machine_data["disallowed"])
Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py 2013-04-07 10:28:13 UTC (rev 20637)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py 2013-04-07 13:30:56 UTC (rev 20638)
@@ -6,7 +6,6 @@
import datetime
import unittest
import package_checks as pc
-import checkpkg
import checkpkg_lib
import os.path
import mox
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