1 |
From: Albert Safin <xzfcpw@×××××.com> |
2 |
|
3 |
Since commit b65e1fc5fe723bd07bf034f6e08878fa3eb033cb, USE_EXPAND |
4 |
prefixes affected subsequent lines of the same atom in package.use. |
5 |
|
6 |
Fixes: b65e1fc5fe72 ("Support USE_EXPAND prefixes in package.use and relevant files") |
7 |
X-Gentoo-Bug: 546512 |
8 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=546512 |
9 |
--- |
10 |
pym/portage/package/ebuild/_config/UseManager.py | 8 +++++++- |
11 |
pym/portage/util/__init__.py | 10 +++++++--- |
12 |
2 files changed, 14 insertions(+), 4 deletions(-) |
13 |
|
14 |
diff --git a/pym/portage/package/ebuild/_config/UseManager.py b/pym/portage/package/ebuild/_config/UseManager.py |
15 |
index a93ea5c..6041802 100644 |
16 |
--- a/pym/portage/package/ebuild/_config/UseManager.py |
17 |
+++ b/pym/portage/package/ebuild/_config/UseManager.py |
18 |
@@ -208,6 +208,9 @@ class UseManager(object): |
19 |
useflags = [] |
20 |
use_expand_prefix = '' |
21 |
for prefixed_useflag in v: |
22 |
+ if extended_syntax and prefixed_useflag == "\n": |
23 |
+ use_expand_prefix = "" |
24 |
+ continue |
25 |
if extended_syntax and prefixed_useflag[-1] == ":": |
26 |
use_expand_prefix = prefixed_useflag[:-1].lower() + "_" |
27 |
continue |
28 |
@@ -236,11 +239,14 @@ class UseManager(object): |
29 |
ret = ExtendedAtomDict(dict) |
30 |
if user_config: |
31 |
pusedict = grabdict_package( |
32 |
- os.path.join(location, file_name), recursive=1, allow_wildcard=True, allow_repo=True, verify_eapi=False) |
33 |
+ os.path.join(location, file_name), recursive=1, newlines=1, allow_wildcard=True, allow_repo=True, verify_eapi=False) |
34 |
for k, v in pusedict.items(): |
35 |
l = [] |
36 |
use_expand_prefix = '' |
37 |
for flag in v: |
38 |
+ if flag == "\n": |
39 |
+ use_expand_prefix = "" |
40 |
+ continue |
41 |
if flag[-1] == ":": |
42 |
use_expand_prefix = flag[:-1].lower() + "_" |
43 |
continue |
44 |
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py |
45 |
index 4b82e71..48cd1b7 100644 |
46 |
--- a/pym/portage/util/__init__.py |
47 |
+++ b/pym/portage/util/__init__.py |
48 |
@@ -340,7 +340,7 @@ def stack_lists(lists, incremental=1, remember_source_file=False, |
49 |
else: |
50 |
return list(new_list) |
51 |
|
52 |
-def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): |
53 |
+def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1, newlines=0): |
54 |
""" |
55 |
This function grabs the lines in a file, normalizes whitespace and returns lines in a dictionary |
56 |
|
57 |
@@ -354,6 +354,8 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): |
58 |
@type recursive: Boolean (integer) |
59 |
@param incremental: Append to the return list, don't overwrite |
60 |
@type incremental: Boolean (integer) |
61 |
+ @param newlines: Append newlines |
62 |
+ @type newlines: Boolean (integer) |
63 |
@rtype: Dictionary |
64 |
@return: |
65 |
1. Returns the lines in a file in a dictionary, for example: |
66 |
@@ -379,6 +381,8 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): |
67 |
continue |
68 |
if len(myline) < 1 and empty == 1: |
69 |
continue |
70 |
+ if newlines: |
71 |
+ myline.append("\n") |
72 |
if incremental: |
73 |
newdict.setdefault(myline[0], []).extend(myline[1:]) |
74 |
else: |
75 |
@@ -424,7 +428,7 @@ def read_corresponding_eapi_file(filename, default="0"): |
76 |
return default |
77 |
return eapi |
78 |
|
79 |
-def grabdict_package(myfilename, juststrings=0, recursive=0, |
80 |
+def grabdict_package(myfilename, juststrings=0, recursive=0, newlines=0, |
81 |
allow_wildcard=False, allow_repo=False, allow_build_id=False, |
82 |
verify_eapi=False, eapi=None, eapi_default="0"): |
83 |
""" Does the same thing as grabdict except it validates keys |
84 |
@@ -438,7 +442,7 @@ def grabdict_package(myfilename, juststrings=0, recursive=0, |
85 |
atoms = {} |
86 |
for filename in file_list: |
87 |
d = grabdict(filename, juststrings=False, |
88 |
- empty=True, recursive=False, incremental=True) |
89 |
+ empty=True, recursive=False, incremental=True, newlines=newlines) |
90 |
if not d: |
91 |
continue |
92 |
if verify_eapi and eapi is None: |
93 |
-- |
94 |
2.3.1 |