diff options
Diffstat (limited to 'portage_with_autodep/pym/portage/dbapi/__init__.py')
-rw-r--r-- | portage_with_autodep/pym/portage/dbapi/__init__.py | 122 |
1 files changed, 66 insertions, 56 deletions
diff --git a/portage_with_autodep/pym/portage/dbapi/__init__.py b/portage_with_autodep/pym/portage/dbapi/__init__.py index e386faa..a1c5c56 100644 --- a/portage_with_autodep/pym/portage/dbapi/__init__.py +++ b/portage_with_autodep/pym/portage/dbapi/__init__.py @@ -1,4 +1,4 @@ -# Copyright 1998-2011 Gentoo Foundation +# Copyright 1998-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 __all__ = ["dbapi"] @@ -11,7 +11,7 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.dep:match_from_list', 'portage.output:colorize', 'portage.util:cmp_sort_key,writemsg', - 'portage.versions:catsplit,catpkgsplit,vercmp', + 'portage.versions:catsplit,catpkgsplit,vercmp,_pkg_str', ) from portage import os @@ -46,7 +46,12 @@ class dbapi(object): def cp_list(self, cp, use_cache=1): raise NotImplementedError(self) - def _cpv_sort_ascending(self, cpv_list): + @staticmethod + def _cmp_cpv(cpv1, cpv2): + return vercmp(cpv1.version, cpv2.version) + + @staticmethod + def _cpv_sort_ascending(cpv_list): """ Use this to sort self.cp_list() results in ascending order. It sorts in place and returns None. @@ -55,12 +60,7 @@ class dbapi(object): # If the cpv includes explicit -r0, it has to be preserved # for consistency in findname and aux_get calls, so use a # dict to map strings back to their original values. - ver_map = {} - for cpv in cpv_list: - ver_map[cpv] = '-'.join(catpkgsplit(cpv)[2:]) - def cmp_cpv(cpv1, cpv2): - return vercmp(ver_map[cpv1], ver_map[cpv2]) - cpv_list.sort(key=cmp_sort_key(cmp_cpv)) + cpv_list.sort(key=cmp_sort_key(dbapi._cmp_cpv)) def cpv_all(self): """Return all CPVs in the db @@ -155,64 +155,74 @@ class dbapi(object): 2) Check enabled/disabled flag states. """ - iuse_implicit_match = self.settings._iuse_implicit_match + aux_keys = ["IUSE", "SLOT", "USE", "repository"] for cpv in cpv_iter: try: - iuse, slot, use = self.aux_get(cpv, ["IUSE", "SLOT", "USE"], myrepo=atom.repo) + metadata = dict(zip(aux_keys, + self.aux_get(cpv, aux_keys, myrepo=atom.repo))) except KeyError: continue - iuse = frozenset(x.lstrip('+-') for x in iuse.split()) - missing_iuse = False - for x in atom.unevaluated_atom.use.required: - if x not in iuse and not iuse_implicit_match(x): - missing_iuse = True - break - if missing_iuse: + + if not self._match_use(atom, cpv, metadata): continue - if not atom.use: - pass - elif not self._use_mutable: - # Use IUSE to validate USE settings for built packages, - # in case the package manager that built this package - # failed to do that for some reason (or in case of - # data corruption). - use = frozenset(x for x in use.split() if x in iuse or \ - iuse_implicit_match(x)) - missing_enabled = atom.use.missing_enabled.difference(iuse) - missing_disabled = atom.use.missing_disabled.difference(iuse) - - if atom.use.enabled: - if atom.use.enabled.intersection(missing_disabled): - continue - need_enabled = atom.use.enabled.difference(use) + + yield cpv + + def _match_use(self, atom, cpv, metadata): + iuse_implicit_match = self.settings._iuse_implicit_match + iuse = frozenset(x.lstrip('+-') for x in metadata["IUSE"].split()) + + for x in atom.unevaluated_atom.use.required: + if x not in iuse and not iuse_implicit_match(x): + return False + + if atom.use is None: + pass + + elif not self._use_mutable: + # Use IUSE to validate USE settings for built packages, + # in case the package manager that built this package + # failed to do that for some reason (or in case of + # data corruption). + use = frozenset(x for x in metadata["USE"].split() + if x in iuse or iuse_implicit_match(x)) + missing_enabled = atom.use.missing_enabled.difference(iuse) + missing_disabled = atom.use.missing_disabled.difference(iuse) + + if atom.use.enabled: + if atom.use.enabled.intersection(missing_disabled): + return False + need_enabled = atom.use.enabled.difference(use) + if need_enabled: + need_enabled = need_enabled.difference(missing_enabled) if need_enabled: - need_enabled = need_enabled.difference(missing_enabled) - if need_enabled: - continue + return False - if atom.use.disabled: - if atom.use.disabled.intersection(missing_enabled): - continue - need_disabled = atom.use.disabled.intersection(use) + if atom.use.disabled: + if atom.use.disabled.intersection(missing_enabled): + return False + need_disabled = atom.use.disabled.intersection(use) + if need_disabled: + need_disabled = need_disabled.difference(missing_disabled) if need_disabled: - need_disabled = need_disabled.difference(missing_disabled) - if need_disabled: - continue - else: - # Check masked and forced flags for repoman. - mysettings = getattr(self, 'settings', None) - if mysettings is not None and not mysettings.local_config: + return False - pkg = "%s:%s" % (cpv, slot) - usemask = mysettings._getUseMask(pkg) - if usemask.intersection(atom.use.enabled): - continue + elif not self.settings.local_config: + # Check masked and forced flags for repoman. + if hasattr(cpv, 'slot'): + pkg = cpv + else: + pkg = _pkg_str(cpv, slot=metadata["SLOT"], + repo=metadata.get("repository")) + usemask = self.settings._getUseMask(pkg) + if usemask.intersection(atom.use.enabled): + return False - useforce = mysettings._getUseForce(pkg).difference(usemask) - if useforce.intersection(atom.use.disabled): - continue + useforce = self.settings._getUseForce(pkg).difference(usemask) + if useforce.intersection(atom.use.disabled): + return False - yield cpv + return True def invalidentry(self, mypath): if '/-MERGING-' in mypath: |