1 |
Author: zmedico |
2 |
Date: 2009-08-24 01:27:20 +0000 (Mon, 24 Aug 2009) |
3 |
New Revision: 14134 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/dbapi/bintree.py |
7 |
main/trunk/pym/portage/update.py |
8 |
main/trunk/pym/portage/xpak.py |
9 |
Log: |
10 |
Bug #282505 - Fix unicode handling for package moves in binary packages. |
11 |
|
12 |
|
13 |
Modified: main/trunk/pym/portage/dbapi/bintree.py |
14 |
=================================================================== |
15 |
--- main/trunk/pym/portage/dbapi/bintree.py 2009-08-24 00:29:34 UTC (rev 14133) |
16 |
+++ main/trunk/pym/portage/dbapi/bintree.py 2009-08-24 01:27:20 UTC (rev 14134) |
17 |
@@ -263,13 +263,21 @@ |
18 |
mydata = mytbz2.get_data() |
19 |
updated_items = update_dbentries([mylist], mydata) |
20 |
mydata.update(updated_items) |
21 |
- mydata["PF"] = mynewpkg + "\n" |
22 |
- mydata["CATEGORY"] = mynewcat+"\n" |
23 |
+ mydata[_unicode_encode('PF', |
24 |
+ encoding=_encodings['repo.content'])] = \ |
25 |
+ _unicode_encode(mynewpkg + "\n", |
26 |
+ encoding=_encodings['repo.content']) |
27 |
+ mydata[_unicode_encode('CATEGORY', |
28 |
+ encoding=_encodings['repo.content'])] = \ |
29 |
+ _unicode_encode(mynewcat + "\n", |
30 |
+ encoding=_encodings['repo.content']) |
31 |
if mynewpkg != myoldpkg: |
32 |
- ebuild_data = mydata.get(myoldpkg+".ebuild") |
33 |
+ ebuild_data = mydata.pop(_unicode_encode(myoldpkg + '.ebuild', |
34 |
+ encoding=_encodings['repo.content']), None) |
35 |
if ebuild_data is not None: |
36 |
- mydata[mynewpkg+".ebuild"] = ebuild_data |
37 |
- del mydata[myoldpkg+".ebuild"] |
38 |
+ mydata[_unicode_encode(mynewpkg + '.ebuild', |
39 |
+ encoding=_encodings['repo.content'])] = ebuild_data |
40 |
+ |
41 |
mytbz2.recompose_mem(portage.xpak.xpak_mem(mydata)) |
42 |
|
43 |
self.dbapi.cpv_remove(mycpv) |
44 |
|
45 |
Modified: main/trunk/pym/portage/update.py |
46 |
=================================================================== |
47 |
--- main/trunk/pym/portage/update.py 2009-08-24 00:29:34 UTC (rev 14133) |
48 |
+++ main/trunk/pym/portage/update.py 2009-08-24 01:27:20 UTC (rev 14134) |
49 |
@@ -55,12 +55,18 @@ |
50 |
dict containing only the updated items.""" |
51 |
updated_items = {} |
52 |
for k, mycontent in mydata.iteritems(): |
53 |
- if k not in ignored_dbentries: |
54 |
+ k_unicode = _unicode_decode(k, |
55 |
+ encoding=_encodings['repo.content'], errors='replace') |
56 |
+ if k_unicode not in ignored_dbentries: |
57 |
+ mycontent = _unicode_decode(mycontent, |
58 |
+ encoding=_encodings['repo.content'], errors='replace') |
59 |
orig_content = mycontent |
60 |
for update_cmd in update_iter: |
61 |
mycontent = update_dbentry(update_cmd, mycontent) |
62 |
if mycontent != orig_content: |
63 |
- updated_items[k] = mycontent |
64 |
+ updated_items[k] = _unicode_encode(mycontent, |
65 |
+ encoding=_encodings['repo.content'], |
66 |
+ errors='backslashreplace') |
67 |
return updated_items |
68 |
|
69 |
def fixdbentries(update_iter, dbdir): |
70 |
@@ -77,7 +83,7 @@ |
71 |
updated_items = update_dbentries(update_iter, mydata) |
72 |
for myfile, mycontent in updated_items.iteritems(): |
73 |
file_path = os.path.join(dbdir, myfile) |
74 |
- write_atomic(file_path, mycontent) |
75 |
+ write_atomic(file_path, mycontent, encoding=_encodings['repo.content']) |
76 |
return len(updated_items) > 0 |
77 |
|
78 |
def grab_updates(updpath, prev_mtimes=None): |
79 |
|
80 |
Modified: main/trunk/pym/portage/xpak.py |
81 |
=================================================================== |
82 |
--- main/trunk/pym/portage/xpak.py 2009-08-24 00:29:34 UTC (rev 14133) |
83 |
+++ main/trunk/pym/portage/xpak.py 2009-08-24 01:27:20 UTC (rev 14134) |
84 |
@@ -97,6 +97,17 @@ |
85 |
|
86 |
def xpak_mem(mydata): |
87 |
"""Create an xpack segement from a map object.""" |
88 |
+ |
89 |
+ mydata_encoded = {} |
90 |
+ for k, v in mydata.iteritems(): |
91 |
+ k = _unicode_encode(k, |
92 |
+ encoding=_encodings['repo.content'], errors='backslashreplace') |
93 |
+ v = _unicode_encode(v, |
94 |
+ encoding=_encodings['repo.content'], errors='backslashreplace') |
95 |
+ mydata_encoded[k] = v |
96 |
+ mydata = mydata_encoded |
97 |
+ del mydata_encoded |
98 |
+ |
99 |
indexglob = _unicode_encode('') |
100 |
indexpos=0 |
101 |
dataglob = _unicode_encode('') |