UseManager: /etc/portage/profile extended syntax
authorZac Medico <zmedico@gentoo.org>
Wed, 26 Sep 2012 20:55:00 +0000 (13:55 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 26 Sep 2012 20:55:38 +0000 (13:55 -0700)
If /etc/portage/profile/eapi does not exist, then support extended atom
syntax. This will fix bug #436330.

pym/portage/package/ebuild/_config/LocationsManager.py
pym/portage/package/ebuild/_config/UseManager.py
pym/portage/util/__init__.py

index 0149ad8ec3a275afb92d375aea0ccce619820031..c3099d73fe725e5244a3df93b35326b50e350e2c 100644 (file)
@@ -28,7 +28,7 @@ _PORTAGE1_DIRECTORIES = frozenset([
        'use.mask', 'use.force'])
 
 _profile_node = collections.namedtuple('_profile_node',
-       'location portage1_directories')
+       'location portage1_directories user_config')
 
 _allow_parent_colon = frozenset(
        ["portage-2"])
@@ -112,7 +112,8 @@ class LocationsManager(object):
                        if os.path.exists(custom_prof):
                                self.user_profile_dir = custom_prof
                                self.profiles.append(custom_prof)
-                               self.profiles_complex.append(_profile_node(custom_prof, True))
+                               self.profiles_complex.append(
+                                       _profile_node(custom_prof, True, True))
                        del custom_prof
 
                self.profiles = tuple(self.profiles)
@@ -210,7 +211,7 @@ class LocationsManager(object):
 
                self.profiles.append(currentPath)
                self.profiles_complex.append(
-                       _profile_node(currentPath, allow_directories))
+                       _profile_node(currentPath, allow_directories, False))
 
        def _expand_parent_colon(self, parentsFile, parentPath,
                repo_loc, repositories):
index bff2a7105de76b47277671e4dce8225f6d2b2927..cd67ced93df36b27d835d3a1353a07b397731526 100644 (file)
@@ -121,12 +121,21 @@ class UseManager(object):
                                ret.append(prefixed_useflag)
                return tuple(ret)
 
-       def _parse_file_to_dict(self, file_name, juststrings=False, recursive=True, eapi_filter=None):
+       def _parse_file_to_dict(self, file_name, juststrings=False, recursive=True,
+               eapi_filter=None, user_config=False):
                ret = {}
                location_dict = {}
-               file_dict = grabdict_package(file_name, recursive=recursive, verify_eapi=True)
-               eapi = read_corresponding_eapi_file(file_name)
-               if eapi_filter is not None and not eapi_filter(eapi):
+               eapi = read_corresponding_eapi_file(file_name, default=None)
+               if eapi is None and not user_config:
+                       eapi = "0"
+               if eapi is None:
+                       ret = ExtendedAtomDict(dict)
+               else:
+                       ret = {}
+               file_dict = grabdict_package(file_name, recursive=recursive,
+                       allow_wildcard=(eapi is None), allow_repo=(eapi is None),
+                       verify_eapi=(eapi is not None))
+               if eapi is not None and eapi_filter is not None and not eapi_filter(eapi):
                        if file_dict:
                                writemsg(_("--- EAPI '%s' does not support '%s': '%s'\n") %
                                        (eapi, os.path.basename(file_name), file_name),
@@ -187,7 +196,8 @@ class UseManager(object):
                juststrings=False, eapi_filter=None):
                return tuple(self._parse_file_to_dict(
                        os.path.join(profile.location, file_name), juststrings,
-                       recursive=profile.portage1_directories, eapi_filter=eapi_filter)
+                       recursive=profile.portage1_directories, eapi_filter=eapi_filter,
+                       user_config=profile.user_config)
                        for profile in locations)
 
        def getUseMask(self, pkg=None):
index e84958aa5107107b57f1e58fd65ca8abe6cf9cbb..c148a739df99c0f189872cf18d623cb6cb931248 100644 (file)
@@ -381,17 +381,22 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
 
 _eapi_cache = {}
 
-def read_corresponding_eapi_file(filename):
+def read_corresponding_eapi_file(filename, default="0"):
        """
        Read the 'eapi' file from the directory 'filename' is in.
        Returns "0" if the file is not present or invalid.
        """
-       default = "0"
        eapi_file = os.path.join(os.path.dirname(filename), "eapi")
        try:
-               return _eapi_cache[eapi_file]
+               eapi = _eapi_cache[eapi_file]
        except KeyError:
                pass
+       else:
+               if eapi is None:
+                       return default
+               return eapi
+
+       eapi = None
        try:
                f = io.open(_unicode_encode(eapi_file,
                        encoding=_encodings['fs'], errors='strict'),
@@ -402,12 +407,13 @@ def read_corresponding_eapi_file(filename):
                else:
                        writemsg(_("--- Invalid 'eapi' file (doesn't contain exactly one line): %s\n") % (eapi_file),
                                noiselevel=-1)
-                       eapi = default
                f.close()
        except IOError:
-               eapi = default
+               pass
 
        _eapi_cache[eapi_file] = eapi
+       if eapi is None:
+               return default
        return eapi
 
 def grabdict_package(myfilename, juststrings=0, recursive=0, allow_wildcard=False, allow_repo=False,