diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org> | 2010-11-14 17:44:07 +0100 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-11-23 18:03:11 -0800 |
commit | c9da5a4e0b0a3e9c563a5576a5b7ea854480c846 (patch) | |
tree | 812875f9602dbab5c22317e45f02a9ac4c9cece6 /pym | |
parent | 62b079b158e8267e43b3cbfef8ad2365fbf8723c (diff) | |
download | portage-c9da5a4e0b0a3e9c563a5576a5b7ea854480c846.tar.gz portage-c9da5a4e0b0a3e9c563a5576a5b7ea854480c846.tar.bz2 portage-c9da5a4e0b0a3e9c563a5576a5b7ea854480c846.zip |
Validate syntax of USE flags in use.force, use.mask, use.unsatisfiable,
package.use.force, package.use.mask, package.use.unsatisfiable and
package.use files.
Diffstat (limited to 'pym')
-rw-r--r-- | pym/portage/package/ebuild/_config/UseManager.py | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py index 11e30291f..d9f6d991c 100644 --- a/pym/portage/package/ebuild/_config/UseManager.py +++ b/pym/portage/package/ebuild/_config/UseManager.py @@ -6,8 +6,9 @@ __all__ = ( ) from portage import os -from portage.dep import ExtendedAtomDict, remove_slot -from portage.util import grabfile, grabdict_package, stack_lists +from portage.dep import ExtendedAtomDict, remove_slot, _get_useflag_re +from portage.localization import _ +from portage.util import grabfile, grabdict_package, read_corresponding_eapi_file, stack_lists, writemsg from portage.versions import cpv_getkey from portage.package.ebuild._config.helper import ordered_by_atom_specificity @@ -63,17 +64,49 @@ class UseManager(object): return ret def _parse_profile_files_to_list(self, file_name, locations): - return tuple( - tuple(grabfile(os.path.join(x, file_name), recursive=1)) - for x in locations) + ret = [] + for profile in locations: + profile_lines = [] + path = os.path.join(profile, file_name) + lines = grabfile(path, recursive=1) + eapi = read_corresponding_eapi_file(path) + useflag_re = _get_useflag_re(eapi) + for prefixed_useflag in lines: + if prefixed_useflag[:1] == "-": + useflag = prefixed_useflag[1:] + else: + useflag = prefixed_useflag + if useflag_re.match(useflag) is None: + writemsg(_("--- Invalid USE flag in '%s': '%s'\n") % (path, prefixed_useflag)) + else: + profile_lines.append(prefixed_useflag) + ret.append(tuple(profile_lines)) + return tuple(ret) def _parse_profile_files_to_dict(self, file_name, locations, juststrings=False): ret = [] - raw = [grabdict_package(os.path.join(x, file_name), - juststrings=juststrings, recursive=1, verify_eapi=True) for x in locations] - for rawdict in raw: + for profile in locations: + profile_dict = {} cpdict = {} - for k, v in rawdict.items(): + path = os.path.join(profile, file_name) + file_dict = grabdict_package(path, recursive=1, verify_eapi=True) + eapi = read_corresponding_eapi_file(path) + useflag_re = _get_useflag_re(eapi) + for k, v in file_dict.items(): + useflags = [] + for prefixed_useflag in v: + if prefixed_useflag[:1] == "-": + useflag = prefixed_useflag[1:] + else: + useflag = prefixed_useflag + if useflag_re.match(useflag) is None: + writemsg(_("--- Invalid USE flag for '%s' in '%s': '%s'\n") % (k, path, prefixed_useflag)) + else: + useflags.append(prefixed_useflag) + profile_dict.setdefault(k, []).extend(useflags) + for k, v in profile_dict.items(): + if juststrings: + v = " ".join(v) cpdict.setdefault(k.cp, {})[k] = v ret.append(cpdict) return ret |