1 |
Author: zmedico |
2 |
Date: 2008-10-28 04:04:56 +0000 (Tue, 28 Oct 2008) |
3 |
New Revision: 11730 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/dbapi/vartree.py |
7 |
Log: |
8 |
Pass $ROOT into the LinkageMap._ObjectKey constructor since it's needed for |
9 |
os.stat() and realpath() calls. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/portage/dbapi/vartree.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/portage/dbapi/vartree.py 2008-10-28 03:41:32 UTC (rev 11729) |
15 |
+++ main/trunk/pym/portage/dbapi/vartree.py 2008-10-28 04:04:56 UTC (rev 11730) |
16 |
@@ -144,9 +144,10 @@ |
17 |
|
18 |
def __init__(self, vardbapi): |
19 |
self._dbapi = vardbapi |
20 |
+ self._root = self._dbapi.root |
21 |
self._libs = {} |
22 |
self._obj_properties = {} |
23 |
- self._defpath = set(getlibpaths(self._dbapi.root)) |
24 |
+ self._defpath = set(getlibpaths(self._root)) |
25 |
self._obj_key_cache = {} |
26 |
|
27 |
class _ObjectKey(object): |
28 |
@@ -155,7 +156,7 @@ |
29 |
|
30 |
__slots__ = ("__weakref__", "_key") |
31 |
|
32 |
- def __init__(self, object): |
33 |
+ def __init__(self, object, root): |
34 |
""" |
35 |
This takes a path to an object. |
36 |
|
37 |
@@ -163,7 +164,7 @@ |
38 |
@type object: string (example: '/usr/bin/bar') |
39 |
|
40 |
""" |
41 |
- self._key = self._generate_object_key(object) |
42 |
+ self._key = self._generate_object_key(object, root) |
43 |
|
44 |
def __hash__(self): |
45 |
return hash(self._key) |
46 |
@@ -171,7 +172,7 @@ |
47 |
def __eq__(self, other): |
48 |
return self._key == other._key |
49 |
|
50 |
- def _generate_object_key(self, object): |
51 |
+ def _generate_object_key(self, object, root): |
52 |
""" |
53 |
Generate object key for a given object. |
54 |
|
55 |
@@ -185,12 +186,13 @@ |
56 |
2. realpath of object if object does not exist. |
57 |
|
58 |
""" |
59 |
+ abs_path = os.path.join(root, object.lstrip(os.path.sep)) |
60 |
try: |
61 |
- object_stat = os.stat(object) |
62 |
+ object_stat = os.stat(abs_path) |
63 |
except OSError: |
64 |
# Use the realpath as the key if the file does not exists on the |
65 |
# filesystem. |
66 |
- return os.path.realpath(object) |
67 |
+ return os.path.realpath(abs_path) |
68 |
# Return a tuple of the device and inode. |
69 |
return (object_stat.st_dev, object_stat.st_ino) |
70 |
|
71 |
@@ -207,6 +209,7 @@ |
72 |
return isinstance(self._key, tuple) |
73 |
|
74 |
def rebuild(self, include_file=None): |
75 |
+ root = self._root |
76 |
libs = {} |
77 |
obj_key_cache = {} |
78 |
obj_properties = {} |
79 |
@@ -239,7 +242,7 @@ |
80 |
continue |
81 |
arch = fields[0] |
82 |
obj = fields[1] |
83 |
- obj_key = self._ObjectKey(obj) |
84 |
+ obj_key = self._ObjectKey(obj, root) |
85 |
soname = fields[2] |
86 |
path = set([normalize_path(x) |
87 |
for x in filter(None, fields[3].replace( |
88 |
@@ -313,7 +316,7 @@ |
89 |
if obj in self._obj_key_cache: |
90 |
obj_key = self._obj_key_cache.get(obj) |
91 |
else: |
92 |
- obj_key = self._ObjectKey(obj) |
93 |
+ obj_key = self._ObjectKey(obj, self._root) |
94 |
# Check that the library exists on the filesystem. |
95 |
if obj_key.file_exists(): |
96 |
# Get the arch and soname from LinkageMap._obj_properties if |
97 |
@@ -427,7 +430,7 @@ |
98 |
|
99 |
""" |
100 |
basename = os.path.basename(obj) |
101 |
- obj_key = self._ObjectKey(obj) |
102 |
+ obj_key = self._ObjectKey(obj, self._root) |
103 |
if obj_key not in self._obj_properties: |
104 |
raise KeyError("%s (%s) not in object list" % (obj_key, obj)) |
105 |
soname = self._obj_properties[obj_key][3] |
106 |
@@ -501,7 +504,7 @@ |
107 |
else: |
108 |
obj_key = self._obj_key_cache.get(obj) |
109 |
if obj_key not in self._obj_properties: |
110 |
- obj_key = self._ObjectKey(obj) |
111 |
+ obj_key = self._ObjectKey(obj, self._root) |
112 |
if obj_key not in self._obj_properties: |
113 |
raise KeyError("%s (%s) not in object list" % (obj_key, obj)) |
114 |
|
115 |
@@ -555,7 +558,7 @@ |
116 |
objs = set([obj]) |
117 |
obj_key = self._obj_key_cache.get(obj) |
118 |
if obj_key not in self._obj_properties: |
119 |
- obj_key = self._ObjectKey(obj) |
120 |
+ obj_key = self._ObjectKey(obj, self._root) |
121 |
if obj_key not in self._obj_properties: |
122 |
raise KeyError("%s (%s) not in object list" % (obj_key, obj)) |