From 94084ef96909a6f938daa2a90aedc1cc3fc8ce0b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 19 Jan 2013 18:33:10 -0800 Subject: [PATCH] repoman: fix stable mask to use correct profile We can't rely on the internal config instance from the given package instance, since it does not refer to the correct profile. --- .../package/ebuild/_config/UseManager.py | 36 +++++++++++++------ pym/portage/package/ebuild/config.py | 3 +- pym/portage/versions.py | 10 +++--- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py index 85380d3af..743160c42 100644 --- a/pym/portage/package/ebuild/_config/UseManager.py +++ b/pym/portage/package/ebuild/_config/UseManager.py @@ -18,7 +18,8 @@ from portage.package.ebuild._config.helper import ordered_by_atom_specificity class UseManager(object): - def __init__(self, repositories, profiles, abs_user_config, user_config=True): + def __init__(self, repositories, profiles, abs_user_config, is_stable, + user_config=True): # file variable #-------------------------------- # repositories @@ -61,6 +62,8 @@ class UseManager(object): #-------------------------------- # puse + self._user_config = user_config + self._is_stable = is_stable self._repo_usemask_dict = self._parse_repository_files_to_dict_of_tuples("use.mask", repositories) self._repo_usestablemask_dict = \ self._parse_repository_files_to_dict_of_tuples("use.stable.mask", @@ -269,6 +272,25 @@ class UseManager(object): ret[repo.name] = file_dict return ret + def _isStable(self, pkg): + if self._user_config: + try: + return pkg.stable + except AttributeError: + # KEYWORDS is unavailable (prior to "depend" phase) + return False + + try: + pkg._metadata + except AttributeError: + # KEYWORDS is unavailable (prior to "depend" phase) + return False + + # Since repoman uses different config instances for + # different profiles, we have to be careful to do the + # stable check against the correct profile here. + return self._is_stable(pkg) + def getUseMask(self, pkg=None): if pkg is None: return frozenset(stack_lists( @@ -282,11 +304,7 @@ class UseManager(object): pkg = _pkg_str(remove_slot(pkg), slot=slot, repo=repo) cp = pkg.cp - try: - stable = pkg.stable - except AttributeError: - # KEYWORDS is unavailable (prior to "depend" phase) - stable = False + stable = self._isStable(pkg) usemask = [] @@ -345,11 +363,7 @@ class UseManager(object): pkg = _pkg_str(remove_slot(pkg), slot=slot, repo=repo) cp = pkg.cp - try: - stable = pkg.stable - except AttributeError: - # KEYWORDS is unavailable (prior to "depend" phase) - stable = False + stable = self._isStable(pkg) useforce = [] diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index 4df3c96bb..0ea0841b2 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -644,7 +644,8 @@ class config(object): self._repo_make_defaults[repo.name] = d #Read all USE related files from profiles and optionally from user config. - self._use_manager = UseManager(self.repositories, profiles_complex, abs_user_config, user_config=local_config) + self._use_manager = UseManager(self.repositories, profiles_complex, + abs_user_config, self._isStable, user_config=local_config) #Initialize all USE related variables we track ourselves. self.usemask = self._use_manager.getUseMask() self.useforce = self._use_manager.getUseForce() diff --git a/pym/portage/versions.py b/pym/portage/versions.py index 1dd2ff359..46c53089b 100644 --- a/pym/portage/versions.py +++ b/pym/portage/versions.py @@ -408,11 +408,13 @@ class _pkg_str(_unicode): settings = self._settings except AttributeError: raise AttributeError('stable') + if not settings.local_config: + # Since repoman uses different config instances for + # different profiles, our local instance does not + # refer to the correct profile. + raise AssertionError('invalid context') stable = settings._isStable(self) - if settings.local_config: - # For repoman, don't cache this value, since - # it needs to be re-computed for each profile. - self.__dict__['_stable'] = stable + self.__dict__['_stable'] = stable return stable def pkgsplit(mypkg, silent=1, eapi=None): -- 2.26.2