Make repoman pass Package instances into run_checks(), so that the checks
authorZac Medico <zmedico@gentoo.org>
Sun, 8 Jun 2008 02:19:46 +0000 (02:19 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 8 Jun 2008 02:19:46 +0000 (02:19 -0000)
can use the Package.mtime and inherited attributes.

svn path=/main/trunk/; revision=10600

bin/repoman
pym/_emerge/__init__.py
pym/repoman/checks.py

index b9710be0fadd16c0779e79bd2bfd63c0f145a5f9..9727d5a5429cc117377f07889bb237cce4c538b1 100755 (executable)
@@ -56,6 +56,9 @@ except ImportError:
        from repoman.checks import run_checks
        from repoman import utilities
 
+from _emerge import Package, RootConfig
+from portage.sets import load_default_config
+
 import portage.checksum
 import portage.const
 import portage.dep
@@ -350,7 +353,9 @@ qawarnings=[
 ]
 
 missingvars=["KEYWORDS","LICENSE","DESCRIPTION","HOMEPAGE","SLOT"]
-allvars=portage.auxdbkeys
+allvars = set(portage.auxdbkeys)
+allvars.update(Package.metadata_keys)
+allvars = sorted(allvars)
 commitmessage=None
 for x in missingvars:
        x += ".missing"
@@ -512,6 +517,8 @@ trees = portage.create_trees()
 trees["/"]["porttree"].settings = repoman_settings
 portdb = trees["/"]["porttree"].dbapi
 portdb.mysettings = repoman_settings
+setconfig = load_default_config(repoman_settings, trees["/"])
+root_config = RootConfig(repoman_settings, trees, setconfig)
 # We really only need to cache the metadata that's necessary for visibility
 # filtering. Anything else can be discarded to reduce memory consumption.
 for k in ("DEPEND", "LICENCE", "PDEPEND",
@@ -780,7 +787,7 @@ for x in scanlist:
 
        checkdirlist=os.listdir(checkdir)
        ebuildlist=[]
-       ebuild_metadata = {}
+       pkgs = {}
        for y in checkdirlist:
                if y in no_exec and \
                        stat.S_IMODE(os.stat(os.path.join(checkdir, y)).st_mode) & 0111:
@@ -804,7 +811,8 @@ for x in scanlist:
                                stats["EAPI.unsupported"] += 1
                                fails["EAPI.unsupported"].append(os.path.join(x, y))
                                continue
-                       ebuild_metadata[pf] = myaux
+                       pkgs[pf] = Package(cpv=cpv, metadata=myaux,
+                               root_config=root_config)
 
        # Sort ebuilds in ascending order for the KEYWORDS.dropped check.
        pkgsplits = {}
@@ -819,7 +827,7 @@ for x in scanlist:
 
        slot_keywords = {}
 
-       if len(ebuild_metadata) != len(ebuildlist):
+       if len(pkgs) != len(ebuildlist):
                # If we can't access all the metadata then it's totally unsafe to
                # commit since there's no way to generate a correct Manifest.
                # Do not try to do any more QA checks on this package since missing
@@ -1075,9 +1083,10 @@ for x in scanlist:
                        fails["ebuild.namenomatch"].append(x+"/"+y+".ebuild")
                        continue
 
-               myaux = ebuild_metadata[y]
+               pkg = pkgs[y]
+               myaux = pkg.metadata
                eapi = myaux["EAPI"]
-               inherited = frozenset(myaux["INHERITED"].split())
+               inherited = pkg.inherited
 
                # Test for negative logic and bad words in the RESTRICT var.
                #for x in myaux[allvars.index("RESTRICT")].split():
@@ -1385,8 +1394,7 @@ for x in scanlist:
                full_path = os.path.join(repodir, relative_path)
                f = open(full_path, 'rb')
                try:
-                       for check_name, e in run_checks(f, os.stat(full_path).st_mtime,
-                               inherited=inherited):
+                       for check_name, e in run_checks(f, pkg):
                                stats[check_name] += 1
                                fails[check_name].append(relative_path + ': %s' % e)
                finally:
index 65de5aeea84de6d2145dbe5ccb57126cf5aec116..520a8610421f567c4d32f93e280bb6e843f31ec6 100644 (file)
@@ -1274,7 +1274,8 @@ class Package(Task):
        __slots__ = ("built", "cpv", "depth",
                "installed", "metadata", "onlydeps", "operation",
                "root_config", "type_name",
-               "category", "counter", "cp", "cpv_split", "iuse", "mtime",
+               "category", "counter", "cp", "cpv_split",
+               "inherited", "iuse", "mtime",
                "pf", "pv_split", "root", "slot", "slot_atom", "use")
 
        metadata_keys = [
@@ -1337,7 +1338,7 @@ class Package(Task):
                Detect metadata updates and synchronize Package attributes.
                """
                _wrapped_keys = frozenset(
-                       ["COUNTER", "IUSE", "SLOT", "USE", "_mtime_"])
+                       ["COUNTER", "INHERITED", "IUSE", "SLOT", "USE", "_mtime_"])
 
                def __init__(self, pkg, metadata):
                        dict.__init__(self)
@@ -1355,6 +1356,11 @@ class Package(Task):
                        if k in self._wrapped_keys:
                                getattr(self, "_set_" + k.lower())(k, v)
 
+               def _set_inherited(self, k, v):
+                       if isinstance(v, basestring):
+                               v = frozenset(v.split())
+                       self._pkg.inherited = v
+
                def _set_iuse(self, k, v):
                        self._pkg.iuse = self._pkg._iuse(
                                v.split(), self._pkg.root_config.iuse_implicit)
index 7bc9d990b4cedc7a580e4e5d0b7a300d64792a22..3c202cad8649f620212c7babe46af6fccce89151 100644 (file)
@@ -221,11 +221,11 @@ _iuse_def_re = re.compile(r'^IUSE=.*')
 _comment_re = re.compile(r'(^|\s*)#')
 _autotools_func_re = re.compile(r'(^|\s)(eautomake|eautoconf|eautoreconf)(\s|$)')
 
-def run_checks(contents, st_mtime, inherited=None):
+def run_checks(contents, pkg):
        checks = list(_constant_checks)
-       checks.append(EbuildHeader(st_mtime))
+       checks.append(EbuildHeader(pkg.mtime))
        iuse_def = None
-       inherit_autotools = inherited and "autotools" in inherited
+       inherit_autotools = "autotools" in pkg.inherited
        autotools_func_call = None
        for num, line in enumerate(contents):
                comment = _comment_re.match(line)