commit: 5c53c0831dc34b7c1edab2ab8726e54cb5957289
Author: Albert Safin <xzfcpw <AT> gmail <DOT> com>
AuthorDate: Tue Apr 14 20:28:55 2015 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Apr 22 00:00:05 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5c53c083
UseManager: handle newlines for USE_EXPAND prefixes (bug 546512)
Since commit b65e1fc5fe723bd07bf034f6e08878fa3eb033cb, USE_EXPAND
prefixes affected subsequent lines of the same atom in package.use.
Fixes: b65e1fc5fe72 ("Support USE_EXPAND prefixes in package.use and relevant
files")
X-Gentoo-Bug: 546512
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=546512
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
pym/portage/package/ebuild/_config/UseManager.py | 8 +++++++-
pym/portage/util/__init__.py | 10 +++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/pym/portage/package/ebuild/_config/UseManager.py
b/pym/portage/package/ebuild/_config/UseManager.py
index a93ea5c..6041802 100644
--- a/pym/portage/package/ebuild/_config/UseManager.py
+++ b/pym/portage/package/ebuild/_config/UseManager.py
@@ -208,6 +208,9 @@ class UseManager(object):
useflags = []
use_expand_prefix = ''
for prefixed_useflag in v:
+ if extended_syntax and prefixed_useflag == "\n":
+ use_expand_prefix = ""
+ continue
if extended_syntax and prefixed_useflag[-1] ==
":":
use_expand_prefix =
prefixed_useflag[:-1].lower() + "_"
continue
@@ -236,11 +239,14 @@ class UseManager(object):
ret = ExtendedAtomDict(dict)
if user_config:
pusedict = grabdict_package(
- os.path.join(location, file_name), recursive=1,
allow_wildcard=True, allow_repo=True, verify_eapi=False)
+ os.path.join(location, file_name), recursive=1,
newlines=1, allow_wildcard=True, allow_repo=True, verify_eapi=False)
for k, v in pusedict.items():
l = []
use_expand_prefix = ''
for flag in v:
+ if flag == "\n":
+ use_expand_prefix = ""
+ continue
if flag[-1] == ":":
use_expand_prefix =
flag[:-1].lower() + "_"
continue
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 4b82e71..48cd1b7 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -340,7 +340,7 @@ def stack_lists(lists, incremental=1,
remember_source_file=False,
else:
return list(new_list)
-def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
+def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1,
newlines=0):
"""
This function grabs the lines in a file, normalizes whitespace and
returns lines in a dictionary
@@ -354,6 +354,8 @@ def grabdict(myfilename, juststrings=0, empty=0,
recursive=0, incremental=1):
@type recursive: Boolean (integer)
@param incremental: Append to the return list, don't overwrite
@type incremental: Boolean (integer)
+ @param newlines: Append newlines
+ @type newlines: Boolean (integer)
@rtype: Dictionary
@return:
1. Returns the lines in a file in a dictionary, for example:
@@ -379,6 +381,8 @@ def grabdict(myfilename, juststrings=0, empty=0,
recursive=0, incremental=1):
continue
if len(myline) < 1 and empty == 1:
continue
+ if newlines:
+ myline.append("\n")
if incremental:
newdict.setdefault(myline[0], []).extend(myline[1:])
else:
@@ -424,7 +428,7 @@ def read_corresponding_eapi_file(filename, default="0"):
return default
return eapi
-def grabdict_package(myfilename, juststrings=0, recursive=0,
+def grabdict_package(myfilename, juststrings=0, recursive=0, newlines=0,
allow_wildcard=False, allow_repo=False, allow_build_id=False,
verify_eapi=False, eapi=None, eapi_default="0"):
""" Does the same thing as grabdict except it validates keys
@@ -438,7 +442,7 @@ def grabdict_package(myfilename, juststrings=0, recursive=0,
atoms = {}
for filename in file_list:
d = grabdict(filename, juststrings=False,
- empty=True, recursive=False, incremental=True)
+ empty=True, recursive=False, incremental=True,
newlines=newlines)
if not d:
continue
if verify_eapi and eapi is None: