1 |
Add emerge --autounmask-license and --autounmask-use options which are |
2 |
enabled by default, and disable package.keywords/mask changes by |
3 |
default. For backward compatibility, previous behavior of |
4 |
--autounmask=y and --autounmask=n is entirely preserved. Users can |
5 |
get the old behavior simply by adding --autounmask to the make.conf |
6 |
EMERGE_DEFAULT_OPTS variable. |
7 |
|
8 |
Bug: https://bugs.gentoo.org/658648 |
9 |
Signed-off-by: Zac Medico <zmedico@g.o> |
10 |
--- |
11 |
lib/_emerge/create_depgraph_params.py | 35 +++++++++++++++++++ |
12 |
lib/_emerge/depgraph.py | 16 +++++---- |
13 |
lib/_emerge/main.py | 10 ++++++ |
14 |
lib/portage/tests/resolver/test_autounmask.py | 35 ++++++++++++++++++- |
15 |
man/emerge.1 | 21 +++++++++-- |
16 |
5 files changed, 107 insertions(+), 10 deletions(-) |
17 |
|
18 |
diff --git a/lib/_emerge/create_depgraph_params.py b/lib/_emerge/create_depgraph_params.py |
19 |
index 08605baa1..7d8da9065 100644 |
20 |
--- a/lib/_emerge/create_depgraph_params.py |
21 |
+++ b/lib/_emerge/create_depgraph_params.py |
22 |
@@ -7,6 +7,11 @@ from portage.util import writemsg_level |
23 |
def create_depgraph_params(myopts, myaction): |
24 |
#configure emerge engine parameters |
25 |
# |
26 |
+ # autounmask: enable autounmask |
27 |
+ # autounmask_keep_keywords: prevent autounmask changes to package.accept_keywords |
28 |
+ # autounmask_keep_license: prevent autounmask changes to package.license |
29 |
+ # autounmask_keep_masks: prevent autounmask changes to package.mask |
30 |
+ # autounmask_keep_use: prevent autounmask changes to package.use |
31 |
# self: include _this_ package regardless of if it is merged. |
32 |
# selective: exclude the package if it is merged |
33 |
# recurse: go into the dependencies |
34 |
@@ -34,6 +39,36 @@ def create_depgraph_params(myopts, myaction): |
35 |
# binpkg_changed_deps: reject binary packages with outdated deps |
36 |
myparams = {"recurse" : True} |
37 |
|
38 |
+ autounmask_keep_keywords = myopts.get("--autounmask-keep-keywords") |
39 |
+ autounmask_keep_masks = myopts.get("--autounmask-keep-masks") |
40 |
+ |
41 |
+ autounmask = myopts.get("--autounmask") |
42 |
+ autounmask_license = myopts.get('--autounmask-license') |
43 |
+ autounmask_use = myopts.get('--autounmask-use') |
44 |
+ if autounmask == 'n': |
45 |
+ autounmask = False |
46 |
+ else: |
47 |
+ if autounmask is None: |
48 |
+ if autounmask_use in (None, 'y'): |
49 |
+ autounmask = True |
50 |
+ elif autounmask_license in (None, 'y'): |
51 |
+ autounmask = True |
52 |
+ |
53 |
+ # Do not enable package.accept_keywords or package.mask |
54 |
+ # changes by default. |
55 |
+ if autounmask_keep_keywords is None: |
56 |
+ autounmask_keep_keywords = True |
57 |
+ if autounmask_keep_masks is None: |
58 |
+ autounmask_keep_masks = True |
59 |
+ else: |
60 |
+ autounmask = True |
61 |
+ |
62 |
+ myparams['autounmask'] = autounmask |
63 |
+ myparams['autounmask_keep_use'] = True if autounmask_use == 'n' else False |
64 |
+ myparams['autounmask_keep_license'] = True if autounmask_license == 'n' else False |
65 |
+ myparams['autounmask_keep_keywords'] = False if autounmask_keep_keywords in (None, 'n') else True |
66 |
+ myparams['autounmask_keep_masks'] = False if autounmask_keep_masks in (None, 'n') else True |
67 |
+ |
68 |
bdeps = myopts.get("--with-bdeps") |
69 |
if bdeps is not None: |
70 |
myparams["bdeps"] = bdeps |
71 |
diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py |
72 |
index 51614fc14..3788cbe04 100644 |
73 |
--- a/lib/_emerge/depgraph.py |
74 |
+++ b/lib/_emerge/depgraph.py |
75 |
@@ -5907,15 +5907,19 @@ class depgraph(object): |
76 |
if self._dynamic_config._autounmask is not True: |
77 |
return |
78 |
|
79 |
- autounmask_keep_keywords = self._frozen_config.myopts.get("--autounmask-keep-keywords", "n") != "n" |
80 |
- autounmask_keep_masks = self._frozen_config.myopts.get("--autounmask-keep-masks", "n") != "n" |
81 |
+ autounmask_keep_keywords = self._dynamic_config.myparams['autounmask_keep_keywords'] |
82 |
+ autounmask_keep_license = self._dynamic_config.myparams['autounmask_keep_license'] |
83 |
+ autounmask_keep_masks = self._dynamic_config.myparams['autounmask_keep_masks'] |
84 |
+ autounmask_keep_use = self._dynamic_config.myparams['autounmask_keep_use'] |
85 |
autounmask_level = self._AutounmaskLevel() |
86 |
|
87 |
- autounmask_level.allow_use_changes = True |
88 |
- yield autounmask_level |
89 |
+ if not autounmask_keep_use: |
90 |
+ autounmask_level.allow_use_changes = True |
91 |
+ yield autounmask_level |
92 |
|
93 |
- autounmask_level.allow_license_changes = True |
94 |
- yield autounmask_level |
95 |
+ if not autounmask_keep_license: |
96 |
+ autounmask_level.allow_license_changes = True |
97 |
+ yield autounmask_level |
98 |
|
99 |
if not autounmask_keep_keywords: |
100 |
autounmask_level.allow_unstable_keywords = True |
101 |
diff --git a/lib/_emerge/main.py b/lib/_emerge/main.py |
102 |
index e8b2c2e13..486664c84 100644 |
103 |
--- a/lib/_emerge/main.py |
104 |
+++ b/lib/_emerge/main.py |
105 |
@@ -347,11 +347,21 @@ def parse_opts(tmpcmdline, silent=False): |
106 |
"choices" : true_y_or_n |
107 |
}, |
108 |
|
109 |
+ "--autounmask-license": { |
110 |
+ "help" : "allow autounmask to change package.license", |
111 |
+ "choices" : y_or_n |
112 |
+ }, |
113 |
+ |
114 |
"--autounmask-unrestricted-atoms": { |
115 |
"help" : "write autounmask changes with >= atoms if possible", |
116 |
"choices" : true_y_or_n |
117 |
}, |
118 |
|
119 |
+ "--autounmask-use": { |
120 |
+ "help" : "allow autounmask to change package.use", |
121 |
+ "choices" : y_or_n |
122 |
+ }, |
123 |
+ |
124 |
"--autounmask-keep-keywords": { |
125 |
"help" : "don't add package.accept_keywords entries", |
126 |
"choices" : true_y_or_n |
127 |
diff --git a/lib/portage/tests/resolver/test_autounmask.py b/lib/portage/tests/resolver/test_autounmask.py |
128 |
index 64718dbf9..a3bf0ff94 100644 |
129 |
--- a/lib/portage/tests/resolver/test_autounmask.py |
130 |
+++ b/lib/portage/tests/resolver/test_autounmask.py |
131 |
@@ -93,6 +93,26 @@ class AutounmaskTestCase(TestCase): |
132 |
mergelist=["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], |
133 |
use_changes={ "dev-libs/B-1": {"foo": True} }), |
134 |
|
135 |
+ ResolverPlaygroundTestCase( |
136 |
+ ["dev-libs/A:1"], |
137 |
+ options={"--autounmask-use": "y"}, |
138 |
+ success=False, |
139 |
+ mergelist=["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], |
140 |
+ use_changes={ "dev-libs/B-1": {"foo": True} }), |
141 |
+ |
142 |
+ # Test default --autounmask-use |
143 |
+ ResolverPlaygroundTestCase( |
144 |
+ ["dev-libs/A:1"], |
145 |
+ success=False, |
146 |
+ mergelist=["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], |
147 |
+ use_changes={ "dev-libs/B-1": {"foo": True} }), |
148 |
+ |
149 |
+ # Explicitly disable --autounmask-use |
150 |
+ ResolverPlaygroundTestCase( |
151 |
+ ["dev-libs/A:1"], |
152 |
+ success=False, |
153 |
+ options={"--autounmask-use": "n"}), |
154 |
+ |
155 |
#Make sure we restart if needed. |
156 |
ResolverPlaygroundTestCase( |
157 |
["dev-libs/A:1", "dev-libs/B"], |
158 |
@@ -408,17 +428,30 @@ class AutounmaskTestCase(TestCase): |
159 |
} |
160 |
|
161 |
test_cases = ( |
162 |
+ # --autounmask=n negates default --autounmask-license |
163 |
ResolverPlaygroundTestCase( |
164 |
["=dev-libs/A-1"], |
165 |
options={"--autounmask": 'n'}, |
166 |
success=False), |
167 |
ResolverPlaygroundTestCase( |
168 |
["=dev-libs/A-1"], |
169 |
- options={"--autounmask": True}, |
170 |
+ options={"--autounmask-license": "y"}, |
171 |
success=False, |
172 |
mergelist=["dev-libs/A-1"], |
173 |
license_changes={ "dev-libs/A-1": set(["TEST"]) }), |
174 |
|
175 |
+ # Test default --autounmask-license |
176 |
+ ResolverPlaygroundTestCase( |
177 |
+ ["=dev-libs/A-1"], |
178 |
+ success=False, |
179 |
+ mergelist=["dev-libs/A-1"], |
180 |
+ license_changes={ "dev-libs/A-1": set(["TEST"]) }), |
181 |
+ |
182 |
+ ResolverPlaygroundTestCase( |
183 |
+ ["=dev-libs/A-1"], |
184 |
+ options={"--autounmask-license": "n"}, |
185 |
+ success=False), |
186 |
+ |
187 |
#Test license+keyword+use change at once. |
188 |
ResolverPlaygroundTestCase( |
189 |
["=dev-libs/C-1"], |
190 |
diff --git a/man/emerge.1 b/man/emerge.1 |
191 |
index d61250ec6..c0edc325e 100644 |
192 |
--- a/man/emerge.1 |
193 |
+++ b/man/emerge.1 |
194 |
@@ -352,15 +352,18 @@ intended to be set in the \fBmake.conf\fR(5) |
195 |
.TP |
196 |
.BR "\-\-autounmask [ y | n ]" |
197 |
Automatically unmask packages and generate package.use |
198 |
-settings as necessary to satisfy dependencies. This |
199 |
-option is enabled by default. If any configuration |
200 |
+settings as necessary to satisfy dependencies. This option |
201 |
+is disabled by default, except for portions of behavior |
202 |
+which are controlled by the \fB\-\-autounmask\-use\fR and |
203 |
+\fB\-\-autounmask\-license\fR options (\fB\-\-autounmask=n\fR |
204 |
+disables autounmask behavior entirely). If any configuration |
205 |
changes are required, then they will be displayed |
206 |
after the merge list and emerge will immediately |
207 |
abort. If the displayed configuration changes are |
208 |
satisfactory, you should copy and paste them into |
209 |
the specified configuration file(s), or enable the |
210 |
\fB\-\-autounmask\-write\fR option. The |
211 |
-\fBEMERGE_DEFAULT_OPTS\fR variable may be used to |
212 |
+\fBEMERGE_DEFAULT_OPTS\fR variable may be used to entirely |
213 |
disable this option by default in \fBmake.conf\fR(5). |
214 |
.TP |
215 |
.BR "\-\-autounmask\-backtrack < y | n >" |
216 |
@@ -407,6 +410,18 @@ If \-\-autounmask is enabled, no package.unmask or ** keyword changes |
217 |
will be created. This leads to unsatisfied dependencies if |
218 |
no other solution exists. |
219 |
.TP |
220 |
+.BR "\-\-autounmask\-license < y | n >" |
221 |
+Allow autounmask package.license changes. This option is enabled by default |
222 |
+(either \fB\-\-autounmask=n\fR or \fB\-\-autounmask\-license=n\fR disables |
223 |
+it). The \fBEMERGE_DEFAULT_OPTS\fR variable may be used to |
224 |
+disable this option by default in \fBmake.conf\fR(5). |
225 |
+.TP |
226 |
+.BR "\-\-autounmask\-use < y | n >" |
227 |
+Allow autounmask package.use changes. This option is enabled by default |
228 |
+(either \fB\-\-autounmask=n\fR or \fB\-\-autounmask\-use=n\fR disables |
229 |
+it). The \fBEMERGE_DEFAULT_OPTS\fR variable may be used to |
230 |
+disable this option by default in \fBmake.conf\fR(5). |
231 |
+.TP |
232 |
.BR "\-\-autounmask\-write [ y | n ]" |
233 |
If \-\-autounmask is enabled, changes are written |
234 |
to config files, respecting \fBCONFIG_PROTECT\fR and \fB\-\-ask\fR. |
235 |
-- |
236 |
2.21.0 |