--- /dev/null
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+__all__ = (
+ 'features_set',
+)
+
+from portage.dep import best_match_to_list
+
+class features_set(object):
+ """
+ Provides relevant set operations needed for access and modification of
+ config.features. The FEATURES variable is automatically synchronized
+ upon modification.
+
+ Modifications result in a permanent override that will cause the change
+ to propagate to the incremental stacking mechanism in config.regenerate().
+ This eliminates the need to call config.backup_changes() when FEATURES
+ is modified, since any overrides are guaranteed to persist despite calls
+ to config.reset().
+ """
+
+ def __init__(self, settings):
+ self._settings = settings
+ self._features = set()
+
+ def __contains__(self, k):
+ return k in self._features
+
+ def __iter__(self):
+ return iter(self._features)
+
+ def _sync_env_var(self):
+ self._settings['FEATURES'] = ' '.join(sorted(self._features))
+
+ def add(self, k):
+ self._settings.modifying()
+ self._settings._features_overrides.append(k)
+ if k not in self._features:
+ self._features.add(k)
+ self._sync_env_var()
+
+ def update(self, values):
+ self._settings.modifying()
+ values = list(values)
+ self._settings._features_overrides.extend(values)
+ need_sync = False
+ for k in values:
+ if k in self._features:
+ continue
+ self._features.add(k)
+ need_sync = True
+ if need_sync:
+ self._sync_env_var()
+
+ def remove(self, k):
+ """
+ This never raises KeyError, since it records a permanent override
+ that will prevent the given flag from ever being added again by
+ incremental stacking in config.regenerate().
+ """
+ self.discard(k)
+
+ def discard(self, k):
+ self._settings.modifying()
+ self._settings._features_overrides.append('-' + k)
+ if k in self._features:
+ self._features.remove(k)
+ self._sync_env_var()
writemsg, writemsg_level
from portage.versions import catpkgsplit, catsplit, cpv_getkey
+from portage.package.ebuild._config.features_set import features_set
from portage.package.ebuild._config.LicenseManager import LicenseManager
from portage.package.ebuild._config.helper import ordered_by_atom_specificity
else:
raise KeyError("Key not found in list; '%s'" % key)
-class _features_set(object):
- """
- Provides relevant set operations needed for access and modification of
- config.features. The FEATURES variable is automatically synchronized
- upon modification.
-
- Modifications result in a permanent override that will cause the change
- to propagate to the incremental stacking mechanism in config.regenerate().
- This eliminates the need to call config.backup_changes() when FEATURES
- is modified, since any overrides are guaranteed to persist despite calls
- to config.reset().
- """
-
- def __init__(self, settings):
- self._settings = settings
- self._features = set()
-
- def __contains__(self, k):
- return k in self._features
-
- def __iter__(self):
- return iter(self._features)
-
- def _sync_env_var(self):
- self._settings['FEATURES'] = ' '.join(sorted(self._features))
-
- def add(self, k):
- self._settings.modifying()
- self._settings._features_overrides.append(k)
- if k not in self._features:
- self._features.add(k)
- self._sync_env_var()
-
- def update(self, values):
- self._settings.modifying()
- values = list(values)
- self._settings._features_overrides.extend(values)
- need_sync = False
- for k in values:
- if k in self._features:
- continue
- self._features.add(k)
- need_sync = True
- if need_sync:
- self._sync_env_var()
-
- def remove(self, k):
- """
- This never raises KeyError, since it records a permanent override
- that will prevent the given flag from ever being added again by
- incremental stacking in config.regenerate().
- """
- self.discard(k)
-
- def discard(self, k):
- self._settings.modifying()
- self._settings._features_overrides.append('-' + k)
- if k in self._features:
- self._features.remove(k)
- self._sync_env_var()
-
def _lazy_iuse_regex(iuse_implicit):
"""
The PORTAGE_IUSE value is lazily evaluated since re.escape() is slow
self.punmaskdict = copy.deepcopy(clone.punmaskdict)
self.prevmaskdict = copy.deepcopy(clone.prevmaskdict)
self.pprovideddict = copy.deepcopy(clone.pprovideddict)
- self.features = _features_set(self)
+ self.features = features_set(self)
self.features._features = copy.deepcopy(clone.features._features)
self._features_overrides = copy.deepcopy(clone._features_overrides)
if hasattr(self, "features"):
self.features._features.clear()
else:
- self.features = _features_set(self)
+ self.features = features_set(self)
self.features._features.update(self.get('FEATURES', '').split())
self.features._sync_env_var()