1 |
commit: 46fac6698e5c73fda964819b508f1fe9dd341393 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Aug 12 17:16:46 2017 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Aug 12 23:48:14 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=46fac669 |
7 |
|
8 |
emerge: add --autounmask-keep-keywords option (bug 622480) |
9 |
|
10 |
The option prevents --autounmask from making changes to |
11 |
package.accept_keywords. This option does not imply |
12 |
--autounmask-keep-masks, so --autounmask is still allowed |
13 |
to create package.unmask changes unless the |
14 |
--autounmask-keep-masks is also specified. |
15 |
|
16 |
X-Gentoo-bug: 622480 |
17 |
X-Gentoo-bug-url: https://bugs.gentoo.org/622480 |
18 |
Reviewed-by: Manuel RĂ¼ger <mrueg <AT> gentoo.org> |
19 |
|
20 |
man/emerge.1 | 7 +++ |
21 |
pym/_emerge/depgraph.py | 12 ++-- |
22 |
pym/_emerge/main.py | 9 +++ |
23 |
.../resolver/test_autounmask_keep_keywords.py | 72 ++++++++++++++++++++++ |
24 |
4 files changed, 96 insertions(+), 4 deletions(-) |
25 |
|
26 |
diff --git a/man/emerge.1 b/man/emerge.1 |
27 |
index ffb453efb..12a0db166 100644 |
28 |
--- a/man/emerge.1 |
29 |
+++ b/man/emerge.1 |
30 |
@@ -395,6 +395,13 @@ using the \'=\' operator will be written. With this |
31 |
option, \'>=\' operators will be used whenever possible. |
32 |
USE and license changes always use the latter behavior. |
33 |
.TP |
34 |
+.BR "\-\-autounmask\-keep\-keywords [ y | n ]" |
35 |
+If \-\-autounmask is enabled, no package.accept_keywords changes will |
36 |
+be created. This leads to unsatisfied dependencies if any keyword |
37 |
+changes are required. This option does not imply \-\-autounmask\-keep\-masks, |
38 |
+so \-\-autounmask is still allowed to create package.unmask changes unless |
39 |
+the \-\-autounmask\-keep\-masks is also specified. |
40 |
+.TP |
41 |
.BR "\-\-autounmask\-keep\-masks [ y | n ]" |
42 |
If \-\-autounmask is enabled, no package.unmask or ** keyword changes |
43 |
will be created. This leads to unsatisfied dependencies if |
44 |
|
45 |
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py |
46 |
index abe2cb1bd..b4fc5f297 100644 |
47 |
--- a/pym/_emerge/depgraph.py |
48 |
+++ b/pym/_emerge/depgraph.py |
49 |
@@ -5707,6 +5707,7 @@ class depgraph(object): |
50 |
if self._dynamic_config._autounmask is not True: |
51 |
return |
52 |
|
53 |
+ autounmask_keep_keywords = self._frozen_config.myopts.get("--autounmask-keep-keywords", "n") != "n" |
54 |
autounmask_keep_masks = self._frozen_config.myopts.get("--autounmask-keep-masks", "n") != "n" |
55 |
autounmask_level = self._AutounmaskLevel() |
56 |
|
57 |
@@ -5716,14 +5717,16 @@ class depgraph(object): |
58 |
autounmask_level.allow_license_changes = True |
59 |
yield autounmask_level |
60 |
|
61 |
- autounmask_level.allow_unstable_keywords = True |
62 |
- yield autounmask_level |
63 |
- |
64 |
- if not autounmask_keep_masks: |
65 |
+ if not autounmask_keep_keywords: |
66 |
+ autounmask_level.allow_unstable_keywords = True |
67 |
+ yield autounmask_level |
68 |
|
69 |
+ if not (autounmask_keep_keywords or autounmask_keep_masks): |
70 |
+ autounmask_level.allow_unstable_keywords = True |
71 |
autounmask_level.allow_missing_keywords = True |
72 |
yield autounmask_level |
73 |
|
74 |
+ if not autounmask_keep_masks: |
75 |
# 4. USE + license + masks |
76 |
# Try to respect keywords while discarding |
77 |
# package.mask (see bug #463394). |
78 |
@@ -5732,6 +5735,7 @@ class depgraph(object): |
79 |
autounmask_level.allow_unmasks = True |
80 |
yield autounmask_level |
81 |
|
82 |
+ if not (autounmask_keep_keywords or autounmask_keep_masks): |
83 |
autounmask_level.allow_unstable_keywords = True |
84 |
|
85 |
for missing_keyword, unmask in ((False, True), (True, True)): |
86 |
|
87 |
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py |
88 |
index 2132aa63c..d3a415b91 100644 |
89 |
--- a/pym/_emerge/main.py |
90 |
+++ b/pym/_emerge/main.py |
91 |
@@ -129,6 +129,7 @@ def insert_optional_args(args): |
92 |
'--autounmask' : y_or_n, |
93 |
'--autounmask-continue' : y_or_n, |
94 |
'--autounmask-only' : y_or_n, |
95 |
+ '--autounmask-keep-keywords' : y_or_n, |
96 |
'--autounmask-keep-masks': y_or_n, |
97 |
'--autounmask-unrestricted-atoms' : y_or_n, |
98 |
'--autounmask-write' : y_or_n, |
99 |
@@ -348,6 +349,11 @@ def parse_opts(tmpcmdline, silent=False): |
100 |
"choices" : true_y_or_n |
101 |
}, |
102 |
|
103 |
+ "--autounmask-keep-keywords": { |
104 |
+ "help" : "don't add package.accept_keywords entries", |
105 |
+ "choices" : true_y_or_n |
106 |
+ }, |
107 |
+ |
108 |
"--autounmask-keep-masks": { |
109 |
"help" : "don't add package.unmask entries", |
110 |
"choices" : true_y_or_n |
111 |
@@ -797,6 +803,9 @@ def parse_opts(tmpcmdline, silent=False): |
112 |
if myoptions.autounmask_unrestricted_atoms in true_y: |
113 |
myoptions.autounmask_unrestricted_atoms = True |
114 |
|
115 |
+ if myoptions.autounmask_keep_keywords in true_y: |
116 |
+ myoptions.autounmask_keep_keywords = True |
117 |
+ |
118 |
if myoptions.autounmask_keep_masks in true_y: |
119 |
myoptions.autounmask_keep_masks = True |
120 |
|
121 |
|
122 |
diff --git a/pym/portage/tests/resolver/test_autounmask_keep_keywords.py b/pym/portage/tests/resolver/test_autounmask_keep_keywords.py |
123 |
new file mode 100644 |
124 |
index 000000000..79a4837a5 |
125 |
--- /dev/null |
126 |
+++ b/pym/portage/tests/resolver/test_autounmask_keep_keywords.py |
127 |
@@ -0,0 +1,72 @@ |
128 |
+# Copyright 2017 Gentoo Foundation |
129 |
+# Distributed under the terms of the GNU General Public License v2 |
130 |
+ |
131 |
+from portage.tests import TestCase |
132 |
+from portage.tests.resolver.ResolverPlayground import ( |
133 |
+ ResolverPlayground, |
134 |
+ ResolverPlaygroundTestCase, |
135 |
+) |
136 |
+ |
137 |
+class AutounmaskKeepKeywordsTestCase(TestCase): |
138 |
+ |
139 |
+ def testAutounmaskKeepKeywordsTestCase(self): |
140 |
+ ebuilds = { |
141 |
+ 'app-misc/A-2': { |
142 |
+ 'EAPI': '6', |
143 |
+ 'RDEPEND': 'app-misc/B', |
144 |
+ }, |
145 |
+ 'app-misc/A-1': { |
146 |
+ 'EAPI': '6', |
147 |
+ 'RDEPEND': 'app-misc/C[foo]', |
148 |
+ }, |
149 |
+ 'app-misc/B-1': { |
150 |
+ 'EAPI': '6', |
151 |
+ 'KEYWORDS': '~x86', |
152 |
+ }, |
153 |
+ 'app-misc/C-1': { |
154 |
+ 'EAPI': '6', |
155 |
+ 'IUSE': 'foo', |
156 |
+ }, |
157 |
+ } |
158 |
+ installed = { |
159 |
+ } |
160 |
+ |
161 |
+ test_cases = ( |
162 |
+ ResolverPlaygroundTestCase( |
163 |
+ ['app-misc/A'], |
164 |
+ success = False, |
165 |
+ options = { |
166 |
+ '--autounmask-keep-keywords': 'n', |
167 |
+ }, |
168 |
+ mergelist = [ |
169 |
+ 'app-misc/B-1', |
170 |
+ 'app-misc/A-2', |
171 |
+ ], |
172 |
+ unstable_keywords={'app-misc/B-1'}, |
173 |
+ ), |
174 |
+ # --autounmask-keep-keywords prefers app-misc/A-1 because |
175 |
+ # it can be installed without accepting unstable |
176 |
+ # keywords |
177 |
+ ResolverPlaygroundTestCase( |
178 |
+ ['app-misc/A'], |
179 |
+ success = False, |
180 |
+ options = { |
181 |
+ '--autounmask-keep-keywords': 'y', |
182 |
+ }, |
183 |
+ mergelist = [ |
184 |
+ 'app-misc/C-1', |
185 |
+ 'app-misc/A-1', |
186 |
+ ], |
187 |
+ use_changes = {'app-misc/C-1': {'foo': True}}, |
188 |
+ ), |
189 |
+ ) |
190 |
+ |
191 |
+ playground = ResolverPlayground(ebuilds=ebuilds, debug=False) |
192 |
+ try: |
193 |
+ for test_case in test_cases: |
194 |
+ playground.run_TestCase(test_case) |
195 |
+ self.assertEqual(test_case.test_success, |
196 |
+ True, test_case.fail_msg) |
197 |
+ finally: |
198 |
+ playground.debug = False |
199 |
+ playground.cleanup() |