repoman: fix stable mask to use correct profile v2.2.0_alpha157
authorZac Medico <zmedico@gentoo.org>
Sun, 20 Jan 2013 02:33:10 +0000 (18:33 -0800)
committerZac Medico <zmedico@gentoo.org>
Sun, 20 Jan 2013 02:33:10 +0000 (18:33 -0800)
We can't rely on the internal config instance from the given package
instance, since it does not refer to the correct profile.

pym/portage/package/ebuild/_config/UseManager.py
pym/portage/package/ebuild/config.py
pym/portage/versions.py

index 85380d3afd8264810ae6da3016163cbe2d006058..743160c42ae5ae50f4e258877d6b5782df388fc1 100644 (file)
@@ -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 = []
 
index 4df3c96bbf12caeeff1d5c13b4cf395b095d7018..0ea0841b24c482a1f4db2f2a8e2ca4cf8a5dabc3 100644 (file)
@@ -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()
index 1dd2ff359b32e738e2f358e5380b7e047c2c54f4..46c53089bf571a153c13823632ba106d36202685 100644 (file)
@@ -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):