[csw-devel] SF.net SVN: gar:[9347] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Wed Mar 24 10:17:49 CET 2010
Revision: 9347
http://gar.svn.sourceforge.net/gar/?rev=9347&view=rev
Author: wahwah
Date: 2010-03-24 09:17:49 +0000 (Wed, 24 Mar 2010)
Log Message:
-----------
mGAR v2: checkpkg, commondirs check integrated with GAR.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/checkpkg.py
csw/mgar/gar/v2/lib/python/dependency_checks.py
csw/mgar/gar/v2/lib/python/package_checks.py
Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py 2010-03-24 03:12:46 UTC (rev 9346)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py 2010-03-24 09:17:49 UTC (rev 9347)
@@ -697,6 +697,7 @@
if not self.system_pkgmap:
self.system_pkgmap = SystemPkgmap()
self.messages = []
+ self.common_paths = {}
def GetPkgmapLineByBasename(self, basename):
"""Proxies calls to self.system_pkgmap."""
@@ -713,7 +714,18 @@
def Message(self, msg):
sef.messages.append(msg)
+ def GetCommonPaths(self, arch):
+ """Returns a list of paths for architecture, from gar/etc/commondirs*."""
+ file_name = os.path.join(
+ os.path.dirname(__file__), "..", "..", "etc", "commondirs-%s" % arch)
+ logging.debug("opening %s", file_name)
+ f = open(file_name, "r")
+ lines = f.read().splitlines()
+ f.close()
+ return lines
+
+
class IndividualCheckInterface(CheckInterfaceBase):
"""To be passed to the checking functions.
Modified: csw/mgar/gar/v2/lib/python/dependency_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/dependency_checks.py 2010-03-24 03:12:46 UTC (rev 9346)
+++ csw/mgar/gar/v2/lib/python/dependency_checks.py 2010-03-24 09:17:49 UTC (rev 9347)
@@ -5,7 +5,7 @@
def Libraries(pkg_data, error_mgr, logger, path_and_pkg_by_soname):
pkgname = pkg_data["basic_stats"]["pkgname"]
- logger.info("Package %s", pkgname)
+ logger.debug("Package %s", pkgname)
orphan_sonames = []
required_deps = []
isalist = pkg_data["isalist"]
Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py 2010-03-24 03:12:46 UTC (rev 9346)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2010-03-24 09:17:49 UTC (rev 9347)
@@ -11,6 +11,7 @@
# logger.debug("Checking something.")
# error_mgr.ReportError("something-is-wrong")
+import copy
import re
import os
import checkpkg
@@ -21,13 +22,14 @@
from Cheetah import Template
PATHS_ALLOWED_ONLY_IN = {
- "CSWcommon": ["/opt",
- "/opt/csw/man",
- "/opt/csw/doc",
- "/opt/csw/info",
- "/opt/csw/share/locale/locale.alias"],
- "CSWiconv": ["/opt/csw/lib/charset.alias"],
- "CSWtexinfp": ["/opt/csw/share/info/dir"],
+ # Leading slash must be removed.
+ "CSWcommon": ["opt",
+ "opt/csw/man",
+ "opt/csw/doc",
+ "opt/csw/info",
+ "opt/csw/share/locale/locale.alias"],
+ "CSWiconv": ["opt/csw/lib/charset.alias"],
+ "CSWtexinfp": ["opt/csw/share/info/dir"],
}
MAX_DESCRIPTION_LENGTH = 100
LICENSE_TMPL = "/opt/csw/share/doc/%s/license"
@@ -46,9 +48,6 @@
MAX_PKGNAME_LENGTH = 20
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", )
-}
DO_NOT_LINK_AGAINST_THESE_SONAMES = set(["libX11.so.4"])
DISCOURAGED_FILE_PATTERNS = (r"\.py[co]$",)
BAD_RPATH_LIST = [
@@ -465,23 +464,33 @@
"%s, %s" % (entry["path"], entry["user"]))
-def CheckPkgmapPaths(pkg_data, error_mgr, logger):
- pkgname = pkg_data["basic_stats"]["pkgname"]
- pkg_paths = set([x["path"] for x in pkg_data["pkgmap"]])
- for allowed_pkgname in ONLY_ALLOWED_IN_PKG:
- for disallowed_path in ONLY_ALLOWED_IN_PKG[allowed_pkgname]:
- if disallowed_path in pkg_paths and pkgname != allowed_pkgname:
- error_mgr.ReportError("disallowed-path", disallowed_path)
-
-
def CheckDisallowedPaths(pkg_data, error_mgr, logger):
- """This seems to be a duplicate of CheckPkgmapPaths."""
- for pkgname in PATHS_ALLOWED_ONLY_IN:
+ """Checks for disallowed paths, such as common paths."""
+ arch = pkg_data["pkginfo"]["ARCH"]
+ # Common paths read from the file are absolute, e.g. /opt/csw/lib
+ # while paths in pkginfo are relative, e.g. opt/csw/lib.
+ common_paths = []
+ for common_path in error_mgr.GetCommonPaths(arch):
+ if common_path.startswith("/"):
+ common_path = common_path[1:]
+ common_paths.append(common_path)
+ paths_only_allowed_in = copy.copy(PATHS_ALLOWED_ONLY_IN)
+ paths_only_allowed_in["CSWcommon"] += common_paths
+ paths_in_pkg = set()
+ for entry in pkg_data["pkgmap"]:
+ entry_path = entry["path"]
+ if not entry_path:
+ continue
+ if entry_path.startswith("/"):
+ entry_path = entry_path[1:]
+ paths_in_pkg.add(entry_path)
+ for pkgname in paths_only_allowed_in:
if pkgname != pkg_data["basic_stats"]["pkgname"]:
- for entry in pkg_data["pkgmap"]:
- for forbidden_path in PATHS_ALLOWED_ONLY_IN[pkgname]:
- if entry["path"] == forbidden_path:
- error_mgr.ReportError("disallowed-path", entry["path"])
+ disallowed_paths = set(paths_only_allowed_in[pkgname])
+ intersection = disallowed_paths.intersection(paths_in_pkg)
+ logger.debug("Bad paths found: %s", intersection)
+ for bad_path in intersection:
+ error_mgr.ReportError("disallowed-path", bad_path)
def CheckLinkingAgainstSunX11(pkg_data, error_mgr, logger):
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