1 |
Author: zmedico |
2 |
Date: 2008-10-28 05:30:33 +0000 (Tue, 28 Oct 2008) |
3 |
New Revision: 11731 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/dbapi/vartree.py |
7 |
Log: |
8 |
Fix incorrect $ROOT handling inside dblink._preserve_libs(). |
9 |
|
10 |
|
11 |
Modified: main/trunk/pym/portage/dbapi/vartree.py |
12 |
=================================================================== |
13 |
--- main/trunk/pym/portage/dbapi/vartree.py 2008-10-28 04:04:56 UTC (rev 11730) |
14 |
+++ main/trunk/pym/portage/dbapi/vartree.py 2008-10-28 05:30:33 UTC (rev 11731) |
15 |
@@ -2425,13 +2425,30 @@ |
16 |
old_libs = old_contents.intersection(liblist) |
17 |
|
18 |
# get list of libraries from new package instance |
19 |
- mylibs = set([os.path.join(os.sep, x) for x in mycontents]).intersection(liblist) |
20 |
+ mycontents = set(os.path.join(os.path.sep, x) for x in mycontents) |
21 |
+ mylibs = mycontents.intersection(liblist) |
22 |
|
23 |
# check which libs are present in the old, but not the new package instance |
24 |
candidates = old_libs.difference(mylibs) |
25 |
- |
26 |
+ candidates_inodes = set() |
27 |
+ for x in candidates: |
28 |
+ x_destroot = os.path.join(destroot, x.lstrip(os.path.sep)) |
29 |
+ try: |
30 |
+ st = os.stat(x_destroot) |
31 |
+ except OSError: |
32 |
+ continue |
33 |
+ candidates_inodes.add((st.st_dev, st.st_ino)) |
34 |
+ |
35 |
for x in old_contents: |
36 |
- if os.path.islink(x) and os.path.realpath(x) in candidates and x not in mycontents: |
37 |
+ x_destroot = os.path.join(destroot, x.lstrip(os.path.sep)) |
38 |
+ if not os.path.islink(x_destroot): |
39 |
+ continue |
40 |
+ try: |
41 |
+ st = os.stat(x_destroot) |
42 |
+ except OSError: |
43 |
+ continue |
44 |
+ if (st.st_dev, st.st_ino) in candidates_inodes and \ |
45 |
+ x not in mycontents: |
46 |
candidates.add(x) |
47 |
|
48 |
provider_cache = {} |
49 |
@@ -2503,12 +2520,14 @@ |
50 |
candidates_stack = list(candidates) |
51 |
while candidates_stack: |
52 |
x = candidates_stack.pop() |
53 |
+ x_srcroot = os.path.join(srcroot, x.lstrip(os.path.sep)) |
54 |
+ x_destroot = os.path.join(destroot, x.lstrip(os.path.sep)) |
55 |
# skip existing files so the 'new' libs aren't overwritten |
56 |
if os.path.exists(os.path.join(srcroot, x.lstrip(os.sep))): |
57 |
continue |
58 |
showMessage("injecting %s into %s\n" % (x, srcroot), |
59 |
noiselevel=-1) |
60 |
- if not os.path.exists(os.path.join(destroot, x.lstrip(os.sep))): |
61 |
+ if not os.path.exists(x_destroot): |
62 |
showMessage("%s does not exist so can't be preserved\n" % x, |
63 |
noiselevel=-1) |
64 |
continue |
65 |
@@ -2519,8 +2538,8 @@ |
66 |
# resolve symlinks and extend preserve list |
67 |
# NOTE: we're extending the list in the loop to emulate recursion to |
68 |
# also get indirect symlinks |
69 |
- if os.path.islink(x): |
70 |
- linktarget = os.readlink(x) |
71 |
+ if os.path.islink(x_destroot): |
72 |
+ linktarget = os.readlink(x_destroot) |
73 |
os.symlink(linktarget, os.path.join(srcroot, x.lstrip(os.sep))) |
74 |
if linktarget[0] != os.sep: |
75 |
linktarget = os.path.join(os.path.dirname(x), linktarget) |
76 |
@@ -2528,8 +2547,7 @@ |
77 |
candidates.add(linktarget) |
78 |
candidates_stack.append(linktarget) |
79 |
else: |
80 |
- shutil.copy2(os.path.join(destroot, x.lstrip(os.sep)), |
81 |
- os.path.join(srcroot, x.lstrip(os.sep))) |
82 |
+ shutil.copy2(x_destroot, x_srcroot) |
83 |
preserve_paths.append(x) |
84 |
|
85 |
del candidates |