1 |
Author: grobian |
2 |
Date: 2009-09-01 17:20:21 +0000 (Tue, 01 Sep 2009) |
3 |
New Revision: 14177 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/bin/repoman |
7 |
main/branches/prefix/pym/portage/__init__.py |
8 |
main/branches/prefix/pym/portage/_selinux.py |
9 |
main/branches/prefix/pym/portage/cache/ebuild_xattr.py |
10 |
main/branches/prefix/pym/portage/dbapi/vartree.py |
11 |
main/branches/prefix/pym/portage/dispatch_conf.py |
12 |
main/branches/prefix/pym/portage/util.py |
13 |
Log: |
14 |
Merged from trunk -r14160:14170 |
15 |
|
16 |
| 14161 | Fix mkdir() to call the local setfscreate() with strict | |
17 |
| zmedico | returncode checking. Thanks to Chris PeBenito | |
18 |
| | <pebenito@g.o> for this patch. | |
19 |
|
20 |
| 14162 | Use plain ascii encoding for this file, in order to avoid | |
21 |
| zmedico | error messages like this which building stages (happens | |
22 |
| | when python is built with USE=build): * Byte compiling | |
23 |
| | python modules for python-2.6 .. ... Compiling | |
24 |
| | //usr/lib64/portage/pym/portage/cache/ebuild_xattr.py ... | |
25 |
| | SyntaxError: ('unknown encoding: UTF8', | |
26 |
| | ('//usr/lib64/portage/pym/portage/cache/ ebuild_xattr.py', | |
27 |
| | 0, 0, None)) | |
28 |
|
29 |
| 14163 | Fix tar_contents() to handle UnicodeEncodeError by falling | |
30 |
| zmedico | back to utf_8 if appropriate. | |
31 |
|
32 |
| 14164 | Fix the code from bug #275796 to ensure that choices always | |
33 |
| zmedico | go into the preferred_in_graph slot when appropriate. | |
34 |
|
35 |
| 14165 | Bug #278729 - Inside dep_zapdeps(), account for USE | |
36 |
| zmedico | dependencies in some cases where USE settings can adversely | |
37 |
| | affect || preference evaluation. This requires invalid | |
38 |
| | atoms to be dropped inside _expand_new_virtuals() since we | |
39 |
| | only want real Atom instances inside dep_zapdeps(). Unlike | |
40 |
| | previous attempts to solve this bug, cases such as || ( | |
41 |
| | foo[a] foo[b] ) should now be correctly handled. | |
42 |
|
43 |
| 14166 | Improve logic for bug #278729. | |
44 |
| zmedico | | |
45 |
|
46 |
| 14167 | Bug #281834 - In getconfig(), do not allow definition of | |
47 |
| zmedico | variables that have invalid names according to shell | |
48 |
| | standards (such as names containing hyphens). | |
49 |
|
50 |
| 14168 | Use KeyValuePairFileLoader instead of getconfig() for | |
51 |
| zmedico | /etc/portage/modules, since getconfig() is too strict about | |
52 |
| | variable names now. Thanks to Arfrever for reporting. | |
53 |
|
54 |
| 14169 | Use KeyValuePairFileLoader intead on getconfig(), since | |
55 |
| zmedico | getconfig() is too strict about variable names now. | |
56 |
|
57 |
| 14170 | Many packages use setuptools at run-time, so remove it from | |
58 |
| arfrever | list of suspected run-time dependencies. | |
59 |
|
60 |
|
61 |
Modified: main/branches/prefix/bin/repoman |
62 |
=================================================================== |
63 |
--- main/branches/prefix/bin/repoman 2009-09-01 01:33:45 UTC (rev 14176) |
64 |
+++ main/branches/prefix/bin/repoman 2009-09-01 17:20:21 UTC (rev 14177) |
65 |
@@ -403,7 +403,6 @@ |
66 |
"dev-lang/swig", |
67 |
"dev-lang/yasm", |
68 |
"dev-perl/extutils-pkgconfig", |
69 |
- "dev-python/setuptools", |
70 |
"dev-util/byacc", |
71 |
"dev-util/cmake", |
72 |
"dev-util/ftjam", |
73 |
|
74 |
Modified: main/branches/prefix/pym/portage/__init__.py |
75 |
=================================================================== |
76 |
--- main/branches/prefix/pym/portage/__init__.py 2009-09-01 01:33:45 UTC (rev 14176) |
77 |
+++ main/branches/prefix/pym/portage/__init__.py 2009-09-01 17:20:21 UTC (rev 14177) |
78 |
@@ -69,6 +69,7 @@ |
79 |
'get_operator,isjustname,isspecific,isvalidatom,' + \ |
80 |
'match_from_list,match_to_list', |
81 |
'portage.eclass_cache', |
82 |
+ 'portage.env.loaders', |
83 |
'portage.exception', |
84 |
'portage.getbinpkg', |
85 |
'portage.locks', |
86 |
@@ -1632,8 +1633,10 @@ |
87 |
|
88 |
self.module_priority = ["user","default"] |
89 |
self.modules = {} |
90 |
- self.modules["user"] = getconfig( |
91 |
- os.path.join(config_root, MODULES_FILE_PATH)) |
92 |
+ modules_loader = portage.env.loaders.KeyValuePairFileLoader( |
93 |
+ os.path.join(config_root, MODULES_FILE_PATH), None, None) |
94 |
+ modules_dict, modules_errors = modules_loader.load() |
95 |
+ self.modules["user"] = modules_dict |
96 |
if self.modules["user"] is None: |
97 |
self.modules["user"] = {} |
98 |
self.modules["default"] = { |
99 |
@@ -7477,6 +7480,9 @@ |
100 |
if portage.dep._dep_check_strict: |
101 |
raise portage.exception.ParseError( |
102 |
_("invalid atom: '%s'") % x) |
103 |
+ else: |
104 |
+ # Only real Atom instances are allowed past this point. |
105 |
+ continue |
106 |
else: |
107 |
if x.blocker and x.blocker.overlap.forbid and \ |
108 |
eapi in ("0", "1") and portage.dep._dep_check_strict: |
109 |
@@ -7665,6 +7671,9 @@ |
110 |
preferred_in_graph = [] |
111 |
preferred_any_slot = [] |
112 |
preferred_non_installed = [] |
113 |
+ unsat_use_in_graph = [] |
114 |
+ unsat_use_installed = [] |
115 |
+ unsat_use_non_installed = [] |
116 |
other = [] |
117 |
|
118 |
# Alias the trees we'll be checking availability against |
119 |
@@ -7694,19 +7703,35 @@ |
120 |
continue |
121 |
|
122 |
all_available = True |
123 |
+ all_use_satisfied = True |
124 |
versions = {} |
125 |
for atom in atoms: |
126 |
if atom[:1] == "!": |
127 |
continue |
128 |
- avail_pkg = mydbapi.match(atom) |
129 |
+ # Ignore USE dependencies here since we don't want USE |
130 |
+ # settings to adversely affect || preference evaluation. |
131 |
+ avail_pkg = mydbapi.match(atom.without_use) |
132 |
if avail_pkg: |
133 |
avail_pkg = avail_pkg[-1] # highest (ascending order) |
134 |
avail_slot = "%s:%s" % (dep_getkey(atom), |
135 |
mydbapi.aux_get(avail_pkg, ["SLOT"])[0]) |
136 |
if not avail_pkg: |
137 |
all_available = False |
138 |
+ all_use_satisfied = False |
139 |
break |
140 |
|
141 |
+ if atom.use: |
142 |
+ avail_pkg_use = mydbapi.match(atom) |
143 |
+ if not avail_pkg_use: |
144 |
+ all_use_satisfied = False |
145 |
+ else: |
146 |
+ # highest (ascending order) |
147 |
+ avail_pkg_use = avail_pkg_use[-1] |
148 |
+ if avail_pkg_use != avail_pkg: |
149 |
+ avail_pkg = avail_pkg_use |
150 |
+ avail_slot = "%s:%s" % (dep_getkey(atom), |
151 |
+ mydbapi.aux_get(avail_pkg, ["SLOT"])[0]) |
152 |
+ |
153 |
versions[avail_slot] = avail_pkg |
154 |
|
155 |
this_choice = (atoms, versions, all_available) |
156 |
@@ -7730,13 +7755,20 @@ |
157 |
not slot_atom.startswith("virtual/"): |
158 |
all_installed_slots = False |
159 |
break |
160 |
- if all_installed: |
161 |
- if all_installed_slots: |
162 |
- preferred_installed.append(this_choice) |
163 |
+ if graph_db is None: |
164 |
+ if all_use_satisfied: |
165 |
+ if all_installed: |
166 |
+ if all_installed_slots: |
167 |
+ preferred_installed.append(this_choice) |
168 |
+ else: |
169 |
+ preferred_any_slot.append(this_choice) |
170 |
+ else: |
171 |
+ preferred_non_installed.append(this_choice) |
172 |
else: |
173 |
- preferred_any_slot.append(this_choice) |
174 |
- elif graph_db is None: |
175 |
- preferred_non_installed.append(this_choice) |
176 |
+ if all_installed_slots: |
177 |
+ unsat_use_installed.append(this_choice) |
178 |
+ else: |
179 |
+ unsat_use_non_installed.append(this_choice) |
180 |
else: |
181 |
all_in_graph = True |
182 |
for slot_atom in versions: |
183 |
@@ -7745,9 +7777,10 @@ |
184 |
not slot_atom.startswith("virtual/"): |
185 |
all_in_graph = False |
186 |
break |
187 |
+ circular_atom = None |
188 |
if all_in_graph: |
189 |
if parent is None or priority is None: |
190 |
- preferred_in_graph.append(this_choice) |
191 |
+ pass |
192 |
elif priority.buildtime: |
193 |
# Check if the atom would result in a direct circular |
194 |
# dependency and try to avoid that if it seems likely |
195 |
@@ -7755,7 +7788,6 @@ |
196 |
# buildtime deps that aren't already satisfied by an |
197 |
# installed package. |
198 |
cpv_slot_list = [parent] |
199 |
- circular_atom = None |
200 |
for atom in atoms: |
201 |
if "!" == atom[:1]: |
202 |
continue |
203 |
@@ -7768,19 +7800,35 @@ |
204 |
if match_from_list(atom, cpv_slot_list): |
205 |
circular_atom = atom |
206 |
break |
207 |
- if circular_atom is None: |
208 |
+ if circular_atom is not None: |
209 |
+ other.append(this_choice) |
210 |
+ else: |
211 |
+ if all_use_satisfied: |
212 |
+ if all_in_graph: |
213 |
preferred_in_graph.append(this_choice) |
214 |
+ elif all_installed: |
215 |
+ if all_installed_slots: |
216 |
+ preferred_installed.append(this_choice) |
217 |
+ else: |
218 |
+ preferred_any_slot.append(this_choice) |
219 |
else: |
220 |
- other.append(this_choice) |
221 |
+ preferred_non_installed.append(this_choice) |
222 |
else: |
223 |
- preferred_in_graph.append(this_choice) |
224 |
- else: |
225 |
- preferred_non_installed.append(this_choice) |
226 |
+ if all_in_graph: |
227 |
+ unsat_use_in_graph.append(this_choice) |
228 |
+ elif all_installed_slots: |
229 |
+ unsat_use_installed.append(this_choice) |
230 |
+ else: |
231 |
+ unsat_use_non_installed.append(this_choice) |
232 |
else: |
233 |
other.append(this_choice) |
234 |
|
235 |
+ # unsat_use_* must come after preferred_non_installed |
236 |
+ # for correct ordering in cases like || ( foo[a] foo[b] ). |
237 |
preferred = preferred_in_graph + preferred_installed + \ |
238 |
- preferred_any_slot + preferred_non_installed + other |
239 |
+ preferred_any_slot + preferred_non_installed + \ |
240 |
+ unsat_use_in_graph + unsat_use_installed + unsat_use_non_installed + \ |
241 |
+ other |
242 |
|
243 |
for allow_masked in (False, True): |
244 |
for atoms, versions, all_available in preferred: |
245 |
|
246 |
Modified: main/branches/prefix/pym/portage/_selinux.py |
247 |
=================================================================== |
248 |
--- main/branches/prefix/pym/portage/_selinux.py 2009-09-01 01:33:45 UTC (rev 14176) |
249 |
+++ main/branches/prefix/pym/portage/_selinux.py 2009-09-01 17:20:21 UTC (rev 14177) |
250 |
@@ -43,11 +43,11 @@ |
251 |
_("mkdir: Failed getting context of reference directory \"%s\".") \ |
252 |
% refdir) |
253 |
|
254 |
- selinux.setfscreatecon(ctx) |
255 |
+ setfscreate(ctx) |
256 |
try: |
257 |
os.mkdir(target) |
258 |
finally: |
259 |
- selinux.setfscreatecon() |
260 |
+ setfscreate() |
261 |
|
262 |
def rename(src, dest): |
263 |
src = _unicode_encode(src, encoding=_encodings['fs'], errors='strict') |
264 |
|
265 |
Modified: main/branches/prefix/pym/portage/cache/ebuild_xattr.py |
266 |
=================================================================== |
267 |
--- main/branches/prefix/pym/portage/cache/ebuild_xattr.py 2009-09-01 01:33:45 UTC (rev 14176) |
268 |
+++ main/branches/prefix/pym/portage/cache/ebuild_xattr.py 2009-09-01 17:20:21 UTC (rev 14177) |
269 |
@@ -1,6 +1,5 @@ |
270 |
-# -*- coding: UTF8 -*- |
271 |
# Copyright: 2009 Gentoo Foundation |
272 |
-# Author(s): Petteri Räty (betelgeuse@g.o) |
273 |
+# Author(s): Petteri Räty (betelgeuse@g.o) |
274 |
# License: GPL2 |
275 |
# $Id$ |
276 |
|
277 |
|
278 |
Modified: main/branches/prefix/pym/portage/dbapi/vartree.py |
279 |
=================================================================== |
280 |
--- main/branches/prefix/pym/portage/dbapi/vartree.py 2009-09-01 01:33:45 UTC (rev 14176) |
281 |
+++ main/branches/prefix/pym/portage/dbapi/vartree.py 2009-09-01 17:20:21 UTC (rev 14177) |
282 |
@@ -5131,6 +5131,26 @@ |
283 |
|
284 |
def tar_contents(contents, root, tar, protect=None, onProgress=None): |
285 |
os = _os_merge |
286 |
+ |
287 |
+ try: |
288 |
+ for x in contents: |
289 |
+ _unicode_encode(x, |
290 |
+ encoding=_encodings['merge'], |
291 |
+ errors='strict') |
292 |
+ except UnicodeEncodeError: |
293 |
+ # The package appears to have been merged with a |
294 |
+ # different value of sys.getfilesystemencoding(), |
295 |
+ # so fall back to utf_8 if appropriate. |
296 |
+ try: |
297 |
+ for x in contents: |
298 |
+ _unicode_encode(x, |
299 |
+ encoding=_encodings['fs'], |
300 |
+ errors='strict') |
301 |
+ except UnicodeEncodeError: |
302 |
+ pass |
303 |
+ else: |
304 |
+ os = portage.os |
305 |
+ |
306 |
from portage.util import normalize_path |
307 |
import tarfile |
308 |
root = normalize_path(root).rstrip(os.path.sep) + os.path.sep |
309 |
@@ -5178,7 +5198,8 @@ |
310 |
tar.addfile(tarinfo) |
311 |
else: |
312 |
f = open(_unicode_encode(path, |
313 |
- encoding=_encodings['merge'], errors='strict'), 'rb') |
314 |
+ encoding=object.__getattribute__(os, '_encoding'), |
315 |
+ errors='strict'), 'rb') |
316 |
try: |
317 |
tar.addfile(tarinfo, f) |
318 |
finally: |
319 |
|
320 |
Modified: main/branches/prefix/pym/portage/dispatch_conf.py |
321 |
=================================================================== |
322 |
--- main/branches/prefix/pym/portage/dispatch_conf.py 2009-09-01 01:33:45 UTC (rev 14176) |
323 |
+++ main/branches/prefix/pym/portage/dispatch_conf.py 2009-09-01 17:20:21 UTC (rev 14177) |
324 |
@@ -21,15 +21,19 @@ |
325 |
DIFF3_MERGE = "diff3 -mE '%s' '%s' '%s' > '%s'" |
326 |
|
327 |
def read_config(mandatory_opts): |
328 |
- try: |
329 |
- opts = portage.getconfig(portage.const.EPREFIX+'/etc/dispatch-conf.conf') |
330 |
- except: |
331 |
- opts = None |
332 |
- |
333 |
+ loader = portage.env.loaders.KeyValuePairFileLoader( |
334 |
+ portage.const.EPREFIX+'/etc/dispatch-conf.conf', None) |
335 |
+ opts, errors = loader.load() |
336 |
if not opts: |
337 |
print >> sys.stderr, _('dispatch-conf: Error reading %s/etc/dispatch-conf.conf; fatal') % (portage.const.EPREFIX,) |
338 |
sys.exit(1) |
339 |
|
340 |
+ # Handle quote removal here, since KeyValuePairFileLoader doesn't do that. |
341 |
+ quotes = "\"'" |
342 |
+ for k, v in opts.iteritems(): |
343 |
+ if v[:1] in quotes and v[:1] == v[-1:]: |
344 |
+ opts[k] = v[1:-1] |
345 |
+ |
346 |
for key in mandatory_opts: |
347 |
if key not in opts: |
348 |
if key == "merge": |
349 |
|
350 |
Modified: main/branches/prefix/pym/portage/util.py |
351 |
=================================================================== |
352 |
--- main/branches/prefix/pym/portage/util.py 2009-09-01 01:33:45 UTC (rev 14176) |
353 |
+++ main/branches/prefix/pym/portage/util.py 2009-09-01 17:20:21 UTC (rev 14177) |
354 |
@@ -16,6 +16,7 @@ |
355 |
import codecs |
356 |
import errno |
357 |
import logging |
358 |
+import re |
359 |
import shlex |
360 |
import stat |
361 |
import string |
362 |
@@ -380,6 +381,8 @@ |
363 |
(self.infile, str(e)), noiselevel=-1) |
364 |
return (newfile, StringIO()) |
365 |
|
366 |
+_invalid_var_name_re = re.compile(r'^\d|\W') |
367 |
+ |
368 |
def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True): |
369 |
if isinstance(expand, dict): |
370 |
# Some existing variable definitions have been |
371 |
@@ -463,6 +466,16 @@ |
372 |
return mykeys |
373 |
key = _unicode_decode(key) |
374 |
val = _unicode_decode(val) |
375 |
+ |
376 |
+ if _invalid_var_name_re.search(key) is not None: |
377 |
+ if not tolerant: |
378 |
+ raise Exception(_( |
379 |
+ "ParseError: Invalid variable name '%s': line %s") % \ |
380 |
+ (key, lex.lineno - 1)) |
381 |
+ writemsg(_("!!! Invalid variable name '%s': line %s in %s\n") \ |
382 |
+ % (key, lex.lineno - 1, mycfg), noiselevel=-1) |
383 |
+ continue |
384 |
+ |
385 |
if expand: |
386 |
mykeys[key] = varexpand(val, expand_map) |
387 |
expand_map[key] = mykeys[key] |