config: unset LINGUAS if appropriate, bug #459350
authorZac Medico <zmedico@gentoo.org>
Wed, 27 Feb 2013 00:27:40 +0000 (16:27 -0800)
committerZac Medico <zmedico@gentoo.org>
Wed, 27 Feb 2013 00:27:40 +0000 (16:27 -0800)
pym/portage/package/ebuild/config.py

index fb7b741d2407da203a78e208f9e6087ecabb2241..2ac59f090e9d43a7e72df26e73e79f11be94e37f 100644 (file)
@@ -1183,8 +1183,11 @@ class config(object):
                the previously calculated USE settings.
                """
 
-               def __init__(self, use, usemask, iuse_implicit,
+               def __init__(self, settings, unfiltered_use,
+                       use, usemask, iuse_implicit,
                        use_expand_split, use_expand_dict):
+                       self._settings = settings
+                       self._unfiltered_use = unfiltered_use
                        self._use = use
                        self._usemask = usemask
                        self._iuse_implicit = iuse_implicit
@@ -1239,13 +1242,32 @@ class config(object):
                                # Don't export empty USE_EXPAND vars unless the user config
                                # exports them as empty.  This is required for vars such as
                                # LINGUAS, where unset and empty have different meanings.
+                               # The special '*' token is understood by ebuild.sh, which
+                               # will unset the variable so that things like LINGUAS work
+                               # properly (see bug #459350).
                                if has_wildcard:
-                                       # ebuild.sh will see this and unset the variable so
-                                       # that things like LINGUAS work properly
                                        value = '*'
                                else:
                                        if has_iuse:
-                                               value = ''
+                                               already_set = False
+                                               # Skip the first 'env' configdict, in order to
+                                               # avoid infinite recursion here, since that dict's
+                                               # __getitem__ calls the current __getitem__.
+                                               for d in self._settings.lookuplist[1:]:
+                                                       if key in d:
+                                                               already_set = True
+                                                               break
+
+                                               if not already_set:
+                                                       for x in self._unfiltered_use:
+                                                               if x[:prefix_len] == prefix:
+                                                                       already_set = True
+                                                                       break
+
+                                               if already_set:
+                                                       value = ''
+                                               else:
+                                                       value = '*'
                                        else:
                                                # It's not in IUSE, so just allow the variable content
                                                # to pass through if it is defined somewhere.  This
@@ -1501,6 +1523,7 @@ class config(object):
                # be done for every setcpv() call since practically every
                # package has different IUSE.
                use = set(self["USE"].split())
+               unfiltered_use = frozenset(use)
                if explicit_iuse is None:
                        explicit_iuse = frozenset(x.lstrip("+-") for x in iuse.split())
 
@@ -1585,7 +1608,8 @@ class config(object):
                # comparison instead of startswith().
                use_expand_split = set(x.lower() for \
                        x in self.get('USE_EXPAND', '').split())
-               lazy_use_expand = self._lazy_use_expand(use, self.usemask,
+               lazy_use_expand = self._lazy_use_expand(
+                       self, unfiltered_use, use, self.usemask,
                        portage_iuse, use_expand_split, self._use_expand_dict)
 
                use_expand_iuses = {}