1 |
Author: grobian |
2 |
Date: 2009-08-24 09:36:42 +0000 (Mon, 24 Aug 2009) |
3 |
New Revision: 14142 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/bin/repoman |
7 |
main/branches/prefix/man/portage.5 |
8 |
main/branches/prefix/pym/_emerge/Binpkg.py |
9 |
main/branches/prefix/pym/_emerge/BinpkgVerifier.py |
10 |
main/branches/prefix/pym/_emerge/EbuildBuild.py |
11 |
main/branches/prefix/pym/_emerge/EbuildFetcher.py |
12 |
main/branches/prefix/pym/_emerge/EbuildMetadataPhase.py |
13 |
main/branches/prefix/pym/_emerge/EbuildPhase.py |
14 |
main/branches/prefix/pym/_emerge/PackageUninstall.py |
15 |
main/branches/prefix/pym/_emerge/Scheduler.py |
16 |
main/branches/prefix/pym/_emerge/changelog.py |
17 |
main/branches/prefix/pym/_emerge/emergelog.py |
18 |
main/branches/prefix/pym/portage/__init__.py |
19 |
main/branches/prefix/pym/portage/cache/flat_hash.py |
20 |
main/branches/prefix/pym/portage/cache/flat_list.py |
21 |
main/branches/prefix/pym/portage/cache/metadata.py |
22 |
Log: |
23 |
Merged from trunk -r14097:14107 |
24 |
|
25 |
| 14098 | Use _encodings['repo.content'] for decoding profiles.desc, | |
26 |
| zmedico | ChangeLog, metadata.xml, and ebuilds. | |
27 |
|
28 |
| 14099 | Use _encodings where appropriate. | |
29 |
| zmedico | | |
30 |
|
31 |
| 14100 | Use _encodings where appropriate. | |
32 |
| zmedico | | |
33 |
|
34 |
| 14101 | Use _encodings where appropriate. | |
35 |
| zmedico | | |
36 |
|
37 |
| 14102 | If sys.getdefaultencoding() returns None (this can happen | |
38 |
| zmedico | if python is built with USE=build, in stage 1), fall back | |
39 |
| | to _encodings['merge'] = 'ascii'. | |
40 |
|
41 |
| 14103 | Fix typo from previous commit. | |
42 |
| zmedico | | |
43 |
|
44 |
| 14104 | Fix portage.5 man page to document the fact that some files | |
45 |
| arfrever | in profiles directory can be directories. | |
46 |
|
47 |
| 14105 | Use _encodings where appropriate. | |
48 |
| zmedico | | |
49 |
|
50 |
| 14106 | Use _encodings where appropriate. | |
51 |
| zmedico | | |
52 |
|
53 |
| 14107 | Use _encodings where appropriate. | |
54 |
| zmedico | | |
55 |
|
56 |
|
57 |
Modified: main/branches/prefix/bin/repoman |
58 |
=================================================================== |
59 |
--- main/branches/prefix/bin/repoman 2009-08-24 09:34:26 UTC (rev 14141) |
60 |
+++ main/branches/prefix/bin/repoman 2009-08-24 09:36:42 UTC (rev 14142) |
61 |
@@ -44,6 +44,8 @@ |
62 |
|
63 |
portage._disable_legacy_globals() |
64 |
from portage import os |
65 |
+from portage import _encodings |
66 |
+from portage import _unicode_encode |
67 |
|
68 |
from repoman.checks import run_checks |
69 |
from repoman import utilities |
70 |
@@ -600,8 +602,9 @@ |
71 |
|
72 |
desc_path = os.path.join(path, 'profiles', 'profiles.desc') |
73 |
try: |
74 |
- desc_file = codecs.open(desc_path, mode='r', |
75 |
- encoding='utf_8', errors='replace') |
76 |
+ desc_file = codecs.open(_unicode_encode(desc_path, |
77 |
+ encoding=_encodings['fs'], errors='strict'), |
78 |
+ mode='r', encoding=_encodings['repo.content'], errors='replace') |
79 |
except EnvironmentError: |
80 |
pass |
81 |
else: |
82 |
@@ -971,8 +974,9 @@ |
83 |
continue |
84 |
try: |
85 |
line = 1 |
86 |
- for l in codecs.open(os.path.join(checkdir, y), mode='r', |
87 |
- encoding='utf_8'): |
88 |
+ for l in codecs.open(_unicode_encode(os.path.join(checkdir, y), |
89 |
+ encoding=_encodings['fs'], errors='strict'), |
90 |
+ mode='r', encoding=_encodings['repo.content']): |
91 |
line +=1 |
92 |
except UnicodeDecodeError, ue: |
93 |
stats["file.UTF8"] += 1 |
94 |
@@ -1553,7 +1557,9 @@ |
95 |
full_path = os.path.join(repodir, relative_path) |
96 |
try: |
97 |
# All ebuilds should have utf_8 encoding. |
98 |
- f = codecs.open(full_path, mode='r', encoding='utf_8') |
99 |
+ f = codecs.open(_unicode_encode(full_path, |
100 |
+ encoding=_encodings['fs'], errors='strict'), |
101 |
+ mode='r', encoding=_encodings['repo.content']) |
102 |
try: |
103 |
for check_name, e in run_checks(f, pkg): |
104 |
stats[check_name] += 1 |
105 |
|
106 |
Modified: main/branches/prefix/man/portage.5 |
107 |
=================================================================== |
108 |
--- main/branches/prefix/man/portage.5 2009-08-24 09:34:26 UTC (rev 14141) |
109 |
+++ main/branches/prefix/man/portage.5 2009-08-24 09:36:42 UTC (rev 14142) |
110 |
@@ -143,6 +143,18 @@ |
111 |
types that \fB/etc/make.profile/\fR does, except parent). Do NOT edit the |
112 |
settings in \fB/etc/make.profile/\fR because they WILL be lost with the next |
113 |
`emerge \-\-sync`. |
114 |
+ |
115 |
+Any file in this directory, directories of other profiles or top-level |
116 |
+"profiles" directory that begins with "package." or "use." can be more than |
117 |
+just a flat file. If it is a directory, then all the files in that directory |
118 |
+will be sorted in ascending alphabetical order by file name and summed together |
119 |
+as if it were a single file. |
120 |
+ |
121 |
+.I Example: |
122 |
+.nf |
123 |
+/usr/portage/profiles/package.mask/removals |
124 |
+/usr/portage/profiles/package.mask/testing |
125 |
+.fi |
126 |
.RS |
127 |
.TP |
128 |
.BR deprecated |
129 |
|
130 |
Modified: main/branches/prefix/pym/_emerge/Binpkg.py |
131 |
=================================================================== |
132 |
--- main/branches/prefix/pym/_emerge/Binpkg.py 2009-08-24 09:34:26 UTC (rev 14141) |
133 |
+++ main/branches/prefix/pym/_emerge/Binpkg.py 2009-08-24 09:36:42 UTC (rev 14142) |
134 |
@@ -12,6 +12,8 @@ |
135 |
from portage.util import writemsg |
136 |
import portage |
137 |
from portage import os |
138 |
+from portage import _encodings |
139 |
+from portage import _unicode_encode |
140 |
import codecs |
141 |
import sys |
142 |
if os.environ.__contains__("PORTAGE_PYTHONPATH"): |
143 |
@@ -41,8 +43,9 @@ |
144 |
|
145 |
log_path = self.settings.get("PORTAGE_LOG_FILE") |
146 |
if log_path is not None: |
147 |
- f = codecs.open(log_path, mode='a', |
148 |
- encoding='utf_8', errors='replace') |
149 |
+ f = codecs.open(_unicode_encode(log_path, |
150 |
+ encoding=_encodings['fs'], errors='strict'), |
151 |
+ mode='a', encoding=_encodings['content'], errors='replace') |
152 |
try: |
153 |
f.write(msg) |
154 |
finally: |
155 |
@@ -235,15 +238,18 @@ |
156 |
else: |
157 |
continue |
158 |
|
159 |
- f = codecs.open(os.path.join(infloc, k), mode='w', |
160 |
- encoding='utf_8', errors='replace') |
161 |
+ f = codecs.open(_unicode_encode(os.path.join(infloc, k), |
162 |
+ encoding=_encodings['fs'], errors='strict'), |
163 |
+ mode='w', encoding=_encodings['content'], errors='replace') |
164 |
try: |
165 |
f.write(v + "\n") |
166 |
finally: |
167 |
f.close() |
168 |
|
169 |
# Store the md5sum in the vdb. |
170 |
- f = open(os.path.join(infloc, "BINPKGMD5"), "w") |
171 |
+ f = codecs.open(_unicode_encode(os.path.join(infloc, 'BINPKGMD5'), |
172 |
+ encoding=_encodings['fs'], errors='strict'), |
173 |
+ mode='w', encoding=_encodings['content'], errors='strict') |
174 |
try: |
175 |
f.write(str(portage.checksum.perform_md5(pkg_path)) + "\n") |
176 |
finally: |
177 |
|
178 |
Modified: main/branches/prefix/pym/_emerge/BinpkgVerifier.py |
179 |
=================================================================== |
180 |
--- main/branches/prefix/pym/_emerge/BinpkgVerifier.py 2009-08-24 09:34:26 UTC (rev 14141) |
181 |
+++ main/branches/prefix/pym/_emerge/BinpkgVerifier.py 2009-08-24 09:36:42 UTC (rev 14142) |
182 |
@@ -7,6 +7,8 @@ |
183 |
import sys |
184 |
import portage |
185 |
from portage import os |
186 |
+from portage import _encodings |
187 |
+from portage import _unicode_encode |
188 |
import codecs |
189 |
|
190 |
class BinpkgVerifier(AsynchronousTask): |
191 |
@@ -27,8 +29,9 @@ |
192 |
stderr_orig = sys.stderr |
193 |
log_file = None |
194 |
if self.background and self.logfile is not None: |
195 |
- log_file = codecs.open(self.logfile, mode='a', |
196 |
- encoding='utf_8', errors='replace') |
197 |
+ log_file = codecs.open(_unicode_encode(self.logfile, |
198 |
+ encoding=_encodings['fs'], errors='strict'), |
199 |
+ mode='a', encoding=_encodings['content'], errors='replace') |
200 |
try: |
201 |
if log_file is not None: |
202 |
sys.stdout = log_file |
203 |
|
204 |
Modified: main/branches/prefix/pym/_emerge/EbuildBuild.py |
205 |
=================================================================== |
206 |
--- main/branches/prefix/pym/_emerge/EbuildBuild.py 2009-08-24 09:34:26 UTC (rev 14141) |
207 |
+++ main/branches/prefix/pym/_emerge/EbuildBuild.py 2009-08-24 09:36:42 UTC (rev 14142) |
208 |
@@ -13,6 +13,9 @@ |
209 |
from portage.util import writemsg |
210 |
import portage |
211 |
from portage import os |
212 |
+from portage import _encodings |
213 |
+from portage import _unicode_encode |
214 |
+import codecs |
215 |
from portage.output import colorize |
216 |
from portage.const import EPREFIX |
217 |
class EbuildBuild(CompositeTask): |
218 |
@@ -182,8 +185,9 @@ |
219 |
|
220 |
log_path = self.settings.get("PORTAGE_LOG_FILE") |
221 |
if log_path is not None: |
222 |
- log_file = codecs.open(log_path, mode='a', |
223 |
- encoding='utf_8', errors='replace') |
224 |
+ log_file = codecs.open(_unicode_encode(log_path, |
225 |
+ encoding=_encodings['fs'], errors='strict'), |
226 |
+ mode='a', encoding=_encodings['content'], errors='replace') |
227 |
try: |
228 |
log_file.write(msg) |
229 |
finally: |
230 |
|
231 |
Modified: main/branches/prefix/pym/_emerge/EbuildFetcher.py |
232 |
=================================================================== |
233 |
--- main/branches/prefix/pym/_emerge/EbuildFetcher.py 2009-08-24 09:34:26 UTC (rev 14141) |
234 |
+++ main/branches/prefix/pym/_emerge/EbuildFetcher.py 2009-08-24 09:36:42 UTC (rev 14142) |
235 |
@@ -9,6 +9,8 @@ |
236 |
import sys |
237 |
import portage |
238 |
from portage import os |
239 |
+from portage import _encodings |
240 |
+from portage import _unicode_encode |
241 |
import codecs |
242 |
from portage.elog.messages import eerror |
243 |
|
244 |
@@ -90,8 +92,9 @@ |
245 |
elog_out = None |
246 |
if self.logfile is not None: |
247 |
if self.background: |
248 |
- elog_out = codecs.open(self.logfile, mode='a', |
249 |
- encoding='utf_8', errors='replace') |
250 |
+ elog_out = codecs.open(_unicode_encode(self.logfile, |
251 |
+ encoding=_encodings['fs'], errors='strict'), |
252 |
+ mode='a', encoding=_encodings['content'], errors='replace') |
253 |
msg = "Fetch failed for '%s'" % (self.pkg.cpv,) |
254 |
if self.logfile is not None: |
255 |
msg += ", Log file:" |
256 |
|
257 |
Modified: main/branches/prefix/pym/_emerge/EbuildMetadataPhase.py |
258 |
=================================================================== |
259 |
--- main/branches/prefix/pym/_emerge/EbuildMetadataPhase.py 2009-08-24 09:34:26 UTC (rev 14141) |
260 |
+++ main/branches/prefix/pym/_emerge/EbuildMetadataPhase.py 2009-08-24 09:36:42 UTC (rev 14142) |
261 |
@@ -8,6 +8,8 @@ |
262 |
from portage.cache.mappings import slot_dict_class |
263 |
import portage |
264 |
from portage import os |
265 |
+from portage import _encodings |
266 |
+from portage import _unicode_encode |
267 |
from itertools import izip |
268 |
import fcntl |
269 |
import codecs |
270 |
@@ -38,8 +40,11 @@ |
271 |
os.path.basename(ebuild_path)) |
272 |
if eapi is None and \ |
273 |
'parse-eapi-ebuild-head' in settings.features: |
274 |
- eapi = portage._parse_eapi_ebuild_head(codecs.open(ebuild_path, |
275 |
- mode='r', encoding='utf_8', errors='replace')) |
276 |
+ eapi = portage._parse_eapi_ebuild_head( |
277 |
+ codecs.open(_unicode_encode(ebuild_path, |
278 |
+ encoding=_encodings['fs'], errors='strict'), |
279 |
+ mode='r', encoding=_encodings['repo.content'], |
280 |
+ errors='replace')) |
281 |
|
282 |
if eapi is not None: |
283 |
if not portage.eapi_is_supported(eapi): |
284 |
@@ -82,7 +87,7 @@ |
285 |
fd_pipes[self._metadata_fd] = slave_fd |
286 |
|
287 |
self._raw_metadata = [] |
288 |
- files.ebuild = os.fdopen(master_fd, 'r') |
289 |
+ files.ebuild = os.fdopen(master_fd, 'rb') |
290 |
self._reg_id = self.scheduler.register(files.ebuild.fileno(), |
291 |
self._registered_events, self._output_handler) |
292 |
self._registered = True |
293 |
@@ -118,8 +123,8 @@ |
294 |
def _set_returncode(self, wait_retval): |
295 |
SubProcess._set_returncode(self, wait_retval) |
296 |
if self.returncode == os.EX_OK: |
297 |
- metadata_lines = u''.join(unicode(chunk, |
298 |
- encoding='utf_8', errors='replace') |
299 |
+ metadata_lines = ''.join(unicode(chunk, |
300 |
+ encoding=_encodings['repo.content'], errors='replace') |
301 |
for chunk in self._raw_metadata).splitlines() |
302 |
if len(portage.auxdbkeys) != len(metadata_lines): |
303 |
# Don't trust bash's returncode if the |
304 |
|
305 |
Modified: main/branches/prefix/pym/_emerge/EbuildPhase.py |
306 |
=================================================================== |
307 |
--- main/branches/prefix/pym/_emerge/EbuildPhase.py 2009-08-24 09:34:26 UTC (rev 14141) |
308 |
+++ main/branches/prefix/pym/_emerge/EbuildPhase.py 2009-08-24 09:36:42 UTC (rev 14142) |
309 |
@@ -8,6 +8,8 @@ |
310 |
from portage.util import writemsg |
311 |
import portage |
312 |
from portage import os |
313 |
+from portage import _encodings |
314 |
+from portage import _unicode_encode |
315 |
import codecs |
316 |
|
317 |
class EbuildPhase(CompositeTask): |
318 |
@@ -32,8 +34,9 @@ |
319 |
log_path = self.settings.get("PORTAGE_LOG_FILE") |
320 |
log_file = None |
321 |
if self.background and log_path is not None: |
322 |
- log_file = codecs.open(log_path, mode='a', |
323 |
- encoding='utf_8', errors='replace') |
324 |
+ log_file = codecs.open(_unicode_encode(log_path, |
325 |
+ encoding=_encodings['fs'], errors='strict'), |
326 |
+ mode='a', encoding=_encodings['content'], errors='replace') |
327 |
out = log_file |
328 |
try: |
329 |
portage._check_build_log(self.settings, out=out) |
330 |
@@ -52,8 +55,9 @@ |
331 |
log_path = self.settings.get("PORTAGE_LOG_FILE") |
332 |
log_file = None |
333 |
if self.background and log_path is not None: |
334 |
- log_file = codecs.open(log_path, mode='a', |
335 |
- encoding='utf_8', errors='replace') |
336 |
+ log_file = codecs.open(_unicode_encode(log_path, |
337 |
+ encoding=_encodings['fs'], errors='strict'), |
338 |
+ mode='a', encoding=_encodings['content'], errors='replace') |
339 |
out = log_file |
340 |
portage._post_src_install_chost_fix(settings) |
341 |
portage._post_src_install_uid_fix(settings, out=out) |
342 |
|
343 |
Modified: main/branches/prefix/pym/_emerge/PackageUninstall.py |
344 |
=================================================================== |
345 |
--- main/branches/prefix/pym/_emerge/PackageUninstall.py 2009-08-24 09:34:26 UTC (rev 14141) |
346 |
+++ main/branches/prefix/pym/_emerge/PackageUninstall.py 2009-08-24 09:36:42 UTC (rev 14142) |
347 |
@@ -6,6 +6,8 @@ |
348 |
import logging |
349 |
import portage |
350 |
from portage import os |
351 |
+from portage import _encodings |
352 |
+from portage import _unicode_encode |
353 |
from _emerge.AsynchronousTask import AsynchronousTask |
354 |
from _emerge.unmerge import unmerge |
355 |
from _emerge.UninstallFailure import UninstallFailure |
356 |
@@ -45,8 +47,9 @@ |
357 |
portage.util.writemsg_level(msg, |
358 |
level=level, noiselevel=noiselevel) |
359 |
|
360 |
- f = codecs.open(log_path, mode='a', |
361 |
- encoding='utf_8', errors='replace') |
362 |
+ f = codecs.open(_unicode_encode(log_path, |
363 |
+ encoding=_encodings['fs'], errors='strict'), |
364 |
+ mode='a', encoding=_encodings['content'], errors='replace') |
365 |
try: |
366 |
f.write(msg) |
367 |
finally: |
368 |
|
369 |
Modified: main/branches/prefix/pym/_emerge/Scheduler.py |
370 |
=================================================================== |
371 |
--- main/branches/prefix/pym/_emerge/Scheduler.py 2009-08-24 09:34:26 UTC (rev 14141) |
372 |
+++ main/branches/prefix/pym/_emerge/Scheduler.py 2009-08-24 09:36:42 UTC (rev 14142) |
373 |
@@ -11,10 +11,14 @@ |
374 |
from itertools import izip |
375 |
import portage |
376 |
from portage import os |
377 |
+from portage import _encodings |
378 |
+from portage import _unicode_decode |
379 |
+from portage import _unicode_encode |
380 |
from portage.cache.mappings import slot_dict_class |
381 |
from portage.elog.messages import eerror |
382 |
from portage.output import colorize, create_color_func, darkgreen, red |
383 |
bad = create_color_func("BAD") |
384 |
+from portage.sets import SETPREFIX |
385 |
from portage.sets.base import InternalPackageSet |
386 |
from portage.util import writemsg, writemsg_level |
387 |
|
388 |
@@ -471,10 +475,13 @@ |
389 |
|
390 |
def _append_to_log_path(self, log_path, msg): |
391 |
|
392 |
- f = codecs.open(portage._unicode_encode(log_path), mode='a', |
393 |
- encoding='utf_8', errors='replace') |
394 |
+ f = codecs.open(_unicode_encode(log_path, |
395 |
+ encoding=_encodings['fs'], errors='strict'), |
396 |
+ mode='a', encoding=_encodings['content'], |
397 |
+ errors='backslashreplace') |
398 |
try: |
399 |
- f.write(portage._unicode_decode(msg)) |
400 |
+ f.write(_unicode_decode(msg, |
401 |
+ encoding=_encodings['content'], errors='replace')) |
402 |
finally: |
403 |
f.close() |
404 |
|
405 |
@@ -486,8 +493,10 @@ |
406 |
background = self._background |
407 |
|
408 |
if background and log_path is not None: |
409 |
- log_file = codecs.open(portage._unicode_encode(log_path), mode='a', |
410 |
- encoding='utf_8', errors='replace') |
411 |
+ log_file = codecs.open(_unicode_encode(log_path, |
412 |
+ encoding=_encodings['fs'], errors='strict'), |
413 |
+ mode='a', encoding=_encodings['content'], |
414 |
+ errors='backslashreplace') |
415 |
out = log_file |
416 |
|
417 |
try: |
418 |
@@ -862,8 +871,9 @@ |
419 |
log_path = self._locate_failure_log(failed_pkg) |
420 |
if log_path is not None: |
421 |
try: |
422 |
- log_file = codecs.open(portage._unicode_encode(log_path), |
423 |
- mode='r', encoding='utf_8', errors='replace') |
424 |
+ log_file = codecs.open(_unicode_encode(log_path, |
425 |
+ encoding=_encodings['fs'], errors='strict'), |
426 |
+ mode='r', encoding=_encodings['content'], errors='replace') |
427 |
except IOError: |
428 |
pass |
429 |
|
430 |
|
431 |
Modified: main/branches/prefix/pym/_emerge/changelog.py |
432 |
=================================================================== |
433 |
--- main/branches/prefix/pym/_emerge/changelog.py 2009-08-24 09:34:26 UTC (rev 14141) |
434 |
+++ main/branches/prefix/pym/_emerge/changelog.py 2009-08-24 09:36:42 UTC (rev 14142) |
435 |
@@ -7,6 +7,8 @@ |
436 |
|
437 |
import portage |
438 |
from portage import os |
439 |
+from portage import _encodings |
440 |
+from portage import _unicode_encode |
441 |
|
442 |
def calc_changelog(ebuildpath,current,next): |
443 |
if ebuildpath == None or not os.path.exists(ebuildpath): |
444 |
@@ -19,8 +21,10 @@ |
445 |
next = next[:-3] |
446 |
changelogpath = os.path.join(os.path.split(ebuildpath)[0],'ChangeLog') |
447 |
try: |
448 |
- changelog = codecs.open(portage._unicode_encode(changelogpath), |
449 |
- mode='r', encoding='utf_8', errors='replace').read() |
450 |
+ changelog = codecs.open(_unicode_encode(changelogpath, |
451 |
+ encoding=_encodings['fs'], errors='strict'), |
452 |
+ mode='r', encoding=_encodings['repo.content'], errors='replace' |
453 |
+ ).read() |
454 |
except SystemExit, e: |
455 |
raise # Needed else can't exit |
456 |
except: |
457 |
|
458 |
Modified: main/branches/prefix/pym/_emerge/emergelog.py |
459 |
=================================================================== |
460 |
--- main/branches/prefix/pym/_emerge/emergelog.py 2009-08-24 09:34:26 UTC (rev 14141) |
461 |
+++ main/branches/prefix/pym/_emerge/emergelog.py 2009-08-24 09:36:42 UTC (rev 14142) |
462 |
@@ -7,6 +7,8 @@ |
463 |
import time |
464 |
import portage |
465 |
from portage import os |
466 |
+from portage import _encodings |
467 |
+from portage import _unicode_encode |
468 |
from portage.data import secpass |
469 |
from portage.output import xtermTitle |
470 |
from portage.const import EPREFIX |
471 |
@@ -26,8 +28,10 @@ |
472 |
xtermTitle(short_msg) |
473 |
try: |
474 |
file_path = os.path.join(_emerge_log_dir, 'emerge.log') |
475 |
- mylogfile = codecs.open(portage._unicode_encode(file_path), mode='a', |
476 |
- encoding='utf_8', errors='replace') |
477 |
+ mylogfile = codecs.open(_unicode_encode(file_path, |
478 |
+ encoding=_encodings['fs'], errors='strict'), |
479 |
+ mode='a', encoding=_encodings['content'], |
480 |
+ errors='backslashreplace') |
481 |
portage.util.apply_secpass_permissions(file_path, |
482 |
uid=portage.portage_uid, gid=portage.portage_gid, |
483 |
mode=0660) |
484 |
|
485 |
Modified: main/branches/prefix/pym/portage/__init__.py |
486 |
=================================================================== |
487 |
--- main/branches/prefix/pym/portage/__init__.py 2009-08-24 09:34:26 UTC (rev 14141) |
488 |
+++ main/branches/prefix/pym/portage/__init__.py 2009-08-24 09:36:42 UTC (rev 14142) |
489 |
@@ -125,8 +125,13 @@ |
490 |
'content' : 'utf_8', |
491 |
'fs' : 'utf_8', |
492 |
'merge' : sys.getfilesystemencoding(), |
493 |
+ 'repo.content' : 'utf_8', |
494 |
} |
495 |
|
496 |
+# This can happen if python is built with USE=build (stage 1). |
497 |
+if _encodings['merge'] is None: |
498 |
+ _encodings['merge'] = 'ascii' |
499 |
+ |
500 |
# Deprecated attributes. Instead use _encodings directly. |
501 |
_content_encoding = _encodings['content'] |
502 |
_fs_encoding = _encodings['fs'] |
503 |
@@ -352,7 +357,7 @@ |
504 |
|
505 |
default_fallback = 'utf_8' |
506 |
default_encoding = sys.getdefaultencoding().lower().replace('-', '_') |
507 |
- filesystem_encoding = sys.getfilesystemencoding().lower().replace('-', '_') |
508 |
+ filesystem_encoding = _encodings['merge'].lower().replace('-', '_') |
509 |
required_encodings = set(['ascii', 'utf_8']) |
510 |
required_encodings.add(default_encoding) |
511 |
required_encodings.add(filesystem_encoding) |
512 |
|
513 |
Modified: main/branches/prefix/pym/portage/cache/flat_hash.py |
514 |
=================================================================== |
515 |
--- main/branches/prefix/pym/portage/cache/flat_hash.py 2009-08-24 09:34:26 UTC (rev 14141) |
516 |
+++ main/branches/prefix/pym/portage/cache/flat_hash.py 2009-08-24 09:36:42 UTC (rev 14142) |
517 |
@@ -9,6 +9,7 @@ |
518 |
import errno |
519 |
import stat |
520 |
from portage import os |
521 |
+from portage import _encodings |
522 |
from portage import _unicode_encode |
523 |
|
524 |
class database(fs_template.FsBased): |
525 |
@@ -29,8 +30,10 @@ |
526 |
def _getitem(self, cpv): |
527 |
fp = os.path.join(self.location, cpv) |
528 |
try: |
529 |
- myf = codecs.open(_unicode_encode(fp), |
530 |
- mode='r', encoding='utf_8', errors='replace') |
531 |
+ myf = codecs.open(_unicode_encode(fp, |
532 |
+ encoding=_encodings['fs'], errors='strict'), |
533 |
+ mode='r', encoding=_encodings['repo.content'], |
534 |
+ errors='replace') |
535 |
try: |
536 |
d = self._parse_data(myf.readlines(), cpv) |
537 |
if '_mtime_' not in d: |
538 |
@@ -58,14 +61,18 @@ |
539 |
s = cpv.rfind("/") |
540 |
fp = os.path.join(self.location,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:])) |
541 |
try: |
542 |
- myf = codecs.open(_unicode_encode(fp), mode='w', |
543 |
- encoding='utf_8', errors='replace') |
544 |
+ myf = codecs.open(_unicode_encode(fp, |
545 |
+ encoding=_encodings['fs'], errors='strict'), |
546 |
+ mode='w', encoding=_encodings['repo.content'], |
547 |
+ errors='backslashreplace') |
548 |
except (IOError, OSError), e: |
549 |
if errno.ENOENT == e.errno: |
550 |
try: |
551 |
self._ensure_dirs(cpv) |
552 |
- myf = codecs.open(_unicode_encode(fp), mode='w', |
553 |
- encoding='utf_8', errors='replace') |
554 |
+ myf = codecs.open(_unicode_encode(fp, |
555 |
+ encoding=_encodings['fs'], errors='strict'), |
556 |
+ mode='w', encoding=_encodings['repo.content'], |
557 |
+ errors='backslashreplace') |
558 |
except (OSError, IOError),e: |
559 |
raise cache_errors.CacheCorruption(cpv, e) |
560 |
else: |
561 |
|
562 |
Modified: main/branches/prefix/pym/portage/cache/flat_list.py |
563 |
=================================================================== |
564 |
--- main/branches/prefix/pym/portage/cache/flat_list.py 2009-08-24 09:34:26 UTC (rev 14141) |
565 |
+++ main/branches/prefix/pym/portage/cache/flat_list.py 2009-08-24 09:36:42 UTC (rev 14142) |
566 |
@@ -1,6 +1,7 @@ |
567 |
from portage.cache import fs_template |
568 |
from portage.cache import cache_errors |
569 |
from portage import os |
570 |
+from portage import _encodings |
571 |
from portage import _unicode_encode |
572 |
import codecs |
573 |
import errno |
574 |
@@ -31,8 +32,10 @@ |
575 |
def _getitem(self, cpv): |
576 |
d = {} |
577 |
try: |
578 |
- myf = codecs.open(_unicode_encode(os.path.join(self._base, cpv)), |
579 |
- mode='r', encoding='utf_8', errors='replace') |
580 |
+ myf = codecs.open(_unicode_encode(os.path.join(self._base, cpv), |
581 |
+ encoding=_encodings['fs'], errors='strict'), |
582 |
+ mode='r', encoding=_encodings['repo.content'], |
583 |
+ errors='replace') |
584 |
for k,v in zip(self.auxdbkey_order, myf): |
585 |
d[k] = v.rstrip("\n") |
586 |
except (OSError, IOError),e: |
587 |
@@ -53,14 +56,18 @@ |
588 |
s = cpv.rfind("/") |
589 |
fp=os.path.join(self._base,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:])) |
590 |
try: |
591 |
- myf = codecs.open(_unicode_encode(fp), mode='w', |
592 |
- encoding='utf_8', errors='replace') |
593 |
+ myf = codecs.open(_unicode_encode(fp, |
594 |
+ encoding=_encodings['fs'], errors='strict'), |
595 |
+ mode='w', encoding=_encodings['repo.content'], |
596 |
+ errors='backslashreplace') |
597 |
except (OSError, IOError), e: |
598 |
if errno.ENOENT == e.errno: |
599 |
try: |
600 |
self._ensure_dirs(cpv) |
601 |
- myf = codecs.open(_unicode_encode(fp), mode='w', |
602 |
- encoding='utf_8', errors='replace') |
603 |
+ myf = codecs.open(_unicode_encode(fp, |
604 |
+ encoding=_encodings['fs'], errors='strict'), |
605 |
+ mode='w', encoding=_encodings['repo.content'], |
606 |
+ errors='backslashreplace') |
607 |
except (OSError, IOError),e: |
608 |
raise cache_errors.CacheCorruption(cpv, e) |
609 |
else: |
610 |
|
611 |
Modified: main/branches/prefix/pym/portage/cache/metadata.py |
612 |
=================================================================== |
613 |
--- main/branches/prefix/pym/portage/cache/metadata.py 2009-08-24 09:34:26 UTC (rev 14141) |
614 |
+++ main/branches/prefix/pym/portage/cache/metadata.py 2009-08-24 09:36:42 UTC (rev 14142) |
615 |
@@ -6,6 +6,7 @@ |
616 |
import errno |
617 |
import re |
618 |
from portage import os |
619 |
+from portage import _encodings |
620 |
from portage import _unicode_encode |
621 |
from portage.cache import cache_errors, flat_hash |
622 |
import portage.eclass_cache |
623 |
@@ -80,16 +81,18 @@ |
624 |
|
625 |
new_content = [] |
626 |
for k in self.auxdbkey_order: |
627 |
- new_content.append(values.get(k, u'')) |
628 |
- new_content.append(u'\n') |
629 |
+ new_content.append(values.get(k, '')) |
630 |
+ new_content.append('\n') |
631 |
for i in xrange(magic_line_count - len(self.auxdbkey_order)): |
632 |
- new_content.append(u'\n') |
633 |
- new_content = u''.join(new_content) |
634 |
- new_content = _unicode_encode(new_content) |
635 |
+ new_content.append('\n') |
636 |
+ new_content = ''.join(new_content) |
637 |
+ new_content = _unicode_encode(new_content, |
638 |
+ _encodings['repo.content'], errors='backslashreplace') |
639 |
|
640 |
new_fp = os.path.join(self.location, cpv) |
641 |
try: |
642 |
- f = open(_unicode_encode(new_fp), 'rb') |
643 |
+ f = open(_unicode_encode(new_fp, |
644 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
645 |
except EnvironmentError: |
646 |
pass |
647 |
else: |
648 |
@@ -117,12 +120,14 @@ |
649 |
fp = os.path.join(self.location,cpv[:s], |
650 |
".update.%i.%s" % (os.getpid(), cpv[s+1:])) |
651 |
try: |
652 |
- myf = open(_unicode_encode(fp), 'wb') |
653 |
+ myf = open(_unicode_encode(fp, |
654 |
+ encoding=_encodings['fs'], errors='strict'), 'wb') |
655 |
except EnvironmentError, e: |
656 |
if errno.ENOENT == e.errno: |
657 |
try: |
658 |
self._ensure_dirs(cpv) |
659 |
- myf = open(_unicode_encode(fp), 'wb') |
660 |
+ myf = open(_unicode_encode(fp, |
661 |
+ encoding=_encodings['fs'], errors='strict'), 'wb') |
662 |
except EnvironmentError, e: |
663 |
raise cache_errors.CacheCorruption(cpv, e) |
664 |
else: |