1 |
commit: eab5a6ee1abff1fbf142cf1558ba940b6d4b270a |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Sep 6 18:34:57 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Sep 6 18:34:57 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=eab5a6ee |
7 |
|
8 |
merge: avoid abssymlink readlink call |
9 |
|
10 |
This will avoid the "OSError: [Errno 2] No such file or directory" that |
11 |
is triggered inside abssymlink if the merge encoding is not ascii or |
12 |
utf_8, as shown in bug #382021. |
13 |
|
14 |
--- |
15 |
pym/portage/__init__.py | 7 +++++-- |
16 |
pym/portage/dbapi/vartree.py | 7 ++++++- |
17 |
2 files changed, 11 insertions(+), 3 deletions(-) |
18 |
|
19 |
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py |
20 |
index 901ea2c..d73ea6d 100644 |
21 |
--- a/pym/portage/__init__.py |
22 |
+++ b/pym/portage/__init__.py |
23 |
@@ -391,9 +391,12 @@ def getcwd(): |
24 |
return "/" |
25 |
getcwd() |
26 |
|
27 |
-def abssymlink(symlink): |
28 |
+def abssymlink(symlink, target=None): |
29 |
"This reads symlinks, resolving the relative symlinks, and returning the absolute." |
30 |
- mylink=os.readlink(symlink) |
31 |
+ if target is None: |
32 |
+ mylink = target |
33 |
+ else: |
34 |
+ mylink = os.readlink(symlink) |
35 |
if mylink[0] != '/': |
36 |
mydir=os.path.dirname(symlink) |
37 |
mylink=mydir+"/"+mylink |
38 |
|
39 |
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py |
40 |
index bafe138..4d0a6dd 100644 |
41 |
--- a/pym/portage/dbapi/vartree.py |
42 |
+++ b/pym/portage/dbapi/vartree.py |
43 |
@@ -4013,7 +4013,12 @@ class dblink(object): |
44 |
os.unlink(mysrc) |
45 |
os.symlink(myto, mysrc) |
46 |
|
47 |
- myabsto = abssymlink(mysrc) |
48 |
+ # Pass in the symlink target in order to bypass the |
49 |
+ # os.readlink() call inside abssymlink(), since that |
50 |
+ # call is unsafe if the merge encoding is not ascii |
51 |
+ # or utf_8 (see bug #382021). |
52 |
+ myabsto = abssymlink(mysrc, target=myto) |
53 |
+ |
54 |
if myabsto.startswith(srcroot): |
55 |
myabsto = myabsto[len(srcroot):] |
56 |
myabsto = myabsto.lstrip(sep) |