aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gentoo.org>2015-02-14 11:51:18 -0500
committerTim Harder <radhermit@gentoo.org>2015-02-14 18:40:49 -0500
commit86a3cee1b94795616a667d4da1d4ec76b778279c (patch)
treead79463261c224bb32cd655c7da5dae9a7e06ada
parentebuild: provide access to stripped iuse (diff)
downloadpkgcore-86a3cee1b94795616a667d4da1d4ec76b778279c.tar.gz
pkgcore-86a3cee1b94795616a667d4da1d4ec76b778279c.tar.bz2
pkgcore-86a3cee1b94795616a667d4da1d4ec76b778279c.zip
profiles: provide access to profile-related iuse_effective
The entire calculation is now performed at the profile level using the user profile's parent. This should be much more efficient than recalculating all the profile related values that don't change for every package when the iuse_effective attribute is wrapped onto them. All that must be done now at the pkg level is tacking on the current pkg's iuse values. This should help provide better access to the values from tools like pcheck that need access to iuse_effective in order to properly handle use flag queries related to implicitly enabled flags from profiles.
-rw-r--r--pkgcore/ebuild/profiles.py23
-rw-r--r--pkgcore/ebuild/repository.py21
2 files changed, 27 insertions, 17 deletions
diff --git a/pkgcore/ebuild/profiles.py b/pkgcore/ebuild/profiles.py
index 7ed335f7c..41cebfd1d 100644
--- a/pkgcore/ebuild/profiles.py
+++ b/pkgcore/ebuild/profiles.py
@@ -560,6 +560,29 @@ class ProfileStack(object):
return frozenset(self.default_env.get("USE_EXPAND_UNPREFIXED", "").split())
@klass.jit_attr
+ def iuse_effective(self):
+ # prefer main system profile and fallback on custom profile
+ for profile in reversed(self.stack):
+ if not isinstance(profile, UserProfileNode):
+ break
+
+ iuse_effective = []
+
+ # EAPI 5 and above allow profile defined IUSE injection (see PMS)
+ if profile.eapi_obj.options.profile_iuse_injection:
+ iuse_effective.extend(self.iuse_implicit)
+ for v in self.use_expand_implicit.intersection(self.use_expand_unprefixed):
+ iuse_effective.extend(self.default_env.get("USE_EXPAND_VALUES_" + v, "").split())
+ for v in self.use_expand.intersection(self.use_expand_implicit):
+ for x in self.default_env.get("USE_EXPAND_VALUES_" + v, "").split():
+ iuse_effective.append(v.lower() + "_" + x)
+ else:
+ iuse_effective.extend(profile.repoconfig.known_arches)
+ iuse_effective.extend(x.lower() + "_.*" for x in self.use_expand)
+
+ return frozenset(iuse_effective)
+
+ @klass.jit_attr
def virtuals(self):
d = {}
for profile in self.stack:
diff --git a/pkgcore/ebuild/repository.py b/pkgcore/ebuild/repository.py
index a8dab9716..d82b05d22 100644
--- a/pkgcore/ebuild/repository.py
+++ b/pkgcore/ebuild/repository.py
@@ -8,7 +8,7 @@ ebuild repository, specific to gentoo ebuild trees (whether cvs or rsync)
__all__ = ("tree", "slavedtree",)
from functools import partial
-from itertools import imap, ifilterfalse
+from itertools import chain, imap, ifilterfalse
import os
import stat
@@ -581,22 +581,9 @@ class _ConfiguredTree(configured.tree):
self._delayed_iuse = partial(
make_kls(InvertedContains), InvertedContains)
- def _generate_iuse_effective(self, profile, pkg, *args):
- iuse_effective = [x.lstrip('-+') for x in pkg.iuse]
-
- # EAPI 5 and above allow profile defined IUSE injection (see PMS)
- if pkg.eapi_obj.options.profile_iuse_injection:
- iuse_effective.extend(profile.iuse_implicit)
- for v in profile.use_expand_implicit.intersection(profile.use_expand_unprefixed):
- iuse_effective.extend(profile.default_env.get("USE_EXPAND_VALUES_" + v, "").split())
- for v in profile.use_expand.intersection(profile.use_expand_implicit):
- for x in profile.default_env.get("USE_EXPAND_VALUES_" + v, "").split():
- iuse_effective.append(v.lower() + "_" + x)
- else:
- iuse_effective.extend(pkg.repo.config.known_arches)
- iuse_effective.extend(x.lower() + "_.*" for x in profile.use_expand)
-
- return frozenset(iuse_effective)
+ @staticmethod
+ def _generate_iuse_effective(profile, pkg, *args):
+ return frozenset(chain.from_iterable((pkg.iuse_stripped, profile.iuse_effective)))
def _get_delayed_immutable(self, pkg, immutable):
return InvertedContains(pkg.iuse.difference(immutable))