aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-09-26 20:55:00 (GMT)
committerZac Medico <zmedico@gentoo.org>2012-09-26 20:55:38 (GMT)
commit7cf1e23b2debfa1a09c98d5cc6a795cc3e58ea95 (patch)
tree1ce9d090c0685b9f8620fd442aaa06c7d3a1420f
parentAdd eapi.sh with ___eapi_*() functions and use these functions in other files. (diff)
downloadportage-7cf1e23b2debfa1a09c98d5cc6a795cc3e58ea95.zip
portage-7cf1e23b2debfa1a09c98d5cc6a795cc3e58ea95.tar.gz
portage-7cf1e23b2debfa1a09c98d5cc6a795cc3e58ea95.tar.bz2
UseManager: /etc/portage/profile extended syntax
If /etc/portage/profile/eapi does not exist, then support extended atom syntax. This will fix bug #436330.
-rw-r--r--pym/portage/package/ebuild/_config/LocationsManager.py7
-rw-r--r--pym/portage/package/ebuild/_config/UseManager.py20
-rw-r--r--pym/portage/util/__init__.py16
3 files changed, 30 insertions, 13 deletions
diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py
index 0149ad8..c3099d7 100644
--- a/pym/portage/package/ebuild/_config/LocationsManager.py
+++ b/pym/portage/package/ebuild/_config/LocationsManager.py
@@ -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):
diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py
index bff2a71..cd67ced 100644
--- a/pym/portage/package/ebuild/_config/UseManager.py
+++ b/pym/portage/package/ebuild/_config/UseManager.py
@@ -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):
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index e84958a..c148a73 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -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,