1 |
commit: c9a0df701f983b41fd0f1aac7bb4536f771846cb |
2 |
Author: Sebastian Luther <SebastianLuther <AT> gmx <DOT> de> |
3 |
AuthorDate: Sun Feb 26 08:49:13 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Feb 26 09:44:16 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c9a0df70 |
7 |
|
8 |
Reorganize how autounmask allows changes to be made |
9 |
|
10 |
This patch does not change emerge's behaviour. |
11 |
|
12 |
--- |
13 |
pym/_emerge/depgraph.py | 109 ++++++++++++++++++++++++---------------------- |
14 |
1 files changed, 57 insertions(+), 52 deletions(-) |
15 |
|
16 |
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py |
17 |
index bb3bf4a..a05c17e 100644 |
18 |
--- a/pym/_emerge/depgraph.py |
19 |
+++ b/pym/_emerge/depgraph.py |
20 |
@@ -3504,42 +3504,63 @@ class depgraph(object): |
21 |
return False |
22 |
return True |
23 |
|
24 |
+ class _AutounmaskLevel(object): |
25 |
+ __slots__ = ("allow_use_changes", "allow_unstable_keywords", "allow_license_changes", "allow_unmasks") |
26 |
+ |
27 |
+ def __init__(self): |
28 |
+ self.allow_use_changes = False |
29 |
+ self.allow_unstable_keywords = False |
30 |
+ self.allow_license_changes = False |
31 |
+ self.allow_unmasks = False |
32 |
+ |
33 |
+ def _autounmask_levels(self): |
34 |
+ |
35 |
+ if self._dynamic_config._autounmask is not True: |
36 |
+ return |
37 |
+ |
38 |
+ autounmask_keep_masks = self._frozen_config.myopts.get("--autounmask-keep-masks", "n") != "n" |
39 |
+ autounmask_level = self._AutounmaskLevel() |
40 |
+ |
41 |
+ autounmask_level.allow_use_changes = True |
42 |
+ |
43 |
+ for only_use_changes in (True, False): |
44 |
+ |
45 |
+ autounmask_level.allow_unstable_keywords = (not only_use_changes) |
46 |
+ autounmask_level.allow_license_changes = (not only_use_changes) |
47 |
+ |
48 |
+ for allow_unmasks in (False, True): |
49 |
+ if allow_unmasks and (only_use_changes or autounmask_keep_masks): |
50 |
+ continue |
51 |
+ |
52 |
+ autounmask_level.allow_unmasks = allow_unmasks |
53 |
+ |
54 |
+ yield autounmask_level |
55 |
+ |
56 |
+ |
57 |
def _select_pkg_highest_available_imp(self, root, atom, onlydeps=False): |
58 |
pkg, existing = self._wrapped_select_pkg_highest_available_imp(root, atom, onlydeps=onlydeps) |
59 |
|
60 |
default_selection = (pkg, existing) |
61 |
|
62 |
- autounmask_keep_masks = self._frozen_config.myopts.get("--autounmask-keep-masks", "n") != "n" |
63 |
- |
64 |
- if self._dynamic_config._autounmask is True: |
65 |
+ def reset_pkg(pkg): |
66 |
if pkg is not None and \ |
67 |
pkg.installed and \ |
68 |
not self._want_installed_pkg(pkg): |
69 |
pkg = None |
70 |
|
71 |
- for only_use_changes in True, False: |
72 |
+ if self._dynamic_config._autounmask is True: |
73 |
+ reset_pkg(pkg) |
74 |
+ |
75 |
+ for autounmask_level in self._autounmask_levels(): |
76 |
if pkg is not None: |
77 |
break |
78 |
|
79 |
- for allow_unmasks in (False, True): |
80 |
- if allow_unmasks and (only_use_changes or autounmask_keep_masks): |
81 |
- continue |
82 |
- |
83 |
- if pkg is not None: |
84 |
- break |
85 |
+ pkg, existing = \ |
86 |
+ self._wrapped_select_pkg_highest_available_imp( |
87 |
+ root, atom, onlydeps=onlydeps, |
88 |
+ autounmask_level=autounmask_level) |
89 |
|
90 |
- pkg, existing = \ |
91 |
- self._wrapped_select_pkg_highest_available_imp( |
92 |
- root, atom, onlydeps=onlydeps, |
93 |
- allow_use_changes=True, |
94 |
- allow_unstable_keywords=(not only_use_changes), |
95 |
- allow_license_changes=(not only_use_changes), |
96 |
- allow_unmasks=allow_unmasks) |
97 |
- |
98 |
- if pkg is not None and \ |
99 |
- pkg.installed and \ |
100 |
- not self._want_installed_pkg(pkg): |
101 |
- pkg = None |
102 |
+ reset_pkg(pkg) |
103 |
|
104 |
if self._dynamic_config._need_restart: |
105 |
return None, None |
106 |
@@ -3551,8 +3572,7 @@ class depgraph(object): |
107 |
|
108 |
return pkg, existing |
109 |
|
110 |
- def _pkg_visibility_check(self, pkg, allow_unstable_keywords=False, |
111 |
- allow_license_changes=False, allow_unmasks=False, trust_graph=True): |
112 |
+ def _pkg_visibility_check(self, pkg, autounmask_level=None, trust_graph=True): |
113 |
|
114 |
if pkg.visible: |
115 |
return True |
116 |
@@ -3565,7 +3585,7 @@ class depgraph(object): |
117 |
# as though they are visible. |
118 |
return True |
119 |
|
120 |
- if not self._dynamic_config._autounmask: |
121 |
+ if not self._dynamic_config._autounmask or autounmask_level is None: |
122 |
return False |
123 |
|
124 |
pkgsettings = self._frozen_config.pkgsettings[pkg.root] |
125 |
@@ -3615,10 +3635,10 @@ class depgraph(object): |
126 |
return True |
127 |
|
128 |
#We treat missing keywords in the same way as masks. |
129 |
- if (masked_by_unstable_keywords and not allow_unstable_keywords) or \ |
130 |
- (masked_by_missing_keywords and not allow_unmasks) or \ |
131 |
- (masked_by_p_mask and not allow_unmasks) or \ |
132 |
- (missing_licenses and not allow_license_changes): |
133 |
+ if (masked_by_unstable_keywords and not autounmask_level.allow_unstable_keywords) or \ |
134 |
+ (masked_by_missing_keywords and not autounmask_level.allow_unmasks) or \ |
135 |
+ (masked_by_p_mask and not autounmask_level.allow_unmasks) or \ |
136 |
+ (missing_licenses and not autounmask_level.allow_license_changes): |
137 |
#We are not allowed to do the needed changes. |
138 |
return False |
139 |
|
140 |
@@ -3733,8 +3753,7 @@ class depgraph(object): |
141 |
self._dynamic_config._need_restart = True |
142 |
return new_use |
143 |
|
144 |
- def _wrapped_select_pkg_highest_available_imp(self, root, atom, onlydeps=False, \ |
145 |
- allow_use_changes=False, allow_unstable_keywords=False, allow_license_changes=False, allow_unmasks=False): |
146 |
+ def _wrapped_select_pkg_highest_available_imp(self, root, atom, onlydeps=False, autounmask_level=None): |
147 |
root_config = self._frozen_config.roots[root] |
148 |
pkgsettings = self._frozen_config.pkgsettings[root] |
149 |
dbs = self._dynamic_config._filtered_trees[root]["dbs"] |
150 |
@@ -3861,10 +3880,7 @@ class depgraph(object): |
151 |
# _dep_check_composite_db, in order to prevent |
152 |
# incorrect choices in || deps like bug #351828. |
153 |
|
154 |
- if not self._pkg_visibility_check(pkg, \ |
155 |
- allow_unstable_keywords=allow_unstable_keywords, |
156 |
- allow_license_changes=allow_license_changes, |
157 |
- allow_unmasks=allow_unmasks): |
158 |
+ if not self._pkg_visibility_check(pkg, autounmask_level): |
159 |
continue |
160 |
|
161 |
# Enable upgrade or downgrade to a version |
162 |
@@ -3904,19 +3920,13 @@ class depgraph(object): |
163 |
pkg_eb_visible = False |
164 |
for pkg_eb in self._iter_match_pkgs(pkg.root_config, |
165 |
"ebuild", Atom("=%s" % (pkg.cpv,))): |
166 |
- if self._pkg_visibility_check(pkg_eb, \ |
167 |
- allow_unstable_keywords=allow_unstable_keywords, |
168 |
- allow_license_changes=allow_license_changes, |
169 |
- allow_unmasks=allow_unmasks): |
170 |
+ if self._pkg_visibility_check(pkg_eb, autounmask_level): |
171 |
pkg_eb_visible = True |
172 |
break |
173 |
if not pkg_eb_visible: |
174 |
continue |
175 |
else: |
176 |
- if not self._pkg_visibility_check(pkg_eb, \ |
177 |
- allow_unstable_keywords=allow_unstable_keywords, |
178 |
- allow_license_changes=allow_license_changes, |
179 |
- allow_unmasks=allow_unmasks): |
180 |
+ if not self._pkg_visibility_check(pkg_eb, autounmask_level): |
181 |
continue |
182 |
|
183 |
# Calculation of USE for unbuilt ebuilds is relatively |
184 |
@@ -3946,7 +3956,7 @@ class depgraph(object): |
185 |
if atom.use: |
186 |
|
187 |
matched_pkgs_ignore_use.append(pkg) |
188 |
- if allow_use_changes and not pkg.built: |
189 |
+ if autounmask_level and autounmask_level.allow_use_changes and not pkg.built: |
190 |
target_use = {} |
191 |
for flag in atom.use.enabled: |
192 |
target_use[flag] = True |
193 |
@@ -4169,21 +4179,16 @@ class depgraph(object): |
194 |
|
195 |
if avoid_update: |
196 |
for pkg in matched_packages: |
197 |
- if pkg.installed and self._pkg_visibility_check(pkg, \ |
198 |
- allow_unstable_keywords=allow_unstable_keywords, |
199 |
- allow_license_changes=allow_license_changes, |
200 |
- allow_unmasks=allow_unmasks): |
201 |
+ if pkg.installed and self._pkg_visibility_check(pkg, autounmask_level): |
202 |
return pkg, existing_node |
203 |
|
204 |
visible_matches = [] |
205 |
if matched_oldpkg: |
206 |
visible_matches = [pkg.cpv for pkg in matched_oldpkg \ |
207 |
- if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords, |
208 |
- allow_license_changes=allow_license_changes, allow_unmasks=allow_unmasks)] |
209 |
+ if self._pkg_visibility_check(pkg, autounmask_level)] |
210 |
if not visible_matches: |
211 |
visible_matches = [pkg.cpv for pkg in matched_packages \ |
212 |
- if self._pkg_visibility_check(pkg, allow_unstable_keywords=allow_unstable_keywords, |
213 |
- allow_license_changes=allow_license_changes, allow_unmasks=allow_unmasks)] |
214 |
+ if self._pkg_visibility_check(pkg, autounmask_level)] |
215 |
if visible_matches: |
216 |
bestmatch = portage.best(visible_matches) |
217 |
else: |