Add _get_feature_flags(eapi_attrs) function.
authorZac Medico <zmedico@gentoo.org>
Sun, 23 Sep 2012 23:22:35 +0000 (16:22 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 23 Sep 2012 23:22:35 +0000 (16:22 -0700)
This will be useful for adding flags that behave specially in
experimental EAPIs, such as the targetroot/sysroot flag which is
planned for EAPI 5-hdepend.

pym/_emerge/depgraph.py
pym/_emerge/resolver/output.py
pym/_emerge/resolver/output_helpers.py
pym/portage/eapi.py
pym/portage/package/ebuild/config.py

index ac70d4315ef6a98d449c606d6acd3d8af5830ee4..9da202c62f97e038758bed17b6330cf106478c43 100644 (file)
@@ -23,13 +23,14 @@ from portage.dep import Atom, best_match_to_list, extract_affecting_use, \
        check_required_use, human_readable_required_use, match_from_list, \
        _repo_separator
 from portage.dep._slot_operator import ignore_built_slot_operator_deps
-from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use
+from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use, \
+       _get_eapi_attrs
 from portage.exception import (InvalidAtom, InvalidDependString,
        PackageNotFound, PortageException)
 from portage.output import colorize, create_color_func, \
        darkgreen, green
 bad = create_color_func("BAD")
-from portage.package.ebuild.config import _feature_flags
+from portage.package.ebuild.config import _get_feature_flags
 from portage.package.ebuild.getmaskingstatus import \
        _getmaskingstatus, _MaskReason
 from portage._sets import SETPREFIX
@@ -1229,20 +1230,22 @@ class depgraph(object):
                        in ("y", "auto"))
                newuse = "--newuse" in self._frozen_config.myopts
                changed_use = "changed-use" == self._frozen_config.myopts.get("--reinstall")
+               feature_flags = _get_feature_flags(
+                       _get_eapi_attrs(pkg.metadata["EAPI"]))
 
                if newuse or (binpkg_respect_use and not changed_use):
                        flags = set(orig_iuse.symmetric_difference(
                                cur_iuse).difference(forced_flags))
                        flags.update(orig_iuse.intersection(orig_use).symmetric_difference(
                                cur_iuse.intersection(cur_use)))
-                       flags.difference_update(_feature_flags)
+                       flags.difference_update(feature_flags)
                        if flags:
                                return flags
 
                elif changed_use or binpkg_respect_use:
                        flags = set(orig_iuse.intersection(orig_use).symmetric_difference(
                                cur_iuse.intersection(cur_use)))
-                       flags.difference_update(_feature_flags)
+                       flags.difference_update(feature_flags)
                        if flags:
                                return flags
                return None
index 05a3e8278cef3cc2f24f2e44b819ab1bab373292..0f2111f6dec071d8574491f4c5bf10433e3fd8c7 100644 (file)
@@ -251,7 +251,7 @@ class Display(object):
                for key in use_expand:
                        if key in self.use_expand_hidden:
                                continue
-                       self.verboseadd += _create_use_string(self.conf, key.upper(),
+                       self.verboseadd += _create_use_string(pkg, self.conf, key.upper(),
                                cur_iuse_map[key], iuse_forced[key],
                                cur_use_map[key], old_iuse_map[key],
                                old_use_map[key], self.is_new,
index be4ea4acbdc1b438678ecf4169c2d48ae3352b76..23b056c3ee92e666365564dca482f05fc48b8261 100644 (file)
@@ -14,10 +14,11 @@ import sys
 from portage import os
 from portage import _encodings, _unicode_encode
 from portage._sets.base import InternalPackageSet
+from portage.eapi import _get_eapi_attrs
 from portage.output import (blue, bold, colorize, create_color_func,
        green, red, teal, turquoise, yellow)
 bad = create_color_func("BAD")
-from portage.package.ebuild.config import _feature_flags
+from portage.package.ebuild.config import _get_feature_flags
 from portage.util import shlex_split, writemsg
 from portage.util.SlotObject import SlotObject
 from portage.versions import catpkgsplit
@@ -247,7 +248,7 @@ def _format_size(mysize):
                mystr=mystr[:mycount]+","+mystr[mycount:]
        return mystr+" kB"
 
-def _create_use_string(conf, name, cur_iuse, iuse_forced, cur_use,
+def _create_use_string(pkg, conf, name, cur_iuse, iuse_forced, cur_use,
        old_iuse, old_use,
        is_new, reinst_flags):
 
@@ -267,6 +268,7 @@ def _create_use_string(conf, name, cur_iuse, iuse_forced, cur_use,
        any_iuse = cur_iuse.union(old_iuse)
        any_iuse = list(any_iuse)
        any_iuse.sort()
+       feature_flags = _get_feature_flags(_get_eapi_attrs(pkg.metadata["EAPI"]))
        for flag in any_iuse:
                flag_str = None
                isEnabled = False
@@ -300,7 +302,7 @@ def _create_use_string(conf, name, cur_iuse, iuse_forced, cur_use,
                        elif flag in old_use:
                                flag_str = green("-" + flag) + "*"
                if flag_str:
-                       if flag in _feature_flags:
+                       if flag in feature_flags:
                                flag_str = "{" + flag_str + "}"
                        elif flag in iuse_forced:
                                flag_str = "(" + flag_str + ")"
index e02e017eea64f1492600be5f163b8ad760cbbffd..b12d81de71b65535ce68da6ed4ab9f1e6b7a5ad7 100644 (file)
@@ -85,7 +85,7 @@ def eapi_allows_directories_on_profile_level_and_repository_level(eapi):
 
 _eapi_attrs = collections.namedtuple('_eapi_attrs',
        'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
-       'iuse_defaults iuse_effective '
+       'feature_flag_test iuse_defaults iuse_effective '
        'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps '
        'src_uri_arrows strong_blocks use_deps use_dep_defaults')
 
@@ -111,6 +111,7 @@ def _get_eapi_attrs(eapi):
                dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)),
                dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
                exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
+               feature_flag_test = True,
                iuse_defaults = (eapi is None or eapi_has_iuse_defaults(eapi)),
                iuse_effective = (eapi is not None and eapi_has_iuse_effective(eapi)),
                repo_deps = (eapi is None or eapi_has_repo_deps(eapi)),
index 684de16db063cbfa18fcadbc4ae4ed11c68c16de..894d14cd380907dda32971e76f849d514048e8e9 100644 (file)
@@ -60,7 +60,21 @@ from portage.package.ebuild._config.helper import ordered_by_atom_specificity, p
 if sys.hexversion >= 0x3000000:
        basestring = str
 
-_feature_flags = frozenset(["test"])
+_feature_flags_cache = {}
+
+def _get_feature_flags(eapi_attrs):
+       cache_key = (eapi_attrs.feature_flag_test,)
+       flags = _feature_flags_cache.get(cache_key)
+       if flags is not None:
+               return flags
+
+       flags = []
+       if eapi_attrs.feature_flag_test:
+               flags.append("test")
+
+       flags = frozenset(flags)
+       _feature_flags_cache[cache_key] = flags
+       return flags
 
 def autouse(myvartree, use_cache=1, mysettings=None):
        warnings.warn("portage.autouse() is deprecated",